48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.6 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('Lokasi', function (Blueprint $table) {
 | |
|              $table->id('LokasiId');
 | |
|             $table->unsignedInteger('PerusahaanId');
 | |
|             $table->string('Nama', 255);
 | |
|             $table->double('Lintang')->nullable()->comment('lintang in decimal degree');
 | |
|             $table->double('Bujur')->nullable()->comment('bujur in decimal degree');
 | |
|             $table->tinyInteger('Tipe')->unsigned()->default(0)->comment('0=kebisingan ambien, 1=udara ambien');
 | |
|             // Karena Laravel tidak mendukung tipe SET, kita gunakan ENUM sebagai gantinya
 | |
|             $table->enum('BakuMutuJenis', ['Angka Tunggal', 'Rentang Angka', 'Positif/Negatif']);
 | |
|             $table->string('BakuMutuNilai1', 45);
 | |
|             $table->string('BakuMutuNilai2', 45)->nullable();
 | |
|             $table->enum('Del', ['y', 'n']);
 | |
| 
 | |
|             $table->index('PerusahaanId', 'IndexLokasi_PerusahaanId');
 | |
|             $table->foreign('PerusahaanId')
 | |
|                   ->references('PerusahaanId')
 | |
|                   ->on('Perusahaan')
 | |
|                   ->onDelete('cascade');
 | |
|             $table->timestamps();
 | |
|         });
 | |
| 
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Reverse the migrations.
 | |
|      */
 | |
|     public function down(): void
 | |
|     {
 | |
|         Schema::table('Lokasi', function (Blueprint $table) {
 | |
|             $table->dropForeign(['PerusahaanId']);
 | |
|         });
 | |
|         Schema::dropIfExists('Lokasi');
 | |
|     }
 | |
| };
 |