2020_01_10_080601_create_group_user_table.php 907 Bytes
Newer Older
Jacob Priddy's avatar
Jacob Priddy committed
1
2
3
<?php

use Illuminate\Support\Facades\Schema;
Jacob Priddy's avatar
Jacob Priddy committed
4
5
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
Jacob Priddy's avatar
Jacob Priddy committed
6
7
8
9
10
11
12
13
14
15
16

class CreateGroupUserTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // This table is a pivot table mapping users into groups
17
18
        Schema::create('group_user', static function (Blueprint $table) {
            $table->id();
Jacob Priddy's avatar
Jacob Priddy committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users');
            $table->unsignedBigInteger('group_id');
            $table->foreign('group_id')->references('id')->on('groups');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('group_user');
    }
}