Files
database-pertani-web/database/migrations/2026_04_11_105538_create_programs_table.php
T

75 lines
2.9 KiB
PHP

<?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::create('core_program', function (Blueprint $table) {
$table->id();
$table->string('nama');
$table->string('sub_domain');
$table->integer('tahun');
$table->string('instansi')->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();
$table->softDeletes();
});
Schema::create('core_program_komoditas', function (Blueprint $table) {
$table->id();
$table->foreignId('program_id')->nullable()->constrained('core_program')->nullOnDelete();
$table->foreignId('komoditas_id')->nullable()->constrained('master_komoditas')->nullOnDelete();
$table->boolean('default')->default(false);
$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('core_program_lokasi', function (Blueprint $table) {
$table->id();
$table->foreignId('program_id')->nullable()->constrained('core_program')->nullOnDelete();
$table->foreignId('provinsi_id')->nullable()->constrained('master_provinsi')->nullOnDelete();
$table->foreignId('kabupaten_kota_id')->nullable()->constrained('master_kabupaten_kota')->nullOnDelete();
$table->foreignId('kecamatan_id')->nullable()->constrained('master_kecamatan')->nullOnDelete();
$table->foreignId('desa_kelurahan_id')->nullable()->constrained('master_desa_kelurahan')->nullOnDelete();
$table->boolean('default')->default(false);
$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();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('core_program_lokasi');
Schema::dropIfExists('core_program_komoditas');
Schema::dropIfExists('core_program');
}
};