39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?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
|
|
{
|
|
Schema::table('invoices', function (Blueprint $table) {
|
|
if (!Schema::hasColumn('invoices', 'discount_rate')) {
|
|
$table->integer('discount_rate')->default(0);
|
|
}
|
|
});
|
|
|
|
Schema::table('invoice_items', function (Blueprint $table) {
|
|
if (!Schema::hasColumn('invoice_items', 'is_discountable')) {
|
|
$table->boolean('is_discountable')->default(true);
|
|
}
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('invoices', function (Blueprint $table) {
|
|
if (Schema::hasColumn('invoices', 'discount_rate')) {
|
|
$table->dropColumn('discount_rate');
|
|
}
|
|
});
|
|
|
|
Schema::table('invoice_items', function (Blueprint $table) {
|
|
if (Schema::hasColumn('invoice_items', 'is_discountable')) {
|
|
$table->dropColumn('is_discountable');
|
|
}
|
|
});
|
|
}
|
|
};
|