1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\Facades\Schema; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Uccello\Core\Database\Migrations\Migration; |
6
|
|
|
|
7
|
|
|
class CreateRelatedlistsTable extends Migration |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
Schema::create($this->tablePrefix.'relatedlists', function(Blueprint $table) { |
17
|
|
|
$table->increments('id'); |
18
|
|
|
$table->unsignedInteger('module_id'); |
19
|
|
|
$table->unsignedInteger('related_module_id'); |
20
|
|
|
$table->unsignedInteger('tab_id')->nullable(); |
21
|
|
|
$table->unsignedInteger('related_field_id')->nullable(); |
22
|
|
|
$table->string('label'); |
23
|
|
|
$table->string('icon')->nullable(); |
24
|
|
|
$table->enum('type', [ 'n-1', 'n-n' ]); |
25
|
|
|
$table->string('method'); |
26
|
|
|
$table->unsignedInteger('sequence'); |
27
|
|
|
$table->text('data')->nullable(); |
28
|
|
|
$table->timestamps(); |
29
|
|
|
|
30
|
|
|
// Foreign keys |
31
|
|
|
$table->foreign('module_id') |
32
|
|
|
->references('id')->on($this->tablePrefix.'modules') |
33
|
|
|
->onDelete('cascade'); |
34
|
|
|
|
35
|
|
|
$table->foreign('related_module_id') |
36
|
|
|
->references('id')->on($this->tablePrefix.'modules') |
37
|
|
|
->onDelete('cascade'); |
38
|
|
|
|
39
|
|
|
$table->foreign('tab_id') |
40
|
|
|
->references('id')->on($this->tablePrefix.'tabs') |
41
|
|
|
->onDelete('cascade'); |
42
|
|
|
|
43
|
|
|
$table->foreign('related_field_id') |
44
|
|
|
->references('id')->on($this->tablePrefix.'fields') |
45
|
|
|
->onDelete('cascade'); |
46
|
|
|
|
47
|
|
|
// Unique keys |
48
|
|
|
$table->unique([ 'module_id', 'related_module_id', 'label' ], 'relatedlists_unique_key'); |
49
|
|
|
}); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Reverse the migrations. |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function down() |
58
|
|
|
{ |
59
|
|
|
Schema::dropIfExists($this->tablePrefix.'relatedlists'); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|