1
<?php
2

3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6

7
class CreateLogModelEventsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14 1
    public function up()
15
    {
16
        Schema::create('log_model_events', function (Blueprint $table) {
17 1
            $table->increments('id');
18 1
            $table->unsignedBigInteger('user_id')->nullable();
19 1
            $table->string('model_type')->index();
20 1
            $table->string('model_id')->index();
21 1
            $table->text('description')->nullable();
22 1
            $table->timestamps();
23

24 1
            $table->foreign('user_id')
25 1
                ->references('id')
26 1
                ->on('users')
27 1
                ->onDelete('cascade');
28 1
        });
29
    }
30

31
    /**
32
     * Reverse the migrations.
33
     *
34
     * @return void
35
     */
36 0
    public function down()
37
    {
38 0
        Schema::dropIfExists('log_model_events');
39
    }
40
}

Read our documentation on viewing source code .

Loading