Removing foreign key constraints from create_permissions_table #2258
-
Hi all, Im trying to integrate my laravel application with planet scale. to use the planetscale, we cant have the foreign key constraints, For my own migration file its quite simple to remove the constraints, but currently i don't know how to remove it for spatie-permission, On installation, spatie-permission will generate a create_permission_tables table, and i need to remove the constraints on this code
I simply replace this code with this line Can some one show me the right way to do this. Thanks a lot |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
-
NOTE: WITHOUT FOREIGN KEY CONSTRAINTS ENFORCED, YOUR DATA WILL LOSE INTEGRITY. The package enforces "some" but NOT ALL relationships internally. It DOES rely on the foreign key constraints to maintain consistency and to delete related records. That said ... To prevent the migration from setting foreign key relationships you can delete the |
Beta Was this translation helpful? Give feedback.
-
You could simply use:
|
Beta Was this translation helpful? Give feedback.
NOTE: WITHOUT FOREIGN KEY CONSTRAINTS ENFORCED, YOUR DATA WILL LOSE INTEGRITY. The package enforces "some" but NOT ALL relationships internally. It DOES rely on the foreign key constraints to maintain consistency and to delete related records.
That said ...
To prevent the migration from setting foreign key relationships you can delete the
$table->foreign()....;
command from the migration file before running it.or
If you need to remove the foreign key constraint after the migration is already run, create a new migration to remove it.
The command in the migration would be something like:
$table->dropForeign('name_of_foreign_key_here');
. Repeat for each relationship.