2020_01_10_081021_create_user_door_table.php 1021 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
17

class CreateUserDoorTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // This table maps special cases of users getting access to doors
        // without being in a special group.
18
19
        Schema::create('user_door', static function (Blueprint $table) {
            $table->id();
Jacob Priddy's avatar
Jacob Priddy committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
            $table->unsignedBigInteger('door_id');
            $table->foreign('door_id')->references('id')->on('doors');
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users');
            $table->boolean('open_mode_allowed')->default(false);
            $table->timestamps();
        });
    }

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