fix: 🐛 Make migrations be compatible to installed addon

This commit is contained in:
IceToast 2023-05-08 11:10:51 +02:00
parent 5b95dd4d13
commit ae9ab59dec
6 changed files with 17 additions and 37 deletions

View file

@ -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();
});
}
}

View file

@ -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]);
}
}
/**

View file

@ -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();
});
}
}

View file

@ -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();
});

View file

@ -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();
});

View file

@ -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"
}