12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Migrations\Migration;
- class GroupsUsers extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('groups_users', function (Blueprint $table) {
- $table->unsignedInteger('user_id');
- $table->foreign('user_id', 'fk_users')
- ->references('id')
- ->on('users')
- ->onDelete('cascade');
- $table->unsignedInteger('group_id');
- $table->foreign('group_id', 'fk_groups')
- ->references('id')
- ->on('groups')
- ->onDelete('cascade');
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('groups_users', function (Blueprint $table) {
- $table->dropForeign('fk_users');
- $table->dropForeign('fk_groups');
- });
- Schema::dropIfExists('groups_users');
- }
- }
|