Migrated issue, originally created by abluevine
Hi all and thanks for a really great and useful project!
I'm using alembic with postgres 9.5.7 to manage the public schema.
My model looks like this:
class DecisionEngineDecisionsLog(Base, TableMixin):
__tablename__ = 'pack_decisions_engine_decisions_log'
...
rule_execution_id = Column('rule_execution_id', INTEGER, ForeignKey(DecisionEngineRulesLog.id, name='pack_decisions_engine_decisions_log_rule_fkey'))
analyst_message_id = Column('analyst_message_id', INTEGER, ForeignKey(AnalystMessage.id, name='pack_decisions_engine_decisions_log_analyst_message_id_fkey'))
the generated migrations keep dropping and recreating the foreign key constrains over and over again:
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('pack_decisions_engine_decisions_log_rule_fkey', 'pack_decisions_engine_decisions_log', type_='foreignkey')
op.drop_constraint('pack_decisions_engine_decisions_log_analyst_message_id_fkey', 'pack_decisions_engine_decisions_log', type_='foreignkey')
op.create_foreign_key('pack_decisions_engine_decisions_log_rule_fkey', 'pack_decisions_engine_decisions_log', 'pack_decisions_engine_rules_log', ['rule_execution_id'], ['id'], source_schema='public', referent_schema='public')
op.create_foreign_key('pack_decisions_engine_decisions_log_analyst_message_id_fkey', 'pack_decisions_engine_decisions_log', 'analystmessage', ['analyst_message_id'], ['id'], source_schema='public', referent_schema='public')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('pack_decisions_engine_decisions_log_analyst_message_id_fkey', 'pack_decisions_engine_decisions_log', schema='public', type_='foreignkey')
op.drop_constraint('pack_decisions_engine_decisions_log_rule_fkey', 'pack_decisions_engine_decisions_log', schema='public', type_='foreignkey')
op.create_foreign_key('pack_decisions_engine_decisions_log_analyst_message_id_fkey', 'pack_decisions_engine_decisions_log', 'analystmessage', ['analyst_message_id'], ['id'])
op.create_foreign_key('pack_decisions_engine_decisions_log_rule_fkey', 'pack_decisions_engine_decisions_log', 'pack_decisions_engine_rules_log', ['rule_execution_id'], ['id'])
# ### end Alembic commands ###
I noticed that another issue was found to be related to keys between different schemas, this is not my case.
thanks in advance for helping
Akiva
该提问来源于开源项目:sqlalchemy/alembic