fix(ai): handle missing disabled column in auth schema V0-to-V1 migration (#387)

The migration unconditionally referenced a `disabled` column in the V0
table, but not all V0 schemas have it. Now checks via PRAGMA table_info
and falls back to NULL when the column is absent.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
brymko
2026-03-13 15:04:33 +01:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 2fcfc335dd
commit 9d44995b30
2 changed files with 8 additions and 1 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed auth schema V0-to-V1 migration crash when the V0 table lacks a `disabled` column
## [13.11.0] - 2026-03-12
### Added
+4 -1
View File
@@ -2291,6 +2291,9 @@ export class AuthCredentialStore {
#migrateAuthSchemaV0ToV1(): void {
const migrate = this.#db.transaction(() => {
const v0Cols = this.#db.prepare("PRAGMA table_info(auth_credentials)").all() as Array<{ name?: string }>;
const hasDisabled = v0Cols.some(col => col.name === "disabled");
this.#db.exec("ALTER TABLE auth_credentials RENAME TO auth_credentials_v0");
this.#db.exec(`
CREATE TABLE auth_credentials (
@@ -2310,7 +2313,7 @@ export class AuthCredentialStore {
provider,
credential_type,
data,
CASE WHEN disabled = 1 THEN 'disabled' ELSE NULL END,
${hasDisabled ? "CASE WHEN disabled = 1 THEN 'disabled' ELSE NULL END" : "NULL"},
created_at,
updated_at
FROM auth_credentials_v0