From 2c6b210f674e3bcd4c51a63d2a721dd2ab86e9d1 Mon Sep 17 00:00:00 2001 From: "fauzgabriel@gmail.com" Date: Wed, 29 Apr 2026 15:06:49 +0700 Subject: [PATCH] migrations --- .../2026_04_27_092223_create_panen_table.php | 33 +++++++++++++++ ...04_27_092224_create_distribution_table.php | 41 +++++++++++++++++++ ...6_04_27_092225_create_inspection_table.php | 37 +++++++++++++++++ ...026_04_27_092226_create_inslahan_table.php | 33 +++++++++++++++ .../2026_04_27_092227_create_facilitator.php | 32 +++++++++++++++ .../2026_04_27_092228_create_offtaker.php | 33 +++++++++++++++ 6 files changed, 209 insertions(+) create mode 100644 database/migrations/2026_04_27_092223_create_panen_table.php create mode 100644 database/migrations/2026_04_27_092224_create_distribution_table.php create mode 100644 database/migrations/2026_04_27_092225_create_inspection_table.php create mode 100644 database/migrations/2026_04_27_092226_create_inslahan_table.php create mode 100644 database/migrations/2026_04_27_092227_create_facilitator.php create mode 100644 database/migrations/2026_04_27_092228_create_offtaker.php diff --git a/database/migrations/2026_04_27_092223_create_panen_table.php b/database/migrations/2026_04_27_092223_create_panen_table.php new file mode 100644 index 0000000..e03ded3 --- /dev/null +++ b/database/migrations/2026_04_27_092223_create_panen_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('land_id')->nullable(); + $table->unsignedBigInteger('plant_id')->nullable(); + $table->unsignedBigInteger('farmer_id')->nullable(); + $table->string('commodity_name'); + $table->double('weight_kg')->default(0); + $table->date('harvest_date'); + $table->text('notes')->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(); + $table->softDeletes(); + }); + } + + public function down(): void { + Schema::dropIfExists('map_panen'); + } +}; \ No newline at end of file diff --git a/database/migrations/2026_04_27_092224_create_distribution_table.php b/database/migrations/2026_04_27_092224_create_distribution_table.php new file mode 100644 index 0000000..7d365db --- /dev/null +++ b/database/migrations/2026_04_27_092224_create_distribution_table.php @@ -0,0 +1,41 @@ +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'); + } +}; \ No newline at end of file diff --git a/database/migrations/2026_04_27_092225_create_inspection_table.php b/database/migrations/2026_04_27_092225_create_inspection_table.php new file mode 100644 index 0000000..794e60e --- /dev/null +++ b/database/migrations/2026_04_27_092225_create_inspection_table.php @@ -0,0 +1,37 @@ +id(); + $table->unsignedBigInteger('tanaman_id')->nullable(); + $table->unsignedBigInteger('lahan_id')->nullable(); + $table->unsignedBigInteger('petani_id')->nullable(); + $table->date('inspection_date')->nullable(); + $table->string('health_status')->nullable(); + $table->string('productivity_status')->nullable(); + $table->string('issue_type')->nullable(); + $table->text('issue_description')->nullable(); + $table->text('recommendation')->nullable(); + $table->text('notes')->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->timestamp('created_date')->useCurrent(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + public function down(): void { + Schema::dropIfExists('tanaman_inspeksi'); + } +}; \ No newline at end of file diff --git a/database/migrations/2026_04_27_092226_create_inslahan_table.php b/database/migrations/2026_04_27_092226_create_inslahan_table.php new file mode 100644 index 0000000..ef66514 --- /dev/null +++ b/database/migrations/2026_04_27_092226_create_inslahan_table.php @@ -0,0 +1,33 @@ +id(); + $table->foreignId('petani_id')->nullable()->constrained('users')->onDelete('set null'); + $table->unsignedBigInteger('lahan_id')->nullable(); + $table->double('kadar_air')->nullable(); + $table->double('ph')->nullable(); + $table->double('kelembapan')->nullable(); + $table->double('temperatur')->nullable(); + $table->string('kondisi_tanaman')->nullable(); + $table->text('catatan')->nullable(); + $table->string('foto_url')->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->timestamps(); + }); + } + + public function down(): void { + Schema::dropIfExists('inspeksi_lahan'); + } +}; \ No newline at end of file diff --git a/database/migrations/2026_04_27_092227_create_facilitator.php b/database/migrations/2026_04_27_092227_create_facilitator.php new file mode 100644 index 0000000..70f6475 --- /dev/null +++ b/database/migrations/2026_04_27_092227_create_facilitator.php @@ -0,0 +1,32 @@ +uuid('id')->primary(); + $table->string('user_email')->unique(); + $table->string('full_name'); + $table->string('role')->nullable(); + $table->string('village')->nullable(); + $table->string('district')->nullable(); + $table->string('regency')->nullable(); + $table->string('province')->nullable(); + $table->string('phone')->nullable(); + $table->boolean('is_active')->default(true); + + // Audit Columns + $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null'); + + $table->timestamp('created_date')->nullable(); // Sesuai konstanta CREATED_AT di model + }); + } + + public function down(): void { + Schema::dropIfExists('facilitator'); + } +}; \ No newline at end of file diff --git a/database/migrations/2026_04_27_092228_create_offtaker.php b/database/migrations/2026_04_27_092228_create_offtaker.php new file mode 100644 index 0000000..771f478 --- /dev/null +++ b/database/migrations/2026_04_27_092228_create_offtaker.php @@ -0,0 +1,33 @@ +id(); + $table->string('user_email')->unique(); + $table->string('company_name'); + $table->string('contact_name')->nullable(); + $table->string('phone')->nullable(); + $table->text('address')->nullable(); + $table->boolean('is_active')->default(true); + $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->timestamp('created_date')->useCurrent(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + public function down(): void { + Schema::dropIfExists('offtakers'); + } +}; \ No newline at end of file