multi script beta
This commit is contained in:
@@ -207,7 +207,11 @@ export function deleteVersion(versionId: number): void {
|
||||
}
|
||||
|
||||
const beta = db()
|
||||
.prepare(`SELECT id FROM betas WHERE script_version_id = ? AND state = 'running'`)
|
||||
.prepare(
|
||||
`SELECT b.id FROM betas b
|
||||
JOIN beta_scripts bs ON bs.beta_id = b.id
|
||||
WHERE bs.script_version_id = ? AND b.state = 'running' LIMIT 1`
|
||||
)
|
||||
.get(versionId) as { id: number } | undefined;
|
||||
if (beta) throw new ScriptError(`beta ${beta.id} is still running against this version`, 'in-use-beta');
|
||||
|
||||
@@ -221,7 +225,11 @@ export function deleteScript(scriptId: number): void {
|
||||
throw new ScriptError('un-set scope before deleting a script', 'has-scope');
|
||||
}
|
||||
const beta = db()
|
||||
.prepare(`SELECT id FROM betas WHERE script_id = ? AND state = 'running'`)
|
||||
.prepare(
|
||||
`SELECT b.id FROM betas b
|
||||
JOIN beta_scripts bs ON bs.beta_id = b.id
|
||||
WHERE bs.script_id = ? AND b.state = 'running' LIMIT 1`
|
||||
)
|
||||
.get(scriptId) as { id: number } | undefined;
|
||||
if (beta) throw new ScriptError(`beta ${beta.id} is still running against this script`, 'has-active-beta');
|
||||
db().prepare('DELETE FROM scripts WHERE id = ?').run(scriptId);
|
||||
|
||||
Reference in New Issue
Block a user