Update Migration & Seeder

This commit is contained in:
2026-05-26 09:38:38 +07:00
parent 9231f25e5d
commit e4f7d675a1
12 changed files with 71 additions and 215 deletions
@@ -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');
}
@@ -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');
}
};
@@ -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');
}
};
@@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('map_lahan', function (Blueprint $table) {
$table->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
{
}
};
@@ -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');
@@ -1,25 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('profiles', function (Blueprint $table) {
$table->foreignId('adat_id')->nullable()->constrained('adat');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
}
};
@@ -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');
@@ -1,55 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('ekosistem_basis_data_kolom', function (Blueprint $table) {
$table->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
{
}
};
@@ -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');
@@ -1,27 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('ekosistem_basis_data_kolom', function (Blueprint $table) {
$table->boolean('is_active')->default('true');
$table->boolean('is_browse')->default('false');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
}
};
@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('map_lahan', function (Blueprint $table) {
//
$table->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']);
});
}
};