mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-23 03:18:09 +08:00
feat(ql3): atomically withdraw quarantined automation
This commit is contained in:
@@ -98,6 +98,8 @@ import { local0085PluginPackageWorkflowRunListIndexMigration } from '../migratio
|
||||
import { local0086CapabilityV43Migration } from '../migrations/0086-capability-v43';
|
||||
import { local0087RunAttemptLogRetentionMigration } from '../migrations/0087-run-attempt-log-retention';
|
||||
import { local0088CapabilityV44Migration } from '../migrations/0088-capability-v44';
|
||||
import { local0089PluginPackageAutomationDispositionEventsMigration } from '../migrations/0089-plugin-package-automation-disposition-events';
|
||||
import { local0090CapabilityV45Migration } from '../migrations/0090-capability-v45';
|
||||
import type { LocalSqliteMigrationContext } from '../migrations/sqlMigration';
|
||||
import {
|
||||
LOCAL_SQLITE_MIGRATION_STREAM_ID,
|
||||
@@ -208,6 +210,8 @@ export const localSqliteMigrationDefinition: MigrationStreamDefinition<LocalSqli
|
||||
local0086CapabilityV43Migration,
|
||||
local0087RunAttemptLogRetentionMigration,
|
||||
local0088CapabilityV44Migration,
|
||||
local0089PluginPackageAutomationDispositionEventsMigration,
|
||||
local0090CapabilityV45Migration,
|
||||
]),
|
||||
});
|
||||
|
||||
|
||||
@@ -452,5 +452,15 @@ export const localSqliteMigrationManifest: MigrationStreamManifest =
|
||||
checksum:
|
||||
'c47a61b140b54d448c30ce7d5f7927c0d16fb897ab36dbe1d6010da2c39075a7',
|
||||
}),
|
||||
Object.freeze({
|
||||
id: '0089-plugin-package-automation-disposition-events',
|
||||
checksum:
|
||||
'3eaff9c7621fc4a69a7605fd7de29d38dfde856df13b5e467ccc2bf1245e21aa',
|
||||
}),
|
||||
Object.freeze({
|
||||
id: '0090-capability-v45',
|
||||
checksum:
|
||||
'1919987d29ef581e150116c590f1dc98f5d327791fc6425d5f1a27b8f6de5475',
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
@@ -70,9 +70,7 @@ CREATE TABLE IF NOT EXISTS "QingLong3SchemaMigrations" (
|
||||
).map(record);
|
||||
}
|
||||
|
||||
async findById(
|
||||
migrationId: string,
|
||||
): Promise<MigrationStreamRecord | null> {
|
||||
async findById(migrationId: string): Promise<MigrationStreamRecord | null> {
|
||||
const row = this.client
|
||||
.prepare(
|
||||
`SELECT migration_id, stream_id, dialect, checksum, applied_at_ms
|
||||
@@ -88,6 +86,11 @@ CREATE TABLE IF NOT EXISTS "QingLong3SchemaMigrations" (
|
||||
transaction: MigrationStreamTransaction<LocalSqliteMigrationContext>,
|
||||
) => Promise<T>,
|
||||
): Promise<T> {
|
||||
const foreignKeys = this.client.prepare('PRAGMA foreign_keys').get() as
|
||||
| { foreign_keys?: unknown }
|
||||
| undefined;
|
||||
const restoreForeignKeys = foreignKeys?.foreign_keys === 1;
|
||||
if (restoreForeignKeys) this.client.exec('PRAGMA foreign_keys = OFF');
|
||||
this.client.exec('BEGIN IMMEDIATE');
|
||||
try {
|
||||
const result = await work({
|
||||
@@ -116,9 +119,11 @@ CREATE TABLE IF NOT EXISTS "QingLong3SchemaMigrations" (
|
||||
},
|
||||
});
|
||||
this.client.exec('COMMIT');
|
||||
if (restoreForeignKeys) this.client.exec('PRAGMA foreign_keys = ON');
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (this.client.isTransaction) this.client.exec('ROLLBACK');
|
||||
if (restoreForeignKeys) this.client.exec('PRAGMA foreign_keys = ON');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user