This commit is contained in:
2026-04-29 16:02:31 +07:00
22 changed files with 1583 additions and 9403 deletions
@@ -0,0 +1,33 @@
<?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('map_panen', function (Blueprint $table) {
$table->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');
}
};
@@ -0,0 +1,41 @@
<?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');
}
};
@@ -0,0 +1,37 @@
<?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('tanaman_inspeksi', function (Blueprint $table) {
$table->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');
}
};
@@ -0,0 +1,33 @@
<?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('inspeksi_lahan', function (Blueprint $table) {
$table->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');
}
};
@@ -0,0 +1,32 @@
<?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('facilitator', function (Blueprint $table) {
$table->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');
}
};
@@ -0,0 +1,33 @@
<?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('offtakers', function (Blueprint $table) {
$table->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');
}
};