diff options
Diffstat (limited to 'src/main/db/index.ts')
| -rw-r--r-- | src/main/db/index.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/db/index.ts b/src/main/db/index.ts index a77cdd4..1613abc 100644 --- a/src/main/db/index.ts +++ b/src/main/db/index.ts | |||
| @@ -20,9 +20,19 @@ export function getDb(): Database.Database { | |||
| 20 | db.pragma("foreign_keys = ON"); | 20 | db.pragma("foreign_keys = ON"); |
| 21 | 21 | ||
| 22 | initSchema(db); | 22 | initSchema(db); |
| 23 | runMigrations(db); | ||
| 24 | |||
| 23 | return db; | 25 | return db; |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 28 | function runMigrations(db: Database.Database): void { | ||
| 29 | // v2: add git_branch column to sessions | ||
| 30 | const cols = db.pragma("table_info(sessions)") as { name: string }[]; | ||
| 31 | if (!cols.find((c) => c.name === "git_branch")) { | ||
| 32 | db.exec("ALTER TABLE sessions ADD COLUMN git_branch TEXT"); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 26 | export function closeDb() { | 36 | export function closeDb() { |
| 27 | if (db) { | 37 | if (db) { |
| 28 | db.close(); | 38 | db.close(); |
