]> git.localhorst.tv Git - alttp.git/blobdiff - database/migrations/2022_08_21_130547_create_technique_chapter_table.php
technique chapters
[alttp.git] / database / migrations / 2022_08_21_130547_create_technique_chapter_table.php
diff --git a/database/migrations/2022_08_21_130547_create_technique_chapter_table.php b/database/migrations/2022_08_21_130547_create_technique_chapter_table.php
new file mode 100644 (file)
index 0000000..339ac77
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::table('techniques', function (Blueprint $table) {
+                       $table->string('name')->nullable()->default(null)->change();
+               });
+               Schema::create('technique_chapter', function (Blueprint $table) {
+                       $table->id();
+                       $table->foreignId('parent_id')->references('id')->on('techniques')->constrained();
+                       $table->foreignId('child_id')->references('id')->on('techniques')->constrained();
+                       $table->integer('level')->default(2);
+                       $table->integer('order')->default(0);
+                       $table->timestamps();
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::dropIfExists('technique_chapter');
+       }
+};