2016_07_03_062439_create_history_tables.php
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Class CreateHistoryTables.
*/
class CreateHistoryTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('history_types', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->string('name');
$table->timestamps();
});
Schema::create('history', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('type_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->integer('entity_id')->unsigned()->nullable();
$table->string('icon')->nullable();
$table->string('class')->nullable();
$table->string('text');
$table->text('assets')->nullable();
$table->timestamps();
$table->foreign('type_id')
->references('id')
->on('history_types')
->onDelete('cascade');
$table->foreign('user_id')
->references('id')
->on(config('access.users_table'))
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('history', function (Blueprint $table) {
$table->dropForeign('history_type_id_foreign');
$table->dropForeign('history_user_id_foreign');
});
Schema::dropIfExists('history_types');
Schema::dropIfExists('history');
}
}