52 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			52 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('Catatan', function (Blueprint $table) {
 | |
|             $table->id('CatatanId');
 | |
|             $table->unsignedInteger('PelaporanId');
 | |
|             $table->unsignedInteger('RefPelaporanId');
 | |
|             $table->text('IsiCatatan')->nullable();
 | |
|             $table->text('Evaluasi')->nullable();
 | |
| 
 | |
|             // Menambahkan index untuk kolom PelaporanId dan RefPelaporanId
 | |
|             $table->index('PelaporanId', 'IndexCatatan_PelaporanId');
 | |
|             $table->index('RefPelaporanId', 'IndexCatatan_RefPelaporanId');
 | |
| 
 | |
|             // Menambahkan foreign key untuk relasi dengan tabel Pelaporan
 | |
|             $table->foreign('PelaporanId')
 | |
|                   ->references('PelaporanId')
 | |
|                   ->on('Pelaporan')
 | |
|                   ->onDelete('cascade');
 | |
| 
 | |
|             // Menambahkan foreign key untuk relasi dengan tabel RefPelaporan
 | |
|             $table->foreign('RefPelaporanId')
 | |
|                   ->references('RefPelaporanId')
 | |
|                   ->on('RefPelaporan')
 | |
|                   ->onDelete('cascade');
 | |
|             $table->timestamps();
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Reverse the migrations.
 | |
|      */
 | |
|     public function down(): void
 | |
|     {
 | |
|         Schema::table('Catatan', function (Blueprint $table) {
 | |
|             $table->dropForeign(['PelaporanId']);
 | |
|             $table->dropForeign(['RefPelaporanId']);
 | |
|         });
 | |
|         Schema::dropIfExists('Catatan');
 | |
|     }
 | |
| };
 |