When i run php artisan migrate i keep getting this error:
[Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1005 Can't create table
binomi
.#sql-3910_c0b
(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table users add constraintusers_activity_foreign
foreign key (activity
) referencesactivity
(id
) on delete cascade) [PDOException] SQLSTATE[HY000]: General error: 1005 Can't create tablebinomi
.#sql-3910_c0b
(errno: 150 "Foreign key constraint is incorrectly formed")
Here is the schema for my user and activity model and those are the only models in the app.
User migration:
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->integer('activity');
$table->rememberToken();
$table->timestamps();
});
Schema::table('users', function($table){
$table->foreign('activity')->references('id')->on('activity')->onDelete('cascade');
}
Activity migration:
Schema::create('activty', function (Blueprint $table) {
$table->increments('id');
$table->string('label');
});