53 lines
2.1 KiB
PHP
53 lines
2.1 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('submissions', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('data_centre_id')->constrained('data_centres')->cascadeOnDelete();
|
|
$table->foreignId('reporting_cycle_id')->constrained('reporting_cycles')->cascadeOnDelete();
|
|
$table->foreignId('consultant_id')->constrained('consultants')->cascadeOnDelete();
|
|
$table->foreignId('checklist_template_id')->nullable()->constrained('checklist_templates')->nullOnDelete();
|
|
|
|
// draf, baru, dalam_tindakan, pembetulan_perunding, selesai
|
|
$table->string('status')->default('draf');
|
|
|
|
$table->boolean('is_locked')->default(false);
|
|
$table->foreignId('locked_by')->nullable()->constrained('users')->nullOnDelete();
|
|
$table->timestamp('locked_at')->nullable();
|
|
$table->text('lock_reason')->nullable();
|
|
|
|
$table->foreignId('assigned_officer_id')->nullable()->constrained('users')->nullOnDelete();
|
|
|
|
$table->boolean('hardcopy_received')->default(false);
|
|
$table->date('hardcopy_received_date')->nullable();
|
|
$table->date('hardcopy_sent_date')->nullable()->comment('Tarikh hardcopy dihantar ke Bahagian Kawalan Perancangan');
|
|
|
|
$table->timestamp('submitted_at')->nullable();
|
|
$table->foreignId('submitted_by')->nullable()->constrained('users')->nullOnDelete();
|
|
|
|
$table->text('review_notes')->nullable();
|
|
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->unique(['data_centre_id', 'reporting_cycle_id'], 'submissions_dc_cycle_unique');
|
|
$table->index('status');
|
|
$table->index('consultant_id');
|
|
$table->index('reporting_cycle_id');
|
|
$table->index('assigned_officer_id');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('submissions');
|
|
}
|
|
};
|