2020_01_10_083534_create_entries_table.php 934 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
class CreateEntriesTable extends Migration
Jacob Priddy's avatar
Jacob Priddy committed
8
9
10
11
12
13
14
15
16
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // This table logs all invalid attempts to open a door
17
18
19
        Schema::create('entries', static function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
Jacob Priddy's avatar
Jacob Priddy committed
20
            $table->unsignedBigInteger('door_id');
21
            $table->boolean('success');
Jacob Priddy's avatar
Jacob Priddy committed
22
            $table->foreign('door_id')->references('id')->on('doors');
23
            $table->foreign('user_id')->references('id')->on('users');
Jacob Priddy's avatar
Jacob Priddy committed
24
25
26
27
28
29
30
31
32
33
34
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
35
        Schema::dropIfExists('entries');
Jacob Priddy's avatar
Jacob Priddy committed
36
37
    }
}