fix wallet
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (!Schema::hasTable('products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('products', 'show_in_assets')) {
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('products', 'show')) {
|
||||
$table->boolean('show_in_assets')->default(false)->after('show');
|
||||
} else {
|
||||
$table->boolean('show_in_assets')->default(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DB::statement(
|
||||
'ALTER TABLE `products` MODIFY COLUMN `show_in_assets` TINYINT(1) NOT NULL DEFAULT 0'
|
||||
);
|
||||
DB::table('products')->update(['show_in_assets' => 0]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (!Schema::hasTable('products') || !Schema::hasColumn('products', 'show_in_assets')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('show_in_assets');
|
||||
});
|
||||
}
|
||||
};
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (!Schema::hasTable('products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('products', 'use_last_price_if_zero')) {
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('products', 'show_in_assets')) {
|
||||
$table->boolean('use_last_price_if_zero')->default(false)->after('show_in_assets');
|
||||
} else {
|
||||
$table->boolean('use_last_price_if_zero')->default(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (!Schema::hasTable('products') || !Schema::hasColumn('products', 'use_last_price_if_zero')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('use_last_price_if_zero');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user