Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 docs: add migrations section #512

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ezeparziale
Copy link

I added the migrations section to use SQLModel with alembic.

  • Initial example
  • Step by step
  • Example codes

@github-actions
Copy link

📝 Docs preview for commit eb3ca5e at: https://639a800274ad247dd834e997--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 3cf251f at: https://639a88d88095c57f0274e6fd--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit feea75f at: https://639a8a3c2fbcf011a10ebd78--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 51d83a6 at: https://639cdd9a18290c00b4ff5209--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 3437837 at: https://639e7f62ce461c1a81789517--sqlmodel.netlify.app

@locomoco28
Copy link

locomoco28 commented Apr 20, 2023

Hello, is this the recommended approach now? Alembic is a little intimidating to me, so I'd prefer to be ensured that Alembic is the migration tool of choice, and to have a tutorial from SQLModel. The previews are a little scuffed with the code blocks ^^

(@tiangolo)

@guysoft
Copy link

guysoft commented Apr 24, 2023

Hey, it would be nice to have this in the docs. I am trying to get this to work on my project, and there is barely any documentation on how to use Alembic with SQLModel. I've been trying to read it from the CI, but the code examples are omitted.

@locomoco28 Do you know of any other tool to manage migrations? I could not find an alternative, and Alembic seems to be well integrated with sqlalchemy

I found only this:
https://www.youtube.com/watch?v=gekC1ESLxPs

@locomoco28
Copy link

I unfortunately do not have any experience with any other migration tooling as I'm coming from the NodeJS world and wanted to use SQLModel for pretty much my first Python project at work.

Thank you for the resource, I'll look into it in the coming days as we're prioritizing a first running beta for now only :)

@ezeparziale
Copy link
Author

I unfortunately do not have any experience with any other migration tooling as I'm coming from the NodeJS world and wanted to use SQLModel for pretty much my first Python project at work.

Thank you for the resource, I'll look into it in the coming days as we're prioritizing a first running beta for now only :)

Hello! see my example in https://github.com/ezeparziale/fastapi-sqlmodel
The secret is config the env.py from alembic, then is only run alembic revision --autogenerate - m "my_message", and finally alembic upgrade head

@locomoco28
Copy link

Hey, thank you both for the resources. It really was easy to set up. I'm using asyncpg (with create_async_engine from sqlalchemy) so my connection uri is postgresql+asyncpg:// which required me to run initialize Alembic using the -t async flag according to this cookbook I found: https://alembic.sqlalchemy.org/en/latest/cookbook.html#using-asyncio-with-alembic

Appreciate your help!

@tiangolo tiangolo added the docs Improvements or additions to documentation label Oct 22, 2023
@caerulescens caerulescens mentioned this pull request Feb 4, 2024
9 tasks
@sparklog
Copy link

alembic seems like not work well with sqllite, because that sqllite does not support alter method.

@Diegovsky
Copy link

alembic seems like not work well with sqllite, because that sqllite does not support alter method.

https://sqlite.org/lang_altertable.html
it does?

@ezeparziale
Copy link
Author

alembic seems like not work well with sqllite, because that sqllite does not support alter method.

https://alembic.sqlalchemy.org/en/latest/batch.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants