File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare(strict_types=1);
4
+
5
+ use Illuminate\Database\Migrations\Migration;
6
+ use Illuminate\Database\Schema\Blueprint;
7
+ use Illuminate\Support\Facades\Schema;
8
+
9
+ return new class extends Migration
10
+ {
11
+ /**
12
+ * Run the migrations.
13
+ */
14
+ public function up(): void
15
+ {
16
+ Schema::create('news_categories', function (Blueprint $table) {
17
+ $table->increments('id');
18
+
19
+ $table->string('title')->default('');
20
+ $table->integer('parent_id')->default(-1);
21
+ $table->integer('weight')->default(0);
22
+ $table->softDeletes();
23
+
24
+ $table->index(['weight'], 'idx_weight');
25
+ $table->timestamps();
26
+ });
27
+
28
+ Schema::create('pivot_news_categories', function (Blueprint $table) {
29
+ $table->increments('id');
30
+ $table->unsignedInteger('news_id');
31
+ $table->unsignedInteger('category_id');
32
+
33
+ $table->index('news_id');
34
+ $table->index('category_id');
35
+ $table->unique(['news_id', 'category_id']);
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Reverse the migrations.
41
+ */
42
+ public function down(): void
43
+ {
44
+ Schema::dropIfExists('news_categories');
45
+ Schema::dropIfExists('pivot_news_categories');
46
+ }
47
+ };
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ protected function getMigrations(): array
146
146
{
147
147
return [
148
148
'create_news_table ' ,
149
+ 'create_news_categories_table ' ,
149
150
];
150
151
}
151
152
}
You can’t perform that action at this time.
0 commit comments