41 lines
1.7 KiB
PHP
41 lines
1.7 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::create('distributions', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('farmer_id')->nullable();
|
|
$table->string('farmer_name')->nullable();
|
|
$table->unsignedBigInteger('offtaker_id')->nullable();
|
|
$table->string('offtaker_name')->nullable();
|
|
$table->string('commodity_name');
|
|
$table->double('quantity_kg')->default(0);
|
|
$table->string('farmer_grade')->nullable();
|
|
$table->string('offtaker_grade')->nullable();
|
|
$table->text('grade_difference_reason')->nullable();
|
|
$table->double('price_per_kg')->default(0);
|
|
$table->double('total_value')->default(0);
|
|
$table->date('distribution_date')->nullable();
|
|
$table->date('received_date')->nullable();
|
|
$table->text('notes')->nullable();
|
|
$table->string('status')->nullable();
|
|
$table->string('sync_status')->default('pending');
|
|
|
|
// Audit Columns
|
|
$table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
|
|
$table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null');
|
|
$table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null');
|
|
|
|
$table->timestamps(); // create_date & updated_date ditangani via timestamps
|
|
$table->softDeletes();
|
|
});
|
|
}
|
|
|
|
public function down(): void {
|
|
Schema::dropIfExists('distributions');
|
|
}
|
|
}; |