10 months ago

SQL cannot add forign key

Posted 10 months ago by mohammed_alama

Hi i have error when hit artisan migrate:fresh to add forign key of user in projects migration

it show me that error

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `projects` add constraint `projects_owner_id_foreign` foreign key (`owner_id`) references `users` (`id`) on delete cascade)

and this is projects migration

  public function up()
        Schema::create('projects', function (Blueprint $table) {
        Schema::table('projects', function($table) {

Please sign in or create an account to participate in this conversation.