Browse Source

Add foreign key constraint for creator_id

This foreign key constrains will prevents creator record
deletion from users table.
tags/1.2.9
Nafies Luthfi 7 years ago
parent
commit
61afdd92dd
  1. 2
      src/stubs/database/migrations/migration-create.stub
  2. 2
      tests/Generators/MigrationGeneratorTest.php

2
src/stubs/database/migrations/migration-create.stub

@ -19,6 +19,8 @@ class CreateMastersTable extends Migration
$table->string('description')->nullable();
$table->unsignedInteger('creator_id');
$table->timestamps();
$table->foreign('creator_id')->references('id')->on('users')->onDelete('restrict');
});
}

2
tests/Generators/MigrationGeneratorTest.php

@ -34,6 +34,8 @@ class Create{$this->plural_model_name}Table extends Migration
\$table->string('description')->nullable();
\$table->unsignedInteger('creator_id');
\$table->timestamps();
\$table->foreign('creator_id')->references('id')->on('users')->onDelete('restrict');
});
}

Loading…
Cancel
Save