feat: [approval] 위임장 양식 데이터 마이그레이션 추가

- 전체 테넌트에 delegation 양식 레코드 자동 삽입
This commit is contained in:
김보곤
2026-03-06 22:41:31 +09:00
parent 88eb507426
commit 91567c54bd

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
$tenants = DB::table('tenants')->whereNull('deleted_at')->pluck('id');
foreach ($tenants as $tenantId) {
$exists = DB::table('approval_forms')
->where('tenant_id', $tenantId)
->where('code', 'delegation')
->exists();
if (! $exists) {
DB::table('approval_forms')->insert([
'tenant_id' => $tenantId,
'name' => '위임장',
'code' => 'delegation',
'category' => 'request',
'template' => '[]',
'body_template' => '',
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
}
}
public function down(): void
{
DB::table('approval_forms')->where('code', 'delegation')->delete();
}
};