skl/database/migrations/2025_03_12_103025_create_ip...

60 lines
1.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('Ipal', function (Blueprint $table) {
$table->id('IpalId');
$table->unsignedInteger('PelaporanId');
$table->unsignedInteger('RefIpalId');
$table->string('Nomor', 100);
$table->string('Nama', 255);
$table->string('Lampiran', 255);
$table->date('IzinTerbit');
$table->date('IzinHabis');
$table->string('Sumber', 255);
$table->float('Kapasitas');
$table->string('Teknologi', 255);
$table->string('BadanAir', 255);
$table->float('DebitMaksimum', 7, 2)->nullable();
$table->double('Lintang')->nullable()->comment('lintang in decimal degree');
$table->double('Bujur')->nullable()->comment('bujur in decimal degree');
$table->index('PelaporanId', 'IndexPelaporan_PelaporanId');
$table->index('RefIpalId', 'IndexRefIpal_RefIpalId');
// Foreign key untuk relasi (pastikan tabel Pelaporan dan RefIpal sudah ada)
$table->foreign('PelaporanId')
->references('PelaporanId')
->on('Pelaporan')
->onDelete('cascade');
$table->foreign('RefIpalId')
->references('RefIpalId')
->on('RefIpal')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('Ipal', function (Blueprint $table) {
$table->dropForeign(['PelaporanId']);
$table->dropForeign(['RefIpalId']);
});
Schema::dropIfExists('Ipal');
}
};