refactor: standardize migration schema structures and remove redundant approval and status modifications
This commit is contained in:
parent
4a13297cb7
commit
bc365ebb4d
@ -14,6 +14,93 @@ ### Traits
|
||||
use FlashesEntityMessage, ParsesDataTableQuery;
|
||||
```
|
||||
|
||||
## Database & Migrasi
|
||||
|
||||
### Struktur File Migrasi
|
||||
- Gunakan *anonymous class* yang meng-extend `Migration`.
|
||||
- Tulis *return type hint* `: void` secara eksplisit pada method `up()` dan `down()`.
|
||||
- **Urutan & Pengelompokan Kolom (Ordering & Grouping):**
|
||||
1. **Primary Key**: `$table->id()` ditaruh paling atas.
|
||||
2. **Relasi (Foreign Keys / Morphs)**: Ditaruh tepat setelah Primary Key di bagian teratas.
|
||||
3. **Kolom Data Utama**: Dikelompokkan secara logis menggunakan spasi (baris kosong) sebagai pemisah antar kelompok data.
|
||||
4. **Timestamps & Soft Deletes**: Ditaruh paling bawah.
|
||||
- **Gunakan:**
|
||||
```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::create('table_name', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
|
||||
|
||||
$table->string('name', 100);
|
||||
$table->string('description', 255)->nullable();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('table_name');
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### Definisi Kolom & Tipe Data
|
||||
- **ID & Timestamps:**
|
||||
- Gunakan `$table->id()` sebagai primary key.
|
||||
- Gunakan `timestamp` eksplisit dengan default `useCurrent()` dan `useCurrentOnUpdate()`. **Hindari penggunaan `$table->timestamps()` bawaan Laravel agar format kolom presisi dan konsisten.**
|
||||
- Tambahkan `$table->softDeletes()` (atau `deleted_at`) jika model terkait menggunakan trait `SoftDeletes`.
|
||||
```php
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
```
|
||||
- **Kolom Enum:**
|
||||
- Hubungkan dengan PHP Backed Enum menggunakan `array_column(EnumName::cases(), 'value')`.
|
||||
- **Contoh:**
|
||||
```php
|
||||
$table->enum('status', array_column(StatusEnum::cases(), 'value'))->default(StatusEnum::PENDING->value);
|
||||
```
|
||||
|
||||
### Relasi & Foreign Key
|
||||
- Gunakan `$table->foreignId()`.
|
||||
- Tentukan constraint relasi secara eksplisit dengan `constrained()` (dan sebutkan nama tabel target jika nama kolom tidak sesuai dengan nama tabel, misal: `constrained('users')`).
|
||||
- Tentukan aksi penghapusan secara eksplisit (`cascadeOnDelete()`, `nullOnDelete()`, atau `restrictOnDelete()`) sesuai kebutuhan integritas data.
|
||||
- **Contoh:**
|
||||
```php
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('category_id')->nullable()->constrained('categories')->nullOnDelete();
|
||||
```
|
||||
|
||||
### Modifikasi Tabel (Alter Schema)
|
||||
- Saat menambahkan kolom baru, gunakan modifier `->after('column_name')` agar tata letak kolom di database terstruktur dengan logis.
|
||||
- Jika menambahkan kolom baru yang non-nullable pada tabel yang sudah berisi data, jalankan data migration di dalam method `up()` setelah schema builder:
|
||||
```php
|
||||
DB::table('table_name')->update(['column_name' => 'default_value']);
|
||||
```
|
||||
- Di dalam method `down()`, pastikan untuk melepas constraint foreign key terlebih dahulu sebelum menghapus kolom bersangkutan. Gunakan `dropConstrainedForeignId` atau `dropForeign` untuk cara yang aman dan ringkas.
|
||||
- **Gunakan:**
|
||||
```php
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('table_name', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('foreign_key_id');
|
||||
$table->dropColumn(['column_one', 'column_two']);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## JavaScript / Vue
|
||||
|
||||
### Struktur Folder Page-Specific Components
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('id', true);
|
||||
$table->id();
|
||||
|
||||
$table->string('email', 100)->unique();
|
||||
$table->string('username', 20)->unique();
|
||||
|
||||
@ -14,8 +14,8 @@ public function up(): void
|
||||
|
||||
$table->foreignId('cash_account_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->nullableMorphs('reference');
|
||||
|
||||
$table->unsignedBigInteger('amount');
|
||||
$table->unsignedBigInteger('balance_after');
|
||||
$table->enum('type', array_column(CashTransactionType::cases(), 'value'))->default(CashTransactionType::DEPOSIT->value);
|
||||
|
||||
@ -11,22 +11,24 @@ public function up(): void
|
||||
{
|
||||
Schema::create('employee_advances', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('paid_by_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||
$table->foreignId('employee_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('verified_by_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||
$table->foreignId('repayment_cash_transaction_id')->nullable()->unique()->constrained('cash_transactions')->restrictOnDelete();
|
||||
$table->foreignId('cash_transaction_id')->nullable()->unique()->constrained()->restrictOnDelete();
|
||||
|
||||
$table->unsignedBigInteger('amount');
|
||||
$table->string('description', 100);
|
||||
$table->date('due_date');
|
||||
$table->enum('status', array_column(EmployeeAdvanceStatus::cases(), 'value'))
|
||||
->default(EmployeeAdvanceStatus::PENDING->value);
|
||||
$table->foreignId('cash_transaction_id')->nullable()->unique()->constrained()->restrictOnDelete();
|
||||
$table->foreignId('repayment_cash_transaction_id')->nullable()->unique()->constrained('cash_transactions')->restrictOnDelete();
|
||||
$table->timestamp('verified_at')->nullable();
|
||||
$table->foreignId('verified_by_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||
$table->timestamp('paid_at')->nullable();
|
||||
$table->foreignId('paid_by_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['employee_id', 'status']);
|
||||
$table->index(['status', 'created_at']);
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -12,11 +12,10 @@ public function up(): void
|
||||
$table->id();
|
||||
|
||||
$table->nullableMorphs('rejectable');
|
||||
$table->foreignId('rejected_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->string('reason', 500);
|
||||
|
||||
$table->foreignId('rejected_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -12,13 +12,13 @@ public function up(): void
|
||||
Schema::create('payroll_periods', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('closed_by_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->unsignedSmallInteger('year');
|
||||
$table->unsignedTinyInteger('month');
|
||||
$table->enum('status', array_column(PayrollPeriodStatus::cases(), 'value'))->default(PayrollPeriodStatus::OPEN->value);
|
||||
$table->timestamp('closed_at')->nullable();
|
||||
|
||||
$table->foreignId('closed_by_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -15,6 +15,7 @@ public function up(): void
|
||||
$table->foreignId('payroll_period_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('employee_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('cash_transaction_id')->nullable()->unique()->constrained()->restrictOnDelete();
|
||||
$table->foreignId('paid_by_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->unsignedInteger('base_salary');
|
||||
$table->unsignedBigInteger('bonus_amount')->default(0);
|
||||
@ -23,8 +24,6 @@ public function up(): void
|
||||
$table->enum('status', array_column(PayrollStatus::cases(), 'value'))->default(PayrollStatus::UNPAID->value);
|
||||
$table->timestamp('paid_at')->nullable();
|
||||
|
||||
$table->foreignId('paid_by_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -11,14 +11,15 @@ public function up(): void
|
||||
{
|
||||
Schema::create('payroll_adjustments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('payroll_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('attendance_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->enum('type', array_column(PayrollAdjustmentType::cases(), 'value'));
|
||||
$table->unsignedBigInteger('amount');
|
||||
$table->string('description', 100);
|
||||
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -13,6 +13,7 @@ public function up(): void
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('employee_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('verified_by_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
@ -20,8 +21,6 @@ public function up(): void
|
||||
$table->enum('status', array_column(LeaveRequestStatus::cases(), 'value'))->default(LeaveRequestStatus::PENDING->value);
|
||||
$table->timestamp('verified_at')->nullable();
|
||||
|
||||
$table->foreignId('verified_by_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -17,6 +17,8 @@ public function up(): void
|
||||
|
||||
$table->foreignId('customer_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('marketing_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('cash_transaction_id')->nullable()->unique()->constrained()->restrictOnDelete();
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->string('order_number', 30)->unique();
|
||||
$table->enum('channel', array_column(OrderChannel::cases(), 'value'));
|
||||
@ -33,10 +35,6 @@ public function up(): void
|
||||
$table->unsignedBigInteger('total_amount');
|
||||
$table->text('notes')->nullable();
|
||||
|
||||
$table->foreignId('cash_transaction_id')->nullable()->unique()->constrained()->restrictOnDelete();
|
||||
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -13,6 +13,9 @@ public function up(): void
|
||||
Schema::create('cuttings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
$table->foreignId('submitted_by_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->enum('status', array_column(CuttingStatus::cases(), 'value'))->default(CuttingStatus::IN_PROGRESS->value);
|
||||
$table->string('description', 100)->nullable();
|
||||
|
||||
@ -21,8 +24,6 @@ public function up(): void
|
||||
$table->unsignedBigInteger('other_cost')->default(0);
|
||||
$table->unsignedBigInteger('cost_per_unit')->nullable();
|
||||
|
||||
$table->foreignId('created_by_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
|
||||
@ -11,7 +11,8 @@ public function up(): void
|
||||
Schema::create('cutting_materials', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('cutting_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('cutting_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('raw_material_price_id')->constrained()->restrictOnDelete();
|
||||
|
||||
$table->decimal('material_usage', 18, 2);
|
||||
|
||||
@ -11,7 +11,8 @@ public function up(): void
|
||||
Schema::create('cutting_results', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('cutting_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('cutting_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('product_variant_id')->constrained()->restrictOnDelete();
|
||||
|
||||
$table->unsignedInteger('cutting_result');
|
||||
|
||||
@ -1,23 +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(): void
|
||||
{
|
||||
Schema::table('payroll_adjustments', function (Blueprint $table): void {
|
||||
$table->foreignId('attendance_id')->nullable()->after('payroll_id')->constrained()->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('payroll_adjustments', function (Blueprint $table): void {
|
||||
$table->dropForeign(['attendance_id']);
|
||||
$table->dropColumn('attendance_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1,35 +0,0 @@
|
||||
<?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
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->string('status', 20)->default('pending')->after('is_active');
|
||||
$table->string('pending_action', 20)->nullable()->after('status');
|
||||
$table->boolean('was_ever_approved')->default(false)->after('pending_action');
|
||||
$table->timestamp('verified_at')->nullable()->after('was_ever_approved');
|
||||
$table->foreignId('verified_by_id')->nullable()->after('verified_at')->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('submitted_by_id')->nullable()->after('verified_by_id')->constrained('users')->nullOnDelete();
|
||||
});
|
||||
|
||||
DB::table('products')->update([
|
||||
'status' => 'approved',
|
||||
'was_ever_approved' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('submitted_by_id');
|
||||
$table->dropConstrainedForeignId('verified_by_id');
|
||||
$table->dropColumn(['status', 'pending_action', 'was_ever_approved', 'verified_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -10,7 +10,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('homepage_configurations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,36 +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(): void
|
||||
{
|
||||
Schema::table('cutting_materials', function (Blueprint $table): void {
|
||||
$table->foreignId('cutting_id')->nullable()->change();
|
||||
$table->foreignId('user_id')->nullable()->after('id')->constrained()->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('cutting_results', function (Blueprint $table): void {
|
||||
$table->foreignId('cutting_id')->nullable()->change();
|
||||
$table->foreignId('user_id')->nullable()->after('id')->constrained()->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('cutting_materials', function (Blueprint $table): void {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropColumn('user_id');
|
||||
$table->foreignId('cutting_id')->nullable(false)->change();
|
||||
});
|
||||
|
||||
Schema::table('cutting_results', function (Blueprint $table): void {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropColumn('user_id');
|
||||
$table->foreignId('cutting_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1,29 +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(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('submitted_by_id');
|
||||
$table->dropConstrainedForeignId('verified_by_id');
|
||||
$table->dropColumn(['status', 'pending_action', 'was_ever_approved', 'verified_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->string('status', 20)->default('pending')->after('is_active');
|
||||
$table->string('pending_action', 20)->nullable()->after('status');
|
||||
$table->boolean('was_ever_approved')->default(false)->after('pending_action');
|
||||
$table->timestamp('verified_at')->nullable()->after('was_ever_approved');
|
||||
$table->foreignId('verified_by_id')->nullable()->after('verified_at')->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('submitted_by_id')->nullable()->after('verified_by_id')->constrained('users')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE cutting_result_prices MODIFY COLUMN price_type ENUM('distributor', 'agent', 'sub_agent', 'grosir', 'ecer', 'tiktok', 'shopee', 'harga_modal') NOT NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE cutting_result_prices MODIFY COLUMN price_type ENUM('distributor', 'agent', 'sub_agent', 'grosir', 'ecer', 'tiktok', 'shopee') NOT NULL");
|
||||
}
|
||||
};
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE orders MODIFY COLUMN price_type ENUM('distributor', 'agent', 'sub_agent', 'grosir', 'ecer', 'tiktok', 'shopee', 'harga_modal') NOT NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE orders MODIFY COLUMN price_type ENUM('distributor', 'agent', 'sub_agent', 'grosir', 'ecer', 'tiktok', 'shopee') NOT NULL");
|
||||
}
|
||||
};
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE product_prices MODIFY COLUMN type ENUM('distributor', 'agent', 'sub_agent', 'grosir', 'ecer', 'tiktok', 'shopee', 'harga_modal') NOT NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE product_prices MODIFY COLUMN type ENUM('distributor', 'agent', 'sub_agent', 'grosir', 'ecer', 'tiktok', 'shopee') NOT NULL");
|
||||
}
|
||||
};
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE cuttings MODIFY COLUMN status ENUM('in_progress', 'completed', 'pending_verification', 'verified', 'rejected') NOT NULL DEFAULT 'in_progress'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE cuttings MODIFY COLUMN status ENUM('in_progress', 'completed', 'verified', 'rejected') NOT NULL DEFAULT 'in_progress'");
|
||||
}
|
||||
};
|
||||
@ -1,26 +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(): void
|
||||
{
|
||||
Schema::table('cuttings', function (Blueprint $table) {
|
||||
$table->foreignId('submitted_by_id')
|
||||
->nullable()
|
||||
->after('created_by_id')
|
||||
->constrained('users')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('cuttings', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('submitted_by_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user