From 8710176b2cc5c332ede6d6ef2ec47f01ad03943d Mon Sep 17 00:00:00 2001 From: SyaharaniSalsabilla Date: Wed, 1 Jul 2026 11:33:53 +0700 Subject: [PATCH] migration sosial ekonomi --- ..._01_105423_create_sosial_ekonomi_table.php | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 database/migrations/2026_07_01_105423_create_sosial_ekonomi_table.php diff --git a/database/migrations/2026_07_01_105423_create_sosial_ekonomi_table.php b/database/migrations/2026_07_01_105423_create_sosial_ekonomi_table.php new file mode 100644 index 0000000..8c8a598 --- /dev/null +++ b/database/migrations/2026_07_01_105423_create_sosial_ekonomi_table.php @@ -0,0 +1,104 @@ +id(); + $table->string('uid')->nullable()->unique(); + + $table->foreignId('petani_id')->nullable()->constrained('petani')->onDelete('cascade'); + + $table->integer('jumlah_tanggungan')->nullable(); + $table->integer('anak_masih_sekolah')->nullable(); + $table->integer('yang_ikut_bekerja')->nullable(); + + $table->tinyInteger('skor_periode_paceklik')->nullable() + ->comment('Skala 1-5: 1=>4 bulan, 2=3-4 bulan, 3=1-2 bulan, 4=sebentar/tidak menentu, 5=tidak ada/stabil'); + $table->string('bulan_paceklik')->nullable(); + $table->text('sumber_penghasilan_paceklik')->nullable(); + + $table->unsignedBigInteger('total_estimasi_biaya_kebun_per_musim')->nullable(); + + $table->tinyInteger('skor_kemampuan_menabung')->nullable() + ->comment('Skala 1-5'); + $table->unsignedBigInteger('estimasi_tabungan_per_bulan')->nullable(); + + $table->tinyInteger('skor_kecukupan_penghasilan')->nullable() + ->comment('Skala 1-5'); + $table->text('alasan_kecukupan_penghasilan')->nullable(); + + $table->string('status_kepemilikan_lahan')->nullable(); + $table->tinyInteger('skor_kejelasan_status_lahan')->nullable() + ->comment('Skala 1-5'); + $table->boolean('ada_sertifikat_dokumen')->nullable(); + $table->boolean('ada_sengketa')->nullable(); + $table->text('keterangan_sengketa')->nullable(); + $table->string('pihak_membantu_konflik')->nullable() + ->comment('Tidak ada-selesaikan sendiri / Ada'); + $table->string('pihak_membantu_konflik_nama')->nullable(); + $table->year('tahun_bantuan_konflik')->nullable(); + $table->string('status_konflik')->nullable() + ->comment('Sudah selesai / Belum, masih berlanjut'); + + $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(); + }); + + Schema::create('pendapatan_komoditas', function (Blueprint $table) { + $table->id(); + $table->string('uid')->nullable()->unique(); + + $table->foreignId('sosial_ekonomi_id')->constrained('sosial_ekonomi')->onDelete('cascade'); + + $table->string('kategori')->comment('utama / lainnya'); + $table->string('komoditas')->nullable(); + $table->unsignedBigInteger('pendapatan')->nullable(); + $table->string('periode')->nullable()->comment('musim / tahun'); + + $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(); + }); + + Schema::create('pendapatan_luar_pertanian', function (Blueprint $table) { + $table->id(); + $table->string('uid')->nullable()->unique(); + + $table->foreignId('sosial_ekonomi_id')->constrained('sosial_ekonomi')->onDelete('cascade'); + + $table->string('jenis_pekerjaan')->nullable(); + $table->unsignedBigInteger('estimasi_per_bulan')->nullable(); + + $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(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('pendapatan_luar_pertanian'); + Schema::dropIfExists('pendapatan_komoditas'); + Schema::dropIfExists('sosial_ekonomi'); + } +};