first commit
This commit is contained in:
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
59
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
59
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedSmallInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('connection');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
|
||||
$table->index(['connection', 'queue', 'failed_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
<?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
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
$table->id(); // permission id
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->id(); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::dropIfExists($tableNames['role_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['model_has_roles']);
|
||||
Schema::dropIfExists($tableNames['model_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['roles']);
|
||||
Schema::dropIfExists($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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('activity_log', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('log_name')->nullable()->index();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->string('event')->nullable();
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('attribute_changes')->nullable();
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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::table('users', function (Blueprint $table) {
|
||||
$table->string('phone')->nullable()->after('email');
|
||||
$table->string('jawatan')->nullable()->after('phone'); // jawatan rasmi
|
||||
$table->boolean('is_active')->default(true)->after('jawatan');
|
||||
$table->softDeletes();
|
||||
$table->index('is_active');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['phone', 'jawatan', 'is_active', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('consultants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('nama_perunding');
|
||||
$table->string('no_pendaftaran_syarikat')->nullable();
|
||||
$table->text('alamat')->nullable();
|
||||
$table->string('emel')->nullable();
|
||||
$table->string('telefon')->nullable();
|
||||
$table->boolean('aktif')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('aktif');
|
||||
$table->index('nama_perunding');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('consultants');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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('data_centres', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama_pusat_data');
|
||||
$table->string('tajuk_permohonan')->nullable();
|
||||
$table->string('lokasi_pusat_data')->nullable();
|
||||
$table->text('alamat')->nullable();
|
||||
$table->decimal('keluasan_tapak', 15, 2)->nullable()->comment('Keluasan tapak (ekar/m2)');
|
||||
$table->decimal('it_load', 15, 2)->nullable()->comment('Kapasiti penjanaan elektrik komponen IT / IT Load (MW)');
|
||||
$table->string('status')->default('aktif'); // aktif / tidak_aktif
|
||||
$table->foreignId('current_consultant_id')->nullable()->constrained('consultants')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('status');
|
||||
$table->index('current_consultant_id');
|
||||
$table->index('nama_pusat_data');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('data_centres');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('data_centre_consultant_assignments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('data_centre_id')->constrained('data_centres')->cascadeOnDelete();
|
||||
$table->foreignId('consultant_id')->constrained('consultants')->cascadeOnDelete();
|
||||
$table->date('start_date');
|
||||
$table->date('end_date')->nullable();
|
||||
$table->text('reason')->nullable(); // sebab perubahan
|
||||
$table->foreignId('assigned_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['data_centre_id', 'is_active'], 'dcca_dc_active_idx');
|
||||
$table->index('consultant_id', 'dcca_consultant_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('data_centre_consultant_assignments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('checklist_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('version')->default('1.0');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_active')->default(false);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('is_active');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('checklist_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('checklist_sections', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('checklist_template_id')->constrained('checklist_templates')->cascadeOnDelete();
|
||||
$table->string('code')->comment('Kod seksyen cth: A, B, C, D, E, LAIN');
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedInteger('order')->default(0);
|
||||
$table->boolean('is_formula_enabled')->default(false)->comment('Seksyen menggunakan formula atau tidak');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['checklist_template_id', 'order']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('checklist_sections');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('checklist_scopes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('checklist_section_id')->constrained('checklist_sections')->cascadeOnDelete();
|
||||
$table->string('code')->comment('cth: SKOP1, SKOP2, SKOP3');
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedInteger('order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['checklist_section_id', 'order']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('checklist_scopes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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('checklist_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('checklist_section_id')->constrained('checklist_sections')->cascadeOnDelete();
|
||||
$table->foreignId('checklist_scope_id')->nullable()->constrained('checklist_scopes')->nullOnDelete();
|
||||
$table->string('code')->comment('Kod rujukan cth: A.1.i, 2(i)');
|
||||
$table->string('formula_token')->nullable()->comment('Token unik untuk rujukan formula cth: SKOP1, EE, RE');
|
||||
$table->string('label');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('input_type')->default('number'); // number,text,textarea,select,checkbox,file_reference,calculated
|
||||
$table->json('options')->nullable()->comment('Pilihan untuk input jenis select/checkbox');
|
||||
$table->string('unit')->nullable()->comment('cth: tCO2e, %, tahun');
|
||||
$table->boolean('is_required')->default(false);
|
||||
$table->boolean('is_calculated')->default(false)->comment('Item formula/dikira automatik');
|
||||
$table->text('formula')->nullable()->comment('Ungkapan formula jika item dikira');
|
||||
$table->unsignedInteger('order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['checklist_section_id', 'order']);
|
||||
$table->index('formula_token');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('checklist_items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('checklist_formulas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('checklist_template_id')->constrained('checklist_templates')->cascadeOnDelete();
|
||||
$table->foreignId('checklist_section_id')->nullable()->constrained('checklist_sections')->cascadeOnDelete();
|
||||
$table->string('result_token')->comment('Token hasil yang dikira cth: A, B, C, D, E');
|
||||
$table->string('label')->nullable();
|
||||
$table->text('expression')->comment('Ungkapan RHS cth: SKOP1 + SKOP2 + SKOP3 atau A - B');
|
||||
$table->string('unit')->nullable();
|
||||
$table->boolean('guard_div_zero')->default(false)->comment('Lindung pembahagian dengan sifar');
|
||||
$table->unsignedInteger('order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['checklist_template_id', 'order']);
|
||||
$table->index('result_token');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('checklist_formulas');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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('reporting_cycles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedSmallInteger('renewal_year')->unique()->comment('Tahun pembaharuan lesen');
|
||||
$table->unsignedSmallInteger('reporting_year')->comment('Tahun pelaporan = renewal_year - 2');
|
||||
$table->date('period_start')->comment('1 Januari tahun pelaporan');
|
||||
$table->date('period_end')->comment('31 Disember tahun pelaporan');
|
||||
$table->date('cut_off_date')->comment('Tarikh tutup serahan, boleh dikonfigur JPP');
|
||||
$table->unsignedSmallInteger('licence_period_year')->default(1);
|
||||
$table->foreignId('checklist_template_id')->nullable()->constrained('checklist_templates')->nullOnDelete();
|
||||
$table->string('status')->default('aktif'); // aktif / tutup
|
||||
$table->text('catatan')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('status');
|
||||
$table->index('reporting_year');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('reporting_cycles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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('submission_answers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('submission_id')->constrained('submissions')->cascadeOnDelete();
|
||||
$table->foreignId('checklist_item_id')->constrained('checklist_items')->cascadeOnDelete();
|
||||
$table->text('value')->nullable();
|
||||
$table->string('unit')->nullable();
|
||||
$table->string('page_reference')->nullable()->comment('No muka surat / rujukan dalam laporan PDF');
|
||||
$table->text('consultant_note')->nullable();
|
||||
$table->text('officer_note')->nullable();
|
||||
// belum_semak, sah, tidak_sah
|
||||
$table->string('validation_status')->default('belum_semak');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['submission_id', 'checklist_item_id'], 'answers_submission_item_unique');
|
||||
$table->index('checklist_item_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('submission_answers');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('submission_results', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('submission_id')->constrained('submissions')->cascadeOnDelete();
|
||||
$table->string('result_token')->comment('A, B, C, D, E');
|
||||
$table->string('label')->nullable();
|
||||
$table->decimal('value', 20, 4)->nullable();
|
||||
$table->string('unit')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['submission_id', 'result_token'], 'results_submission_token_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('submission_results');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('submission_documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('submission_id')->constrained('submissions')->cascadeOnDelete();
|
||||
$table->string('original_filename');
|
||||
$table->string('stored_path');
|
||||
$table->string('file_hash', 64)->nullable();
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->unsignedBigInteger('size')->nullable();
|
||||
$table->unsignedInteger('version')->default(1);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['submission_id', 'is_active']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('submission_documents');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('submission_status_histories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('submission_id')->constrained('submissions')->cascadeOnDelete();
|
||||
$table->string('from_status')->nullable();
|
||||
$table->string('to_status');
|
||||
$table->foreignId('changed_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('submission_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('submission_status_histories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('submission_correction_requests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('submission_id')->constrained('submissions')->cascadeOnDelete();
|
||||
$table->foreignId('checklist_item_id')->nullable()->constrained('checklist_items')->nullOnDelete();
|
||||
$table->string('page_reference')->nullable()->comment('No muka surat yang perlu dibetulkan');
|
||||
$table->string('location')->nullable()->comment('Lokasi / seksyen / item');
|
||||
$table->text('description')->comment('Penerangan apa yang perlu dibetulkan');
|
||||
// terbuka, dijawab, selesai
|
||||
$table->string('status')->default('terbuka');
|
||||
$table->text('consultant_response')->nullable();
|
||||
$table->timestamp('responded_at')->nullable();
|
||||
$table->foreignId('responded_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('resolved_at')->nullable();
|
||||
$table->foreignId('resolved_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['submission_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('submission_correction_requests');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('submission_comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('submission_id')->constrained('submissions')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->text('body');
|
||||
$table->boolean('is_internal')->default(false)->comment('Mesej dalaman JPP sahaja / luaran kepada perunding');
|
||||
$table->string('attachment_path')->nullable();
|
||||
$table->string('attachment_name')->nullable();
|
||||
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['submission_id', 'created_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('submission_comments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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('app_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->string('type')->default('string'); // string, integer, boolean, date
|
||||
$table->string('group')->default('umum');
|
||||
$table->string('label')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('app_settings');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user