Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Conversation

@aponcedeleonch
Copy link
Member

@aponcedeleonch aponcedeleonch commented Jan 15, 2025

Related: #583

We had been using a single DB schema that didn't change until now. This introduces migrations using alembic. To create a new migration one can use:

alembic revision -m "My migration"

That should generate an empty migration file that needs to be hand-filled. Specifically the upgrade method which will be the one executed when running the migration. See the existent migration 30d0144e1a50_init_db.py for a filled example.

"""My migration

Revision ID: <some_hash>
Revises: <previous_hash>
Create Date: YYYY-MM-DD HH:MM:SS.XXXXXX
"""
from alembic import op
import sqlalchemy as sa

revision = '<some_hash>'
down_revision = '<previous_hash>'
branch_labels = None
depends_on = None

def upgrade():
    pass

def downgrade():
    pass

Related: #583

We had been using a single DB schema that didn't change until now.
This introduces migrations using `alembic`. To create a new migration
one can use:
```sh
alembic revision -m "My migration"
```
That should generate an empty migration file that needs to be hand-filled.
Specifically the `upgrade` method which will be the one executed when
running the migration.
```python
"""My migration

Revision ID: <some_hash>
Revises: <previous_hash>
Create Date: YYYY-MM-DD HH:MM:SS.XXXXXX
"""
from alembic import op
import sqlalchemy as sa

revision = '<some_hash>'
down_revision = '<previous_hash>'
branch_labels = None
depends_on = None

def upgrade():
    pass

def downgrade():
    pass
```
JAORMX
JAORMX previously approved these changes Jan 15, 2025
@aponcedeleonch aponcedeleonch merged commit 7593f72 into main Jan 15, 2025
2 checks passed
@aponcedeleonch aponcedeleonch deleted the db-migrations branch January 15, 2025 12:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants