Manual edits to Alembic migration file not being implemented

3 weeks ago 19
ARTICLE AD BOX

I am attempting to include some manual updates to an alembic-generated migration file for my sqlite database. I have a models.py where tables are defined.

The update of the auto-generated table works just fine, however I want the table to be created and then populated with some default values. This wasn't working, so I decided to test out editing the migration file in a simple way: I attempted to add a line for a new column that did not exist in my models.py definition. When I downgrade, delete, recreate, edit, and upgrade, alembic creates the table in the db but completely ignores my manual updates to the migration file.

Sample migration upgrade:

from alembic import op import sqlalchemy as sa def upgrade() -> None: """Upgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.create_table('sample_table', sa.Column('auto_generated_1', sa.Integer(), nullable=False), sa.Column('MANUAL_ADDITION',sa.Integer(), nullable=False), sa.Column('auto_generated_2', sa.Integer(), nullable=False), ) # ### end Alembic commands ###

When I run "alembic upgrade head", the MANUAL_ADDITION column I added to the migration file is completely ignored. I have checked the alembic versions as well and it matches the upgrades/downgrades as expected.

What's going on here? I am at a loss.

Read Entire Article