Ensure job_roles table exists before job_sub_roles migration

This commit is contained in:
2026-06-05 14:47:11 +02:00
parent e5bf546ae7
commit 789c547bc7
@@ -8,6 +8,55 @@ final class CreateJobSubRolesTable extends AbstractMigration
{
public function change(): void
{
if (!$this->hasTable('job_roles')) {
$rolesTable = $this->table('job_roles', [
'id' => false,
'primary_key' => ['id'],
'collation' => 'utf8mb4_unicode_ci',
'encoding' => 'utf8mb4',
]);
$rolesTable
->addColumn('id', 'integer', [
'identity' => true,
'signed' => false,
])
->addColumn('name', 'string', [
'limit' => 255,
'null' => false,
])
->addColumn('description', 'text', [
'null' => true,
'default' => null,
])
->addColumn('sort_order', 'integer', [
'signed' => false,
'null' => false,
'default' => 999,
])
->addColumn('is_active', 'boolean', [
'null' => false,
'default' => 1,
])
->addColumn('created_at', 'timestamp', [
'null' => true,
'default' => 'CURRENT_TIMESTAMP',
])
->addColumn('updated_at', 'timestamp', [
'null' => true,
'default' => 'CURRENT_TIMESTAMP',
'update' => 'CURRENT_TIMESTAMP',
])
->addIndex(['is_active'], [
'name' => 'idx_job_roles_is_active',
])
->addIndex(['sort_order'], [
'name' => 'idx_job_roles_sort_order',
])
->create();
}
if (!$this->hasTable('job_sub_roles')) {
$table = $this->table('job_sub_roles', [
'id' => false,
'primary_key' => ['id'],
@@ -71,4 +120,5 @@ final class CreateJobSubRolesTable extends AbstractMigration
)
->create();
}
}
}