فهرست منبع

fix: 🐛 Make migrations be compatible to installed addon

IceToast 2 سال پیش
والد
کامیت
ae9ab59dec

+ 0 - 32
database/migrations/2022_07_21_234818_undo_decimal_in_price.php

@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class UndoDecimalInPrice extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('products', function (Blueprint $table) {
-            $table->decimal('price', 15, 4)->change();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('products', function (Blueprint $table) {
-            $table->decimal('price',['11','2'])->change();
-        });
-    }
-}

+ 6 - 2
database/migrations/2022_06_16_092704_add_billing_period_to_products.php → database/migrations/2023_05_08_092704_add_billing_period_to_products.php

@@ -14,11 +14,16 @@ class AddBillingPeriodToProducts extends Migration
      */
     public function up()
     {
+        // User already has installed the addon before
+        if (Schema::hasColumn("products", "billing_period")) {
+            return;
+        }
+
         Schema::table('products', function (Blueprint $table) {
+
             $table->string('billing_period')->default("hourly");
             $table->decimal('price', 15, 4)->change();
             $table->decimal('minimum_credits', 15, 4)->change();
-
         });
 
         DB::statement('UPDATE products SET billing_period="hourly"');
@@ -29,7 +34,6 @@ class AddBillingPeriodToProducts extends Migration
             $price = $price / 30 / 24;
             DB::table('products')->where('id', $product->id)->update(['price' => $price]);
         }
-
     }
 
     /**

+ 1 - 2
database/migrations/2022_06_16_094402_update_user_credits_datatype.php → database/migrations/2023_05_08_094402_update_user_credits_datatype.php

@@ -26,8 +26,7 @@ class UpdateUserCreditsDatatype extends Migration
     public function down()
     {
         Schema::table('users', function (Blueprint $table) {
-            $table->unsignedFloat('credits')->default(250)->change();
-
+            $table->decimal('price', ['11', '2'])->change();
         });
     }
 }

+ 5 - 0
database/migrations/2022_06_16_095818_add_last_billed_field_to_servers.php → database/migrations/2023_05_08_095818_add_last_billed_field_to_servers.php

@@ -14,6 +14,11 @@ class AddLastBilledFieldToServers extends Migration
      */
     public function up()
     {
+        // User already has installed the addon before
+        if (Schema::hasColumn("servers", "last_billed")) {
+            return;
+        }
+
         Schema::table('servers', function (Blueprint $table) {
             $table->dateTime('last_billed')->default(DB::raw('CURRENT_TIMESTAMP'))->nullable();
         });

+ 5 - 0
database/migrations/2022_07_21_234527_add_cancelation_to_servers_table.php → database/migrations/2023_05_08_234527_add_cancelation_to_servers_table.php

@@ -13,6 +13,11 @@ class AddCancelationToServersTable extends Migration
      */
     public function up()
     {
+        // User already has installed the addon before
+        if (Schema::hasColumn("servers", "cancelled")) {
+            return;
+        }
+
         Schema::table('servers', function (Blueprint $table) {
             $table->dateTime('cancelled')->nullable();
         });

+ 0 - 1
lang/en.json

@@ -600,5 +600,4 @@
     "Billing period": "Billing period",
     "Upgrading/Downgrading your server will reset your billing cycle to now. Your overpayed Credits will be refunded. The price for the new billing cycle will be withdrawed": "Upgrading/Downgrading your server will reset your billing cycle to now. Your overpayed Credits will be refunded. The price for the new billing cycle will be withdrawed",
     "Caution": "Caution"
-    "hu": "Hungarian"
 }