diff options
| author | bndw <ben@bdw.to> | 2026-02-28 20:07:05 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-28 20:07:05 -0800 |
| commit | 9d192d16b7a4026b35ad2bcaff9edb9f2670de2b (patch) | |
| tree | 2603dd04c3567074e84be271c448ede02ee7097d /src/main/db/index.ts | |
| parent | 283013c09d4855529e846951a1e090f0f16030a8 (diff) | |
feat: git branches
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(); |
