2

I have a table which i created as shown below

op.create_table('test', sa.Column('userid', sa.String(length=60), nullable=False), sa.Column('page_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['userid'], ['map.userid']), ) 

I want add a ondelete="CASCADE" constraint on the foreign key. I understand we need to do drop_contraint and create_foreign_key. But how do i drop_contraint foreign key which has no Name in alembic?

1
  • 1
    Please google your title. Commented Jun 6, 2017 at 5:25

1 Answer 1

3

If ForeignKey was created without name, then the name will be autogenerated. The format of this name is dependent on the database you’re using.

The name can be found, for instance, like this:

 SELECT * FROM information_schema.key_column_usage WHERE table_name='$table_name'; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.