sqlalchemy / alembic

A database migrations tool for SQLAlchemy.
MIT License
2.61k stars 234 forks source link

Sql Server default constraints have generated names #1413

Closed marshall62 closed 5 months ago

marshall62 commented 5 months ago

The use of server_default results in a generated constraint in Sql Server.
op.add_column("OrderTable", sa.Column("item_counter", sa.Integer(), nullable=False, server_default="0"))

A constraint like df_OrderTable_item_cou__5A843B7E3. is generated when alembic upgrade is run.

At present, there is no way to gain control over the name of the constraint. This means that the downgrade function fails because there is no way to add a command to delete the constraint.

zzzeek commented 5 months ago

use mssql_drop_default for this.