refactor: make provisioning own instance lifecycle operations
This commit is contained in:
@@ -261,6 +261,14 @@ export function db(): Database.Database {
|
||||
handle.exec(schemaSql);
|
||||
migrateProvisioningActions(handle);
|
||||
migrateTable(handle, 'restart_rollout', [{ name: 'operation_id', ddl: 'ALTER TABLE restart_rollout ADD COLUMN operation_id TEXT' }]);
|
||||
migrateTable(handle, 'server_deployments', [
|
||||
{ name: 'submitted_at', ddl: 'ALTER TABLE server_deployments ADD COLUMN submitted_at TEXT' },
|
||||
{ name: 'checked_at', ddl: 'ALTER TABLE server_deployments ADD COLUMN checked_at TEXT' },
|
||||
{ name: 'players', ddl: 'ALTER TABLE server_deployments ADD COLUMN players INTEGER' }
|
||||
]);
|
||||
for (const table of ['deployment_servers', 'beta_servers', 'maintenance_jobs']) {
|
||||
migrateTable(handle, table, [{ name: 'provisioning_id', ddl: `ALTER TABLE ${table} ADD COLUMN provisioning_id TEXT` }]);
|
||||
}
|
||||
migrateServers(handle);
|
||||
// Column additions must run BEFORE any statement that references the
|
||||
// new columns. schema.sql cannot include those references — see the
|
||||
|
||||
@@ -441,6 +441,16 @@ CREATE TABLE IF NOT EXISTS server_rebuild_jobs (
|
||||
removed_at TEXT
|
||||
);
|
||||
|
||||
-- Stable links from consumers to lifecycle jobs. Sources survive their caller's
|
||||
-- history retention, while current pointers live on the caller's server rows.
|
||||
CREATE TABLE IF NOT EXISTS provisioning_sources (
|
||||
operation_id TEXT NOT NULL REFERENCES server_deployments(id) ON DELETE CASCADE,
|
||||
kind TEXT NOT NULL CHECK (kind IN ('campaign','beta','maintenance')),
|
||||
source_id TEXT NOT NULL,
|
||||
server TEXT NOT NULL,
|
||||
PRIMARY KEY (operation_id, kind, source_id, server)
|
||||
);
|
||||
|
||||
-- Blueprints retain map/count selections only. The legacy column name remains
|
||||
-- compatible with older snapshot-based definitions, read as selections at runtime.
|
||||
CREATE TABLE IF NOT EXISTS server_blueprints (
|
||||
|
||||
Reference in New Issue
Block a user