diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 6a48c7e..cf2f279 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -10,13 +10,14 @@ return new class extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); + $table->string('uid')->unique(); $table->string('name'); - $table->string('email')->unique(); + $table->string('username')->unique(); + $table->string('email')->unique()->nullable(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->string('role')->nullable(); - $table->string('uid')->unique(); $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'); @@ -24,17 +25,6 @@ return new class extends Migration $table->softDeletes(); }); - // Schema::create('user_roles', function (Blueprint $table) { - // $table->id(); - // $table->foreignId('user_id')->unique()->constrained('users')->onDelete('cascade'); - // $table->enum('role_name', ['Super Admin', 'Admin', 'Koordinator', 'Penyuluh', 'Pendamping', 'Petani'])->default('Petani'); - // $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('password_reset_tokens', function (Blueprint $table) { $table->string('email')->primary(); $table->string('token'); @@ -54,7 +44,6 @@ return new class extends Migration public function down(): void { Schema::dropIfExists('users'); - // Schema::dropIfExists('user_roles'); Schema::dropIfExists('password_reset_tokens'); Schema::dropIfExists('sessions'); } diff --git a/database/migrations/2026_02_20_110207_create_komoditas_table.php b/database/migrations/2026_02_20_110207_create_komoditas_table.php index f495045..1f7e0bb 100644 --- a/database/migrations/2026_02_20_110207_create_komoditas_table.php +++ b/database/migrations/2026_02_20_110207_create_komoditas_table.php @@ -23,9 +23,22 @@ return new class extends Migration $table->softDeletes(); }); + Schema::create('jenis_komoditas', function (Blueprint $table) { + $table->id(); + $table->foreignId('komoditas_id')->constrained('master_komoditas')->onDelete('cascade'); + $table->string('nama'); + $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('master_varietas', function (Blueprint $table) { $table->id(); $table->foreignId('komoditas_id')->constrained('master_komoditas')->onDelete('cascade'); + $table->foreignId('jenis_komoditas_id')->constrained('jenis_komoditas')->onDelete('cascade'); $table->string('nama'); $table->text('deskripsi')->unique(); @@ -37,13 +50,11 @@ return new class extends Migration $table->softDeletes(); }); } - - /** - * Reverse the migrations. - */ + public function down(): void { - Schema::dropIfExists('master_komoditas'); Schema::dropIfExists('master_varietas'); + Schema::dropIfExists('jenis_komoditas'); + Schema::dropIfExists('master_komoditas'); } }; diff --git a/database/migrations/2026_02_20_131504_create_lahans_table.php b/database/migrations/2026_02_20_131504_create_lahans_table.php index 9469b3e..13dc242 100644 --- a/database/migrations/2026_02_20_131504_create_lahans_table.php +++ b/database/migrations/2026_02_20_131504_create_lahans_table.php @@ -13,6 +13,7 @@ return new class extends Migration { Schema::create('map_lahan', function (Blueprint $table) { $table->id(); + $table->string('uid')->unique(); $table->string('nama'); $table->string('status_kepemilikan'); @@ -21,8 +22,14 @@ return new class extends Migration $table->foreignId('adat_pemilik_id')->nullable()->constrained('adat')->onDelete('set null'); $table->foreignId('desa_kelurahan_id')->nullable()->constrained('master_desa_kelurahan'); + $table->string('lat')->nullable(); + $table->string('long')->nullable(); $table->jsonb('path')->nullable(); + $table->boolean('sertifikat')->default(false); + $table->boolean('konflik')->default(false); + $table->text('deskripsi')->nullable(); + $table->float('luas_lahan', 8)->nullable(); $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); @@ -33,11 +40,31 @@ return new class extends Migration $table->softDeletes(); }); + Schema::create('sertifikat_lahan', function (Blueprint $table) { + $table->id(); + $table->string('uid')->unique(); + $table->string('nomor_sertifikat'); + $table->date('tanggal_terbit'); + $table->date('tanggal_kadaluarsa')->nullable(); + $table->string('lembaga_penerbit')->nullable(); + + $table->foreignId('lahan_id')->constrained('map_lahan')->onDelete('cascade'); + + $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('map_tanaman', function (Blueprint $table) { $table->id(); + $table->string('uid')->unique(); $table->string('nama'); $table->foreignId('komoditas_id')->constrained('master_komoditas')->onDelete('set null'); + $table->foreignId('jenis_komoditas_id')->constrained('jenis_komoditas')->onDelete('set null'); $table->foreignId('varietas_id')->constrained('master_varietas')->onDelete('set null'); $table->foreignId('profile_id')->constrained('profiles')->onDelete('set null'); $table->foreignId('lahan_id')->constrained('map_lahan')->onDelete('set null'); @@ -46,6 +73,8 @@ return new class extends Migration $table->float('longitude')->nullable(); $table->string('kondisi_tanaman')->nullable(); + $table->string('metode_pengumpulan')->nullable(); + $table->text('deskripsi')->nullable(); $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); $table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null'); @@ -62,6 +91,7 @@ return new class extends Migration public function down(): void { Schema::dropIfExists('map_tanaman'); + Schema::dropIfExists('sertifikat_lahan'); Schema::dropIfExists('map_lahan'); } }; diff --git a/database/migrations/2026_04_10_131504_update_jsonb_path.php b/database/migrations/2026_04_10_131504_update_jsonb_path.php deleted file mode 100644 index d7534c8..0000000 --- a/database/migrations/2026_04_10_131504_update_jsonb_path.php +++ /dev/null @@ -1,42 +0,0 @@ -jsonb('path')->nullable()->change(); - }); - - Schema::table('master_provinsi', function (Blueprint $table) { - $table->jsonb('path')->nullable()->change(); - }); - - Schema::table('master_kabupaten_kota', function (Blueprint $table) { - $table->jsonb('path')->nullable()->change(); - }); - - Schema::table('master_kecamatan', function (Blueprint $table) { - $table->jsonb('path')->nullable()->change(); - }); - - Schema::table('master_desa_kelurahan', function (Blueprint $table) { - $table->jsonb('path')->nullable()->change(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - - } -}; diff --git a/database/migrations/2026_04_15_103739_create_basis_data_table.php b/database/migrations/2026_04_15_103739_create_basis_data_table.php index e8d3fa8..35aeedb 100644 --- a/database/migrations/2026_04_15_103739_create_basis_data_table.php +++ b/database/migrations/2026_04_15_103739_create_basis_data_table.php @@ -29,9 +29,15 @@ return new class extends Migration $table->foreignId('tabel_id')->constrained('ekosistem_basis_data_tabel')->restrictOnDelete(); $table->string('kolom'); $table->string('label'); - $table->enum('tipe', ['varchar', 'integer', 'float', 'boolean', 'date', 'datetime', 'text'])->default('varchar'); + $table->enum('tipe', ['varchar', 'integer', 'float', 'boolean', 'date', 'datetime', 'text', 'foreign_key', 'enum'])->default('varchar'); $table->jsonb('validasi')->nullable(); $table->integer('urutan')->default(1); + $table->string('relasi_tabel')->nullable(); + $table->string('relasi_kolom_id')->nullable(); + $table->string('relasi_kolom_label')->nullable(); + $table->boolean('is_active')->default('true'); + $table->boolean('is_browse')->default('false'); + $table->jsonb('enum_opsi')->nullable(); $table->timestamps(); $table->softDeletes(); @@ -60,6 +66,8 @@ return new class extends Migration $table->date('value_date')->nullable(); $table->datetime('value_datetime')->nullable(); $table->text('value_text')->nullable(); + $table->integer('value_relasi')->nullable(); + $table->string('value_enum')->nullable(); $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); $table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null'); diff --git a/database/migrations/2026_04_16_172905_update_profiles_table.php b/database/migrations/2026_04_16_172905_update_profiles_table.php deleted file mode 100644 index f2ee0fb..0000000 --- a/database/migrations/2026_04_16_172905_update_profiles_table.php +++ /dev/null @@ -1,25 +0,0 @@ -foreignId('adat_id')->nullable()->constrained('adat'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - } -}; diff --git a/database/migrations/2026_04_27_092222_create_petani_table.php b/database/migrations/2026_04_27_092222_create_petani_table.php index 13df24f..46a432c 100644 --- a/database/migrations/2026_04_27_092222_create_petani_table.php +++ b/database/migrations/2026_04_27_092222_create_petani_table.php @@ -13,9 +13,11 @@ return new class extends Migration { Schema::create('ekosistem_petani_cpm', function (Blueprint $table) { $table->id(); - + $table->string('uid')->unique(); + $table->foreignId('program_id')->nullable()->constrained('core_program')->nullOnDelete(); $table->string('nama'); $table->boolean('jenis_kelamin'); + $table->string('tempat_lahir')->nullable(); $table->date('tanggal_lahir'); $table->string('pendidikan_terakhir')->nullable(); @@ -28,11 +30,17 @@ return new class extends Migration $table->float('lama_bertani', 8)->nullable(); $table->float('luas_lahan', 8)->nullable(); + $table->string('dusun_rt_rw')->nullable(); + $table->string('nomor_telepon')->nullable(); + $table->string('foto')->nullable(); + $table->string('pekerjaan_sampingan')->nullable(); $table->foreignId('komoditas_sampingan_id')->nullable()->constrained('master_komoditas'); $table->float('lama_bertani_sampingan', 8)->nullable(); $table->float('luas_lahan_sampingan', 8)->nullable(); + + $table->string('status_perkawinan')->nullable(); $table->string('status_keluarga')->nullable(); $table->integer('jumlah_tanggungan')->nullable(); @@ -48,9 +56,6 @@ return new class extends Migration }); } - /** - * Reverse the migrations. - */ public function down(): void { Schema::dropIfExists('ekosistem_petani_cpm'); diff --git a/database/migrations/2026_05_05_103739_update_basis_data_table.php b/database/migrations/2026_05_05_103739_update_basis_data_table.php deleted file mode 100644 index cee687b..0000000 --- a/database/migrations/2026_05_05_103739_update_basis_data_table.php +++ /dev/null @@ -1,55 +0,0 @@ -string('relasi_tabel')->nullable(); - $table->string('relasi_kolom_id')->nullable(); - $table->string('relasi_kolom_label')->nullable(); - - $table->jsonb('enum_opsi')->nullable(); - }); - - DB::statement("alter table public.ekosistem_basis_data_kolom drop constraint ekosistem_basis_data_kolom_tipe_check;"); - DB::statement(" - alter table public.ekosistem_basis_data_kolom add constraint ekosistem_basis_data_kolom_tipe_check check (((tipe)::text = any - ((array[ - 'varchar'::character varying, - 'integer'::character varying, - 'float'::character varying, - 'boolean'::character varying, - 'date'::character varying, - 'datetime'::character varying, - 'text'::character varying, - 'foreign_key'::character varying, - 'enum'::character varying - ])::text[]))) - "); - - Schema::table('ekosistem_basis_data_value', function (Blueprint $table) { - $table->integer('value_relasi')->nullable(); - $table->string('value_enum')->nullable(); - }); - - Schema::table('ekosistem_petani_cpm', function (Blueprint $table) { - $table->foreignId('program_id')->nullable()->constrained('core_program')->nullOnDelete(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - } -}; diff --git a/database/migrations/2026_05_06_113516_create_ekosistem_lahan_cpcl_table.php b/database/migrations/2026_05_06_113516_create_ekosistem_lahan_cpcl_table.php index d2d866f..db86702 100644 --- a/database/migrations/2026_05_06_113516_create_ekosistem_lahan_cpcl_table.php +++ b/database/migrations/2026_05_06_113516_create_ekosistem_lahan_cpcl_table.php @@ -13,6 +13,7 @@ return new class extends Migration { Schema::create('ekosistem_lahan_cpcl', function (Blueprint $table) { $table->id(); + $table->string('uid')->unique(); $table->string('nama'); $table->string('status_kepemilikan'); diff --git a/database/migrations/2026_05_07_103739_update_basis_data_table_2.php b/database/migrations/2026_05_07_103739_update_basis_data_table_2.php deleted file mode 100644 index a187a6b..0000000 --- a/database/migrations/2026_05_07_103739_update_basis_data_table_2.php +++ /dev/null @@ -1,27 +0,0 @@ -boolean('is_active')->default('true'); - $table->boolean('is_browse')->default('false'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - } -}; diff --git a/database/migrations/2026_05_18_112159_add_uid_to_map_tanaman.php b/database/migrations/2026_05_18_112159_add_uid_to_map_tanaman.php deleted file mode 100644 index 4f41d03..0000000 --- a/database/migrations/2026_05_18_112159_add_uid_to_map_tanaman.php +++ /dev/null @@ -1,39 +0,0 @@ -string('uid')->unique(); // LH-1234567890&0987654321 (sepuluh digit user - 10 digit lahan) - }); - - Schema::table('map_tanaman', function(Blueprint $table){ - $table->string('uid')->unique(); //// LH-1234567890&0987654321&5432167890 - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('map_lahan', function (Blueprint $table) { - $table->dropUnique(['uid']); - $table->dropColumn(['uid']); - }); - - Schema::table('map_tanaman', function (Blueprint $table) { - $table->dropUnique(['uid']); - $table->dropColumn(['uid']); - }); - } -}; diff --git a/database/seeders/AdminUserSeeder.php b/database/seeders/AdminUserSeeder.php index 39cfc85..d1193be 100644 --- a/database/seeders/AdminUserSeeder.php +++ b/database/seeders/AdminUserSeeder.php @@ -15,17 +15,18 @@ class AdminUserSeeder extends Seeder public function run(): void { DB::table('users')->insert([ + 'uid' => 'AD-1234567891', 'name' => 'Admin', + 'username' => 'admin', 'email' => 'admin@example.com', 'email_verified_at' => now(), 'password' => Hash::make('Asalada123'), 'role' => 'super_admin', - 'uid' => 'AD-1234567891', 'created_at' => now(), 'updated_at' => now(), ]); - Db::table('profiles')->insert([ + DB::table('profiles')->insert([ 'user_id' => 1, 'role' => 'super_admin', 'nama' => 'Admin', @@ -44,7 +45,6 @@ class AdminUserSeeder extends Seeder 'updated_by' => 1, 'created_at' => now(), 'updated_at' => now(), - 'adat_id' => null, 'user_uid' => 'AD-1234567891', ]); }