Support multi-game betas with automatic server selection
This commit is contained in:
@@ -125,9 +125,8 @@ function migrateTable(handle: Database.Database, table: string, cols: Array<{ na
|
||||
}
|
||||
|
||||
// Backfill the multi-script join tables from the legacy single-script columns.
|
||||
// Idempotent — every INSERT is guarded by a NOT EXISTS clause on the target
|
||||
// row's primary key. Safe to run on every boot even after the deprecated
|
||||
// columns are eventually dropped.
|
||||
// Existing bundle membership is authoritative. Only single-script betas can
|
||||
// inherit server membership from the deprecated primary-script columns.
|
||||
function backfillMultiScriptJoins(handle: Database.Database): void {
|
||||
handle.exec(
|
||||
`INSERT INTO beta_scripts (beta_id, script_id, script_version_id)
|
||||
@@ -144,9 +143,11 @@ function backfillMultiScriptJoins(handle: Database.Database): void {
|
||||
WHERE b.script_id IS NOT NULL
|
||||
AND bs.server_deleted_at IS NULL
|
||||
AND EXISTS (SELECT 1 FROM servers WHERE name = bs.server)
|
||||
AND (SELECT COUNT(*) FROM beta_scripts x WHERE x.beta_id = b.id) = 1
|
||||
AND EXISTS (SELECT 1 FROM beta_scripts x WHERE x.beta_id = b.id AND x.script_id = b.script_id)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM beta_server_scripts x
|
||||
WHERE x.beta_id = bs.beta_id AND x.server = bs.server AND x.script_id = b.script_id
|
||||
WHERE x.beta_id = bs.beta_id AND x.server = bs.server
|
||||
)`
|
||||
);
|
||||
handle.exec(
|
||||
|
||||
Reference in New Issue
Block a user