Answer the question
In order to leave comments, you need to log in
How to overcome the transition to Postgres and the problem with FOREIGN KEY?
Hello.
I am using the Laratrust component for roles in a project.
It has a table:
// Create table for associating roles to users (Many-to-Many)
Schema::create('role_user', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['user_id', 'role_id']);
});
Answer the question
In order to leave comments, you need to log in
SET FOREIGN_KEY_CHECKS
works only in MySQL, in Postgres there is no such thing, you need to disable one table at a time. - disable - enable ALTER TABLE permission_role ENABLE TRIGGER ALL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question