Separate staged command payloads from provisioning state
This commit is contained in:
@@ -122,6 +122,15 @@ export function ensureHostSchema(handle: Database.Database): void {
|
||||
CREATE INDEX IF NOT EXISTS ec_host_operations_important_history ON ec_host_operations(created_at)
|
||||
WHERE ${importantOperationSql.replaceAll('o.', '')}`);
|
||||
handle.exec('CREATE TABLE IF NOT EXISTS ec_host_schema_migrations (name TEXT PRIMARY KEY)');
|
||||
if (!handle.prepare('SELECT 1 FROM ec_host_schema_migrations WHERE name=?').get('staged-operation-payloads')) {
|
||||
handle.transaction(() => {
|
||||
handle.exec(`INSERT OR IGNORE INTO ec_host_operation_payloads(operation_id,payload)
|
||||
SELECT id,payload FROM ec_host_operations WHERE kind='files.stage' AND json_type(payload,'$.files')='array';
|
||||
UPDATE ec_host_operations SET payload=json_object('stageId',json_extract(payload,'$.stageId'))
|
||||
WHERE kind='files.stage' AND json_type(payload,'$.files')='array';`);
|
||||
handle.prepare('INSERT INTO ec_host_schema_migrations(name) VALUES(?)').run('staged-operation-payloads');
|
||||
})();
|
||||
}
|
||||
if (!handle.prepare('SELECT 1 FROM ec_host_schema_migrations WHERE name=?').get('completed-status-batches')) {
|
||||
handle.transaction(() => {
|
||||
// Reclassify existing completed batches without discarding their per-server replies.
|
||||
|
||||
Reference in New Issue
Block a user