vernova/database/migrations/2024_01_01_000007_create_employees_table.php
2026-07-26 19:58:27 +03:30

42 lines
1.5 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('employees', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->foreignId('project_id')->nullable()->constrained()->nullOnDelete();
$table->string('national_code');
$table->string('first_name');
$table->string('last_name');
$table->string('phone')->nullable();
$table->string('job_title');
$table->enum('contract_type', ['full_time', 'part_time', 'contractor', 'intern'])->default('full_time');
$table->date('hire_date');
$table->date('termination_date')->nullable();
$table->enum('status', ['active', 'inactive', 'terminated'])->default('active');
$table->decimal('base_salary', 15, 0)->default(0);
$table->foreignId('currency_id')->nullable()->constrained('currencies')->nullOnDelete();
$table->string('bank_account')->nullable();
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('tenant_id');
$table->index('project_id');
$table->index('status');
});
}
public function down(): void
{
Schema::dropIfExists('employees');
}
};