1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Illuminate\Support\Facades\Schema; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Migration auto-generated by Sequel Pro Laravel Export (1.5.0). |
9
|
|
|
* |
10
|
|
|
* @see https://github.com/cviebrock/sequel-pro-laravel-export |
11
|
|
|
*/ |
12
|
|
|
class CreateVocabulariesTable extends Migration |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Run the migrations. |
16
|
|
|
* |
17
|
|
|
* @return void |
18
|
|
|
*/ |
19
|
|
|
public function up() |
20
|
|
|
{ |
21
|
|
|
$connection = config('trans-helper.database.connection') ?: config('database.default'); |
22
|
|
|
if (!Schema::connection($connection)->hasTable('_trans_helper_cites')) { |
23
|
|
|
Schema::connection($connection)->create( |
24
|
|
|
'_trans_helper_cites', |
25
|
|
|
function (Blueprint $table) { |
26
|
|
|
$table->bigIncrements('id'); |
27
|
|
|
$table->string('file', 256)->default(''); |
28
|
|
|
$table->unsignedBigInteger('line'); |
29
|
|
|
$table->string('class', 256)->nullable(); |
30
|
|
|
$table->string('function', 256)->nullable(); |
31
|
|
|
$table->mediumText('code')->nullable(); |
32
|
|
|
$table->timestamps(); |
33
|
|
|
|
34
|
|
|
$table->index('created_at', 'created_at'); |
35
|
|
|
$table->index('updated_at', 'updated_at'); |
36
|
|
|
$table->index('function', 'function'); |
37
|
|
|
$table->index('file', 'file'); |
38
|
|
|
$table->index('line', 'line'); |
39
|
|
|
$table->index('class', 'class'); |
40
|
|
|
} |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if (!Schema::connection($connection)->hasTable('_trans_helper_terms')) { |
45
|
|
|
Schema::connection($connection)->create( |
46
|
|
|
'_trans_helper_terms', |
47
|
|
|
function (Blueprint $table) { |
48
|
|
|
$table->bigIncrements('id'); |
49
|
|
|
$table->string('namespace', 256)->default(''); |
50
|
|
|
$table->string('term', 256)->default(''); |
51
|
|
|
$table->json('translation')->nullable(); |
52
|
|
|
$table->timestamps(); |
53
|
|
|
|
54
|
|
|
$table->unique(['namespace', 'term'], 'unique_namespace_term'); |
55
|
|
|
$table->index('namespace', 'namespace'); |
56
|
|
|
$table->index('term', 'term'); |
57
|
|
|
$table->index('created_at', 'created_at'); |
58
|
|
|
$table->index('updated_at', 'updated_at'); |
59
|
|
|
} |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (!Schema::connection($connection)->hasTable('_trans_helper_links')) { |
64
|
|
|
Schema::connection($connection)->create( |
65
|
|
|
'_trans_helper_links', |
66
|
|
|
function (Blueprint $table) { |
67
|
|
|
$table->unsignedBigInteger('cited'); |
68
|
|
|
$table->unsignedBigInteger('vocab'); |
69
|
|
|
|
70
|
|
|
$table->primary(['cited', 'vocab']); |
71
|
|
|
$table->index('cited', 'cited'); |
72
|
|
|
$table->index('vocab', 'vocab'); |
73
|
|
|
$table->foreign('cited') |
74
|
|
|
->references('id') |
75
|
|
|
->on('_trans_helper_cites') |
76
|
|
|
->onDelete('cascade'); |
77
|
|
|
$table->foreign('vocab') |
78
|
|
|
->references('id') |
79
|
|
|
->on('_trans_helper_terms') |
80
|
|
|
->onDelete('cascade'); |
81
|
|
|
} |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Reverse the migrations. |
88
|
|
|
* |
89
|
|
|
* @return void |
90
|
|
|
*/ |
91
|
|
|
public function down() |
92
|
|
|
{ |
93
|
|
|
$connection = config('trans-helper.database.connection') ?: config('database.default'); |
94
|
|
|
Schema::connection($connection)->dropIfExists('_trans_helper_links'); |
95
|
|
|
Schema::connection($connection)->dropIfExists('_trans_helper_cites'); |
96
|
|
|
Schema::connection($connection)->dropIfExists('_trans_helper_terms'); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|