Files
database-pertani-web/database/migrations/2026_04_27_092224_create_distribution_table.php
2026-06-25 14:50:27 +07:00

42 lines
1.8 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('distribusi', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('petani_id')->nullable();
$table->unsignedBigInteger('panen_id')->nullable();
$table->string('nama_pengirim')->nullable();
$table->unsignedBigInteger('offtaker_id')->nullable();
$table->string('nama_offtaker')->nullable();
$table->string('komoditas_id');
$table->double('berat_kg')->default(0);
$table->string('grade_petani')->nullable();
$table->string('grade_offtaker')->nullable();
$table->text('alasan')->nullable();
$table->double('harga_per_kg')->default(0);
$table->double('total')->default(0);
$table->date('tgl_distribusi')->nullable();
$table->date('tgl_terima')->nullable();
$table->text('catatan')->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');
}
};