I am using alembic to manage my database migrations. In my last revision, I realized that alembic identify a difference in one of my id column, and I don't understand why.
Here is the result of the alembic revision --autogenerate -m "update"
command :
def upgrade() -> None:
op.alter_column('calendars', 'id',
existing_type=sa.BIGINT(),
server_default=None,
existing_nullable=False,
autoincrement=True)
def downgrade() -> None:
op.alter_column('calendars', 'id',
existing_type=sa.BIGINT(),
server_default=sa.Identity(always=False, start=1, increment=1),
existing_nullable=False,
autoincrement=True)
I see that there is a difference on the server_default
part but I don't understand why it's finding this.
The column declaration in my model did not change and is :
id = Column(BigInteger, primary_key=True)
The autogenerated migration when I created the table ended up with the following code :
def upgrade() -> None:
op.create_table('calendars',
sa.Column('id', sa.BigInteger(), nullable=False),
...
)
I guess alembic finds a difference in between the column declaration and how it is currently in the db, but I don't understand why it finds such difference, and what is actually the difference. Now I wonder if there is some issue in the original declaration and that there is some inconsistency between the current state of my db and the original table migration.
Can someone explain explain what is going on ?