Im trying to migrate on of my table but when im doing the laravel migration heres an error that show.
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table subscribers
add constraint subscribers_user_id_foreign
foreign key (user_id
) references users
(id
) on delete set null)
Here's my table that i want to migrate:
Schema::create('subscribers', function (Blueprint $table) {
$table->increments('id');
$table->string('account_no');
$table->enum('type',['individual','company'])->default('individual');
$table->string('title')->nullable();
$table->string('firstname');
$table->string('middlename');
$table->string('lastname');
$table->string('suffix')->nullable();
$table->enum('gender',['male','female']);
$table->date('birthday')->nullable();
$table->string('contact_no');
$table->string('email');
$table->tinyInteger('status')->default(1);
$table->integer('user_id')->unsigned();
$table->unsignedInteger('created_by');
$table->unsignedInteger('updated_by');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
});