mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
fix(snippets): repair missing note column on SQLite upgrades (#1541)
This commit is contained in:
1 parent
d3568e484d
commit
117e125d55
3 files changed
+78
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import type Database from "better-sqlite3";
|
||||
|
||||
/** Repair older SQLite tables before adoption, or after an incomplete 2.9 upgrade. */
|
||||
export function repairSnippetsNoteColumn(sqlite: Database.Database): void {
|
||||
for (const table of ["snippets", "p_snippets_snippets"]) {
|
||||
const columns = sqlite.pragma(`table_info("${table}")`) as Array<{
|
||||
name: string;
|
||||
}>;
|
||||
if (
|
||||
columns.length === 0 ||
|
||||
columns.some(({ name }) => name === "is_note")
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
sqlite.exec(
|
||||
`ALTER TABLE "${table}" ADD COLUMN "is_note" INTEGER NOT NULL DEFAULT 0`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user