【发布时间】:2021-11-20 20:04:48
【问题描述】:
我正在尝试使用 alembic 将迁移应用到 Azure Synapse SQL DW。我在执行alembic upgrade head 时遇到以下问题:
sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Enforced unique constraints are not supported. To create an unenforced unique constraint you must include the NOT ENFORCED syntax as part of your statement. (104467) (SQLExecDirectW)')
[SQL:
CREATE TABLE alembic_version (
version_num VARCHAR(32) NOT NULL,
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
)
]
(Background on this error at: https://sqlalche.me/e/14/f405)
我的版本文件是:
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6c51cb206ea6'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'dqrule',
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('description', sa.String, nullable=False),
sa.Column('source_type', sa.String, nullable=False),
sa.Column('source_schema', sa.String, nullable=False),
sa.Column('source_entity', sa.String, nullable=False)
)
def downgrade():
op.drop_table('dqrule')
【问题讨论】:
-
您可以尝试在 alembic.ini 的
[alembic]部分添加一行version_table_pk = false看看是否有帮助。 -
@GordThompson 该设置似乎没有任何效果
标签: sqlalchemy alembic azure-synapse