forked from tangled.org/core
Monorepo for Tangled

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

Changed files
+11 -4
knotserver
db
+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 ); ··· 61 63 event text not null, -- json 62 64 created integer not null default (strftime('%s', 'now')), 63 65 primary key (rkey, nsid) 66 + ); 67 + 68 + create table if not exists migrations ( 69 + id integer primary key autoincrement, 70 + name text unique 64 71 ); 65 72 `) 66 73 if err != nil {