Wenn ich php Handwerkers Migrate laufen halten i diesen Fehler:Allgemeiner Fehler: 1005 Can not create table
[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")
Hier ist das Schema für meine Benutzer und Aktivitätsmodell und das sind die einzigen Modelle die App.
Benutzermigration:
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');
}
Aktivität Migration:
Schema::create('activty', function (Blueprint $table) {
$table->increments('id');
$table->string('label');
});
Bemerkt die ";;" am Ende Ihrer Fremdschlüsselzeile? – Duikboot
es ist nur ein Tippfehler @Duikboot –