Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).

knotserver: add ability to run migrations on knots

Signed-off-by: oppiliappan <me@oppi.li>

authored by oppi.li and committed by

Tangled 6870bf54 f220cd3e

+11 -4
+11 -4
knotserver/db/db.go
··· 32 32 return nil, err 33 33 } 34 34 35 - // NOTE: If any other migration is added here, you MUST 36 - // copy the pattern in appview: use a single sql.Conn 37 - // for every migration. 35 + conn, err := db.Conn(ctx) 36 + if err != nil { 37 + return nil, err 38 + } 39 + defer conn.Close() 38 40 39 - _, err = db.Exec(` 41 + _, err = conn.ExecContext(ctx, ` 40 42 create table if not exists known_dids ( 41 43 did text primary key 42 44 ); ··· 63 61 event text not null, -- json 64 62 created integer not null default (strftime('%s', 'now')), 65 63 primary key (rkey, nsid) 64 + ); 65 + 66 + create table if not exists migrations ( 67 + id integer primary key autoincrement, 68 + name text unique 66 69 ); 67 70 `) 68 71 if err != nil {