skl/database/migrations/2025_03_11_140738_create_ce...

65 lines
2.3 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('Cerobong', function (Blueprint $table) {
$table->id('CerobongId');
$table->unsignedInteger('PelaporanId');
$table->unsignedInteger('RefCerobongId');
$table->string('Kode', 45)->nullable();
$table->string('Nama', 255)->nullable();
$table->string('SumberEmisi', 255)->nullable();
$table->string('JenisBahanBakar', 255)->nullable();
$table->string('Konsumsi', 255)->nullable();
$table->string('Bentuk', 255)->nullable();
$table->float('Tinggi')->nullable();
$table->float('Diameter')->nullable();
$table->float('Posisi')->nullable();
$table->string('JenisPengendali', 255)->nullable();
$table->float('JamOperasional')->nullable();
$table->float('Kapasitas')->nullable();
$table->string('SatuanKapasitas', 255)->nullable();
$table->double('Lintang')->nullable()->comment('lintang in decimal degree');
$table->double('Bujur')->nullable()->comment('bujur in decimal degree');
// Menambahkan index
$table->index('PelaporanId', 'IndexCerobong_PelaporanId');
$table->index('RefCerobongId', 'IndexCerobong_RefCerobongId');
// Menambahkan foreign key untuk relasi dengan tabel Pelaporan
$table->foreign('PelaporanId')
->references('PelaporanId')
->on('Pelaporan')
->onDelete('cascade');
// Menambahkan foreign key untuk relasi dengan tabel RefCerobong
$table->foreign('RefCerobongId')
->references('RefCerobongId')
->on('RefCerobong')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('Cerobong', function (Blueprint $table) {
$table->dropForeign(['PelaporanId']);
$table->dropForeign(['RefCerobongId']);
});
Schema::dropIfExists('Cerobong');
}
};