41 lines
1.8 KiB
PHP
41 lines
1.8 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('leaves', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||
|
|
$table->unsignedBigInteger('user_id')->comment('신청자 ID');
|
||
|
|
$table->string('leave_type', 20)->comment('휴가유형: annual/half_am/half_pm/sick/family/maternity/parental');
|
||
|
|
$table->date('start_date')->comment('시작일');
|
||
|
|
$table->date('end_date')->comment('종료일');
|
||
|
|
$table->decimal('days', 3, 1)->comment('사용일수');
|
||
|
|
$table->text('reason')->nullable()->comment('휴가 사유');
|
||
|
|
$table->string('status', 20)->default('pending')->comment('상태: pending/approved/rejected/cancelled');
|
||
|
|
$table->unsignedBigInteger('approved_by')->nullable()->comment('승인자 ID');
|
||
|
|
$table->timestamp('approved_at')->nullable()->comment('승인/반려 일시');
|
||
|
|
$table->text('reject_reason')->nullable()->comment('반려 사유');
|
||
|
|
$table->unsignedBigInteger('created_by')->nullable()->comment('등록자');
|
||
|
|
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
|
||
|
|
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자');
|
||
|
|
$table->softDeletes();
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
$table->index(['tenant_id', 'user_id'], 'idx_tenant_user');
|
||
|
|
$table->index('status', 'idx_status');
|
||
|
|
$table->index(['start_date', 'end_date'], 'idx_dates');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('leaves');
|
||
|
|
}
|
||
|
|
};
|