Fix scope restoration for promoted scripts

This commit is contained in:
2026-09-18 08:08:17 -04:00
parent 3c49437bf9
commit b2ec01daf5
4 changed files with 100 additions and 13 deletions
+2 -1
View File
@@ -23,6 +23,7 @@ import {
listPromotedOverlaysForScope,
listVersions,
serversMatchingScope,
setScope,
type ScopeType,
type ScriptRow,
type ScriptVersionRow
@@ -1089,6 +1090,7 @@ export function latestVersionForScript(script: ScriptRow): ScriptVersionRow | nu
export function unsetScopeAndDetach(scriptId: number): string[] {
const script = getScript(scriptId);
if (!script) throw new BetaError(`no such script (id=${scriptId})`, 'no-such-script');
setScope({ scriptId, scopeType: null, scopeValue: null });
const detached: string[] = [];
if (script.kind === 'script' || script.kind === 'plugin') {
@@ -1104,6 +1106,5 @@ export function unsetScopeAndDetach(scriptId: number): string[] {
detached.push(server);
}
}
db().prepare('UPDATE scripts SET scope_type = NULL, scope_value = NULL WHERE id = ?').run(scriptId);
return detached;
}