···1717 }
18181919 _, err = db.Exec(`
2020- create table if not exists public_keys (
2121- id integer primary key autoincrement,
2222- did text not null,
2323- name text not null,
2424- key text not null,
2525- unique(did, name, key))
2626- `)
2020+ create table if not exists public_keys (
2121+ id integer primary key autoincrement,
2222+ did text not null,
2323+ name text not null,
2424+ key text not null,
2525+ unique(did, name, key)
2626+ );
2727+ create table if not exists repos (
2828+ id integer primary key autoincrement,
2929+ did text not null,
3030+ name text not null,
3131+ description text not null,
3232+ unique(did, name)
3333+ )
3434+ `)
2735 if err != nil {
2836 return nil, err
2937 }
+25
legit/db/repo.go
···11+package db
22+33+func (d *DB) AddRepo(did string, name string, description string) error {
44+ _, err := d.db.Exec("insert into repos (did, name, description) values (?, ?, ?)", did, name, description)
55+ if err != nil {
66+ return err
77+ }
88+ return nil
99+}
1010+1111+func (d *DB) RemoveRepo(did string) error {
1212+ _, err := d.db.Exec("delete from repos where did = ?", did)
1313+ if err != nil {
1414+ return err
1515+ }
1616+ return nil
1717+}
1818+1919+func (d *DB) UpdateRepo(did string, name string, description string) error {
2020+ _, err := d.db.Exec("update repos set name = ?, description = ? where did = ?", name, description, did)
2121+ if err != nil {
2222+ return err
2323+ }
2424+ return nil
2525+}