Преглед изворни кода

fix: 🗃️ settings table migration order

IceToast пре 2 година
родитељ
комит
f2a714cece

+ 0 - 22
database/migrations/2023_02_01_155140_rename_settings_table.php

@@ -1,22 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-return new class extends Migration
-{
-    public function up()
-    {
-        Schema::table('settings', function (Blueprint $table) {
-            $table->rename('settings_old');
-        });
-    }
-
-    public function down()
-    {
-        Schema::table('settings_old', function (Blueprint $table) {
-            $table->rename("settings");
-        });
-    }
-};

+ 10 - 0
database/migrations/2023_02_01_155730_create_new_settings_table.php

@@ -13,6 +13,12 @@ return new class extends Migration
      */
     public function up()
     {
+        // rename old settings table
+        Schema::table('settings', function (Blueprint $table) {
+            $table->rename('settings_old');
+        });
+
+        // create new settings table
         Schema::create('settings', function (Blueprint $table) {
             $table->id();
             $table->string('name');
@@ -31,5 +37,9 @@ return new class extends Migration
     public function down()
     {
         Schema::dropIfExists('settings');
+
+        Schema::table('settings_old', function (Blueprint $table) {
+            $table->rename("settings");
+        });
     }
 };

+ 2 - 2
database/migrations/2023_02_13_150022_delete_old_settings_table.php

@@ -24,10 +24,10 @@ return new class extends Migration
     public function down()
     {
         Schema::create('settings_old', function (Blueprint $table) {
-            $table->string('key', 191);
+            $table->string('key', 191)->primary();
             $table->text('value')->nullable();
             $table->string('type');
-            $table->longText('description');
+            $table->longText('description')->nullable();
             $table->timestamps();
         });
     }