1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
|
6
|
|
|
class CreateTables extends Migration |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* Run the migrations. |
10
|
|
|
*/ |
11
|
|
|
public function up() |
12
|
|
|
{ |
13
|
|
|
Schema::create('countries', function (Blueprint $table) { |
14
|
|
|
$table->increments('id'); |
15
|
|
|
$table->string('code'); |
16
|
|
|
$table->timestamps(); |
17
|
|
|
$table->softDeletes(); |
18
|
|
|
}); |
19
|
|
|
|
20
|
|
View Code Duplication |
Schema::create('country_translations', function (Blueprint $table) { |
|
|
|
|
21
|
|
|
$table->increments('id'); |
22
|
|
|
$table->integer('country_id')->unsigned(); |
23
|
|
|
$table->string('name'); |
24
|
|
|
$table->string('locale')->index(); |
25
|
|
|
|
26
|
|
|
$table->unique(['country_id', 'locale']); |
27
|
|
|
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade'); |
28
|
|
|
}); |
29
|
|
|
|
30
|
|
|
Schema::create('cities', function (Blueprint $table) { |
31
|
|
|
$table->increments('id'); |
32
|
|
|
$table->integer('country_id')->unsigned(); |
33
|
|
|
$table->timestamps(); |
34
|
|
|
|
35
|
|
|
$table->foreign('country_id')->references('id')->on('countries'); |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
View Code Duplication |
Schema::create('city_translations', function (Blueprint $table) { |
|
|
|
|
39
|
|
|
$table->increments('id'); |
40
|
|
|
$table->integer('city_id')->unsigned(); |
41
|
|
|
$table->string('name'); |
42
|
|
|
$table->string('locale')->index(); |
43
|
|
|
|
44
|
|
|
$table->unique(['city_id', 'locale']); |
45
|
|
|
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade'); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
Schema::create('companies', function (Blueprint $table) { |
49
|
|
|
$table->increments('id'); |
50
|
|
|
$table->string('name')->nullable(); |
51
|
|
|
$table->timestamps(); |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
Schema::create('continents', function (Blueprint $table) { |
55
|
|
|
$table->increments('id'); |
56
|
|
|
$table->timestamps(); |
57
|
|
|
}); |
58
|
|
|
|
59
|
|
|
Schema::create('foods', function (Blueprint $table) { |
60
|
|
|
$table->increments('id'); |
61
|
|
|
$table->timestamps(); |
62
|
|
|
}); |
63
|
|
|
|
64
|
|
View Code Duplication |
Schema::create('food_translations', function (Blueprint $table) { |
|
|
|
|
65
|
|
|
$table->increments('id'); |
66
|
|
|
$table->integer('food_id')->unsigned(); |
67
|
|
|
$table->string('name'); |
68
|
|
|
$table->string('locale')->index(); |
69
|
|
|
|
70
|
|
|
$table->unique(['food_id', 'locale']); |
71
|
|
|
$table->foreign('food_id')->references('id')->on('foods')->onDelete('cascade'); |
72
|
|
|
}); |
73
|
|
|
|
74
|
|
|
Schema::create('continent_translations', function (Blueprint $table) { |
75
|
|
|
$table->increments('id'); |
76
|
|
|
$table->integer('continent_id')->unsigned(); |
77
|
|
|
$table->string('name'); |
78
|
|
|
$table->string('locale')->index(); |
79
|
|
|
$table->timestamps(); |
80
|
|
|
}); |
81
|
|
|
|
82
|
|
|
Schema::create('vegetables', function (Blueprint $table) { |
83
|
|
|
$table->increments('identity'); |
84
|
|
|
$table->timestamps(); |
85
|
|
|
}); |
86
|
|
|
|
87
|
|
View Code Duplication |
Schema::create('vegetable_translations', function (Blueprint $table) { |
|
|
|
|
88
|
|
|
$table->increments('id'); |
89
|
|
|
$table->integer('vegetable_identity')->unsigned(); |
90
|
|
|
$table->string('name'); |
91
|
|
|
$table->string('locale')->index(); |
92
|
|
|
|
93
|
|
|
$table->unique(['vegetable_identity', 'locale']); |
94
|
|
|
$table->foreign('vegetable_identity')->references('identity')->on('vegetables')->onDelete('cascade'); |
95
|
|
|
}); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Reverse the migrations. |
100
|
|
|
*/ |
101
|
|
|
public function down() |
102
|
|
|
{ |
103
|
|
|
Schema::dropIfExists('city_translations'); |
104
|
|
|
Schema::dropIfExists('cities'); |
105
|
|
|
|
106
|
|
|
Schema::dropIfExists('country_translations'); |
107
|
|
|
Schema::dropIfExists('countries'); |
108
|
|
|
|
109
|
|
|
Schema::dropIfExists('companies'); |
110
|
|
|
|
111
|
|
|
Schema::dropIfExists('continent_translations'); |
112
|
|
|
Schema::dropIfExists('continents'); |
113
|
|
|
Schema::dropIfExists('food_translations'); |
114
|
|
|
Schema::dropIfExists('foods'); |
115
|
|
|
Schema::dropIfExists('vegetable_translations'); |
116
|
|
|
Schema::dropIfExists('vegetables'); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.