Initial commit - lms-v2 + CLAUDE.md
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?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();
|
||||
|
||||
// --- 1. Identitas Utama ---
|
||||
$table->string('nik')->unique()->nullable(); // NIK / Nomor Karyawan
|
||||
$table->string('identity_number')->nullable(); // No. KTP / NPWP
|
||||
|
||||
// --- 2. Penamaan ---
|
||||
$table->string('initial', 10)->nullable();
|
||||
$table->string('first_name');
|
||||
$table->string('last_name')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
|
||||
// --- 3. Autentikasi & Hak Akses ---
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('role')->default('karyawan'); // Role: admin, trainer, karyawan
|
||||
|
||||
// --- 4. Demografi & Status ---
|
||||
$table->enum('gender', ['L', 'P'])->nullable(); // Laki-laki / Perempuan
|
||||
$table->date('date_of_birth')->nullable();
|
||||
$table->date('join_date')->nullable();
|
||||
|
||||
// --- 5. Media ---
|
||||
$table->string('photo')->nullable(); // URL/Path foto profil
|
||||
|
||||
// --- 6. Relasi Master Data (Foreign Keys) ---
|
||||
$table->foreignId('department_id')->nullable()->constrained('departments')->nullOnDelete();
|
||||
$table->foreignId('position_id')->nullable()->constrained('positions')->nullOnDelete();
|
||||
$table->foreignId('training_matrix_id')->nullable()->constrained('training_matrices')->nullOnDelete();
|
||||
|
||||
// --- 7. Kebutuhan Migrasi dari LMS CI3 (Legacy) ---
|
||||
$table->unsignedBigInteger('old_id')->nullable(); // Menjaga relasi nilai ujian lama
|
||||
$table->string('old_password_hash')->nullable(); // Backup password MD5/SHA1 lama
|
||||
|
||||
$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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user