|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
5
|
|
|
|
|
6
|
|
|
class CreateContents extends Migration |
|
7
|
|
|
{ |
|
8
|
|
|
public function fieldTableFields(Blueprint $table) |
|
9
|
|
|
{ |
|
10
|
|
|
$table->increments('id'); |
|
11
|
|
|
$table->string('name'); |
|
12
|
|
|
$table->integer('weight'); |
|
13
|
|
|
|
|
14
|
|
|
$table->timestamps(); |
|
15
|
|
|
|
|
16
|
|
|
$table->unsignedInteger('revision_id'); |
|
17
|
|
|
$table->foreign('revision_id')->references('id')->on('revisions'); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Run the migrations. |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
|
|
public function up() |
|
26
|
|
|
{ |
|
27
|
|
|
Schema::create( |
|
28
|
|
|
'contents', |
|
29
|
|
|
function (Blueprint $table) { |
|
30
|
|
|
$table->increments('id'); |
|
31
|
|
|
$table->timestamps(); |
|
32
|
|
|
} |
|
33
|
|
|
); |
|
34
|
|
|
|
|
35
|
|
|
Schema::create( |
|
36
|
|
|
'revisions', |
|
37
|
|
|
function (Blueprint $table) { |
|
38
|
|
|
$table->increments('id'); |
|
39
|
|
|
$table->unsignedInteger('language_id'); |
|
40
|
|
|
$table->unsignedInteger('content_id'); |
|
41
|
|
|
$table->timestamps(); |
|
42
|
|
|
|
|
43
|
|
|
$table->foreign('language_id')->references('id')->on('languages'); |
|
44
|
|
|
$table->foreign('content_id')->references('id')->on('contents'); |
|
45
|
|
|
} |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
Schema::create( |
|
49
|
|
|
'field_string', |
|
50
|
|
|
function (Blueprint $table) { |
|
51
|
|
|
$this->fieldTableFields($table); |
|
52
|
|
|
$table->string('value'); |
|
53
|
|
|
} |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
Schema::create( |
|
57
|
|
|
'field_text', |
|
58
|
|
|
function (Blueprint $table) { |
|
59
|
|
|
$this->fieldTableFields($table); |
|
60
|
|
|
$table->text('value'); |
|
61
|
|
|
} |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
|
|
Schema::create( |
|
65
|
|
|
'field_date', |
|
66
|
|
|
function (Blueprint $table) { |
|
67
|
|
|
$this->fieldTableFields($table); |
|
68
|
|
|
$table->date('value'); |
|
69
|
|
|
} |
|
70
|
|
|
); |
|
71
|
|
|
|
|
72
|
|
|
Schema::create( |
|
73
|
|
|
'field_datetime', |
|
74
|
|
|
function (Blueprint $table) { |
|
75
|
|
|
$this->fieldTableFields($table); |
|
76
|
|
|
$table->datetime('value'); |
|
77
|
|
|
} |
|
78
|
|
|
); |
|
79
|
|
|
|
|
80
|
|
|
Schema::create( |
|
81
|
|
|
'field_entity', |
|
82
|
|
|
function (Blueprint $table) { |
|
83
|
|
|
$this->fieldTableFields($table); |
|
84
|
|
|
$table->unsignedInteger('value'); |
|
85
|
|
|
$table->foreign('value')->references('id')->on('contents'); |
|
86
|
|
|
} |
|
87
|
|
|
); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Reverse the migrations. |
|
92
|
|
|
* |
|
93
|
|
|
* @return void |
|
94
|
|
|
*/ |
|
95
|
|
|
public function down() |
|
96
|
|
|
{ |
|
97
|
|
|
Schema::drop('field_string'); |
|
98
|
|
|
Schema::drop('field_text'); |
|
99
|
|
|
Schema::drop('field_date'); |
|
100
|
|
|
Schema::drop('field_datetime'); |
|
101
|
|
|
Schema::drop('field_entity'); |
|
102
|
|
|
Schema::drop('revisions'); |
|
103
|
|
|
Schema::drop('contents'); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|