Title: How to run a database migration when using SQLModel (such as Alembic)? · Issue #85 · fastapi/sqlmodel · GitHub
Open Graph Title: How to run a database migration when using SQLModel (such as Alembic)? · Issue #85 · fastapi/sqlmodel
X Title: How to run a database migration when using SQLModel (such as Alembic)? · Issue #85 · fastapi/sqlmodel
Description: First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I already searched in Google "How to X in...
Open Graph Description: First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I...
X Description: First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated searc...
Opengraph URL: https://github.com/fastapi/sqlmodel/issues/85
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to run a database migration when using SQLModel (such as Alembic)?","articleBody":"### First Check\r\n\r\n- [X] I added a very descriptive title to this issue.\r\n- [X] I used the GitHub search to find a similar issue and didn't find it.\r\n- [X] I searched the SQLModel documentation, with the integrated search.\r\n- [X] I already searched in Google \"How to X in SQLModel\" and didn't find any information.\r\n- [X] I already read and followed all the tutorial in the docs and didn't find an answer.\r\n- [X] I already checked if it is not related to SQLModel but to [Pydantic](https://github.com/samuelcolvin/pydantic).\r\n- [X] I already checked if it is not related to SQLModel but to [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy).\r\n\r\n### Commit to Help\r\n\r\n- [X] I commit to help with one of those options 👆\r\n\r\n### Example Code\r\n\r\nI created a simple app (based on the documentation using FastAPI and SQLModel)\r\nThis can be run with either Docker or a python virtual environment, to speed things up. \r\n\r\nhttps://github.com/joemudryk/learning-sqlmodel\r\n\r\n\r\n\r\n### Description\r\n\r\nI am trying to:\r\n1. Create a database from the existing model\r\n2. Update the model (or uncomment [this line](https://github.com/joemudryk/learning-sqlmodel/blob/83a6734a69c93d396b395a2849eb0cc7f34a6166/models/hero.py#L10) )\r\n3. Run a database migration such as Alembic\r\n4. Continue to use the application with the updated model and database\r\n\r\nAny help would be greatly appreciated, and maybe the instructions can be used to help update the [official documentation](https://sqlmodel.tiangolo.com/advanced/?h=migration) :) \r\n\r\n### Operating System\r\n\r\nLinux\r\n\r\n### Operating System Details\r\n\r\nLinux Mint 20.1\r\n\r\n### SQLModel Version\r\n\r\n0.0.4\r\n\r\n### Python Version\r\n\r\n3.9.6\r\n\r\n### Additional Context\r\n\r\nI was able to use [Alembic](https://alembic.sqlalchemy.org/en/latest/) for the orm library [ormar](https://collerek.github.io/ormar/) okay. The instructions for that can be found here:\r\nhttps://collerek.github.io/ormar/models/migrations/\r\n\r\nMaybe that will give some insight for the approach I took, or you will find a solution that I didn't.\r\n\r\nThank you in advanced.","author":{"url":"https://github.com/joemudryk","@type":"Person","name":"joemudryk"},"datePublished":"2021-09-08T04:29:15Z","url":"https://github.com/fastapi/sqlmodel/issues/85"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:44c627af-c2c7-cf26-3d2b-171eb0b3d123 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 96B4:580A9:7A469:AEB96:6AFDEE8E |
| html-safe-nonce | 46f7fa508e1613282f152884b09aa3eb58c0b967422b5ac97a3b950521526f66 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkI0OjU4MEE5OjdBNDY5OkFFQjk2OjZBRkRFRThFIiwidmlzaXRvcl9pZCI6IjQ3MTE1NDY0MzIyMTU5Njk0MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7b30955f1a4167d82abd6c7ffb7277e1a1424c7d9ba08a11a0f23b4406d6fe90 |
| hovercard-subject-tag | issue:990702413 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/fastapi/sqlmodel/85/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7acb38c529a8dcde9f49229e22d6d007bef48d6fb71a88da8f4ecaa51691a6da/fastapi/sqlmodel/issues/85 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7acb38c529a8dcde9f49229e22d6d007bef48d6fb71a88da8f4ecaa51691a6da/fastapi/sqlmodel/issues/85 |
| og:image:alt | First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joemudryk |
| hostname | github.com |
| expected-hostname | github.com |
| None | dd812ec581ecac95855f5ec917ef9827506c39a9da1443f43ddb4179a46471eb |
| turbo-cache-control | no-preview |
| go-import | github.com/fastapi/sqlmodel git https://github.com/fastapi/sqlmodel.git |
| octolytics-dimension-user_id | 156354296 |
| octolytics-dimension-user_login | fastapi |
| octolytics-dimension-repository_id | 399495186 |
| octolytics-dimension-repository_nwo | fastapi/sqlmodel |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 399495186 |
| octolytics-dimension-repository_network_root_nwo | fastapi/sqlmodel |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 32ac708bac264dafdc28e10ff49b4d137f0c34a7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width