You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
migrate:fresh fails to drop tables because of FK constraints on mysql. This is true both with and w/o the -f option.
To Reproduce
Steps to reproduce the behavior:
On a mysql DB, create a migration that defines a schema with two tables A and B where B has a FK on A with FK constraint
with self.schema.create("A") as table:
table.increments("rowid").primary()
with self.schema.create("B") as table:
table.increments("rowid").primary()
table.unsigned_integer('a_id', nullable=False)
table.foreign('a_id').references('rowid').on('A')
Run masonite-orm migrate:fresh (will succeed)
Run masonite-orm migrate:fresh (will fail, see below)
See error
Expected behavior
Should delete all tables and re-create the schema
Actual results "Cannot drop table 'A' referenced by a foreign key constraint 'b_a_id_foreign' on table 'B'.")
Desktop (please complete the following information):
OS: Rocky linux
Version: "8.6 (Green Obsidian)"
What database are you using?
Type: mysql
Version 8.0.30
Masonite ORM 2.23.2
Additional context
If you rename A to C so that the alpha order is reversed then it will work. It seems that the table deletion is done in alpha order rather than based on a dependency graph. The -f argument fails to disable the FK constraints so that the table drop may proceed.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
migrate:fresh fails to drop tables because of FK constraints on mysql. This is true both with and w/o the -f option.
To Reproduce
Steps to reproduce the behavior:
masonite-orm migrate:fresh
(will succeed)masonite-orm migrate:fresh
(will fail, see below)Expected behavior
Should delete all tables and re-create the schema
Actual results
"Cannot drop table 'A' referenced by a foreign key constraint 'b_a_id_foreign' on table 'B'.")
Desktop (please complete the following information):
What database are you using?
Additional context
If you rename A to C so that the alpha order is reversed then it will work. It seems that the table deletion is done in alpha order rather than based on a dependency graph. The
-f
argument fails to disable the FK constraints so that the table drop may proceed.The text was updated successfully, but these errors were encountered: