generated from MasoniteFramework/starter-package
-
-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Labels
bugAn existing feature is not working as intendedAn existing feature is not working as intended
Description
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.
Metadata
Metadata
Assignees
Labels
bugAn existing feature is not working as intendedAn existing feature is not working as intended