没有检查约束的 Alembic 自动生成迁移
Alembic autogenerate migration without check contraint
我是 alembic 和 sqlalchemy 世界的新手
假设我有模型:
class Model(Base):
__tablename__ = 'models'
id = Column(Integer, primary_key=True)
value = Column(Integer, CheckContraint('value >= 0'))
如果我做 alembic --config=development.ini revision --autogenerate -m "init"
我得到例如
def upgrade():
op.create_table('models',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('value', sa.Integer())
我想念这里 create_check_constraint
我怎样才能自动添加还是应该手动添加?我希望它与 postgresql
一起工作
Alembic 自动生成当前不支持检查约束检测。
Autogenerate can’t currently, but will eventually detect:
Some free-standing constraint additions and removals, like CHECK, PRIMARY KEY - these are not fully implemented.
看来您需要手动完成,例如通过使用 execute.
我是 alembic 和 sqlalchemy 世界的新手
假设我有模型:
class Model(Base):
__tablename__ = 'models'
id = Column(Integer, primary_key=True)
value = Column(Integer, CheckContraint('value >= 0'))
如果我做 alembic --config=development.ini revision --autogenerate -m "init" 我得到例如
def upgrade():
op.create_table('models',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('value', sa.Integer())
我想念这里 create_check_constraint 我怎样才能自动添加还是应该手动添加?我希望它与 postgresql
一起工作Alembic 自动生成当前不支持检查约束检测。
Autogenerate can’t currently, but will eventually detect:
Some free-standing constraint additions and removals, like CHECK, PRIMARY KEY - these are not fully implemented.
看来您需要手动完成,例如通过使用 execute.