update migration
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m27s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
Build, Push and Deploy / deploy-staging (push) Successful in 23s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-05 17:18:42 +07:00
parent 30de18d283
commit 3b3a1da5c3
7 changed files with 92 additions and 78 deletions

View File

@@ -11,24 +11,26 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('employees', function (Blueprint $table) { if (!Schema::hasTable('employees')) {
$table->id(); Schema::create('employees', function (Blueprint $table) {
$table->string('name'); $table->id();
$table->foreignId('business_id')->constrained()->cascadeOnDelete(); $table->string('name');
$table->foreignId('designation_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('business_id')->constrained()->cascadeOnDelete();
$table->foreignId('department_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('designation_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('shift_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('department_id')->nullable()->constrained()->nullOnDelete();
$table->double('amount', 10, 2)->default(0); $table->foreignId('shift_id')->nullable()->constrained()->nullOnDelete();
$table->string('image')->nullable(); $table->double('amount', 10, 2)->default(0);
$table->string('phone'); $table->string('image')->nullable();
$table->string('email')->nullable(); $table->string('phone');
$table->string('gender'); $table->string('email')->nullable();
$table->string('country')->nullable(); $table->string('gender');
$table->date('birth_date')->nullable(); $table->string('country')->nullable();
$table->date('join_date')->nullable(); $table->date('birth_date')->nullable();
$table->string('status')->default('active'); // active || terminated || suspended $table->date('join_date')->nullable();
$table->timestamps(); $table->string('status')->default('active'); // active || terminated || suspended
}); $table->timestamps();
});
}
} }
/** /**

View File

@@ -11,14 +11,16 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('leave_types', function (Blueprint $table) { if (!Schema::hasTable('leave_types')) {
$table->id(); Schema::create('leave_types', function (Blueprint $table) {
$table->foreignId('business_id')->constrained()->cascadeOnDelete(); $table->id();
$table->string('name'); $table->foreignId('business_id')->constrained()->cascadeOnDelete();
$table->text('description')->nullable(); $table->string('name');
$table->boolean('status')->default(1); $table->text('description')->nullable();
$table->timestamps(); $table->boolean('status')->default(1);
}); $table->timestamps();
});
}
} }
/** /**

View File

@@ -11,20 +11,22 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('leaves', function (Blueprint $table) { if (!Schema::hasTable('leaves')) {
$table->id(); Schema::create('leaves', function (Blueprint $table) {
$table->foreignId('business_id')->constrained()->cascadeOnDelete(); $table->id();
$table->foreignId('employee_id')->constrained()->cascadeOnDelete(); $table->foreignId('business_id')->constrained()->cascadeOnDelete();
$table->foreignId('leave_type_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('employee_id')->constrained()->cascadeOnDelete();
$table->foreignId('department_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('leave_type_id')->nullable()->constrained()->nullOnDelete();
$table->date('start_date'); $table->foreignId('department_id')->nullable()->constrained()->nullOnDelete();
$table->date('end_date'); $table->date('start_date');
$table->double('leave_duration'); $table->date('end_date');
$table->string('month'); $table->double('leave_duration');
$table->string('status')->default('pending'); // rejected, pending, approved $table->string('month');
$table->text('description')->nullable(); $table->string('status')->default('pending'); // rejected, pending, approved
$table->timestamps(); $table->text('description')->nullable();
}); $table->timestamps();
});
}
} }
/** /**

View File

@@ -11,15 +11,17 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('holidays', function (Blueprint $table) { if (!Schema::hasTable('holidays')) {
$table->id(); Schema::create('holidays', function (Blueprint $table) {
$table->foreignId('business_id')->constrained()->cascadeOnDelete(); $table->id();
$table->string('name'); $table->foreignId('business_id')->constrained()->cascadeOnDelete();
$table->date('start_date'); $table->string('name');
$table->date('end_date'); $table->date('start_date');
$table->text('description')->nullable(); $table->date('end_date');
$table->timestamps(); $table->text('description')->nullable();
}); $table->timestamps();
});
}
} }
/** /**

View File

@@ -11,19 +11,21 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('attendances', function (Blueprint $table) { if (!Schema::hasTable('attendances')) {
$table->id(); Schema::create('attendances', function (Blueprint $table) {
$table->foreignId('business_id')->constrained()->cascadeOnDelete(); $table->id();
$table->foreignId('employee_id')->constrained()->cascadeOnDelete(); $table->foreignId('business_id')->constrained()->cascadeOnDelete();
$table->foreignId('shift_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('employee_id')->constrained()->cascadeOnDelete();
$table->time('time_in'); $table->foreignId('shift_id')->nullable()->constrained()->nullOnDelete();
$table->time('time_out'); $table->time('time_in');
$table->date('date'); $table->time('time_out');
$table->time('duration'); $table->date('date');
$table->string('month'); $table->time('duration');
$table->longText('note')->nullable(); $table->string('month');
$table->timestamps(); $table->longText('note')->nullable();
}); $table->timestamps();
});
}
} }
/** /**

View File

@@ -11,19 +11,21 @@
*/ */
public function up(): void public function up(): void
{ {
Schema::create('payrolls', function (Blueprint $table) { if (!Schema::hasTable('payrolls')) {
$table->id(); Schema::create('payrolls', function (Blueprint $table) {
$table->foreignId('business_id')->constrained()->cascadeOnDelete(); $table->id();
$table->foreignId('employee_id')->constrained()->cascadeOnDelete(); $table->foreignId('business_id')->constrained()->cascadeOnDelete();
$table->foreignId('payment_type_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('employee_id')->constrained()->cascadeOnDelete();
$table->string('month'); $table->foreignId('payment_type_id')->nullable()->constrained()->nullOnDelete();
$table->string('puid'); $table->string('month');
$table->date('date')->nullable(); $table->string('puid');
$table->double('amount', 10, 2); $table->date('date')->nullable();
$table->string('payemnt_year'); $table->double('amount', 10, 2);
$table->longText('note')->nullable(); $table->string('payemnt_year');
$table->timestamps(); $table->longText('note')->nullable();
}); $table->timestamps();
});
}
} }
/** /**

View File

@@ -12,9 +12,11 @@ public function up(): void
{ {
// HOLIDAYS, ATTENDANCES, LEAVES, PAYROLLS, employees // HOLIDAYS, ATTENDANCES, LEAVES, PAYROLLS, employees
foreach (['holidays', 'attendances', 'leaves', 'payrolls', 'employees'] as $tableName) { foreach (['holidays', 'attendances', 'leaves', 'payrolls', 'employees'] as $tableName) {
Schema::table($tableName, function (Blueprint $table) { if (!Schema::hasColumn($tableName, 'branch_id')) {
$table->foreignId('branch_id')->nullable()->after('business_id')->constrained('branches')->nullOnDelete(); Schema::table($tableName, function (Blueprint $table) {
}); $table->foreignId('branch_id')->nullable()->after('business_id')->constrained('branches')->nullOnDelete();
});
}
} }
} }