···33import (
44 "context"
55 "database/sql"
66+ "fmt"
67 "log/slog"
78 "strings"
89···115116 issue_at text,
116117 unique(repo_at, issue_id),
117118 foreign key (repo_at) references repos(at_uri) on delete cascade
118118- );
119119- create table if not exists comments (
120120- id integer primary key autoincrement,
121121- owner_did text not null,
122122- issue_id integer not null,
123123- repo_at text not null,
124124- comment_id integer not null,
125125- comment_at text not null,
126126- body text not null,
127127- created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
128128- unique(issue_id, comment_id),
129129- foreign key (repo_at, issue_id) references issues(repo_at, issue_id) on delete cascade
130119 );
131120 create table if not exists pulls (
132121 -- identifiers
···693682 create index if not exists idx_notifications_recipient_read on notifications(recipient_did, read);
694683 create index if not exists idx_references_from_at on reference_links(from_at);
695684 create index if not exists idx_references_to_at on reference_links(to_at);
696696- create index if not exists idx_webhooks_repo_at on webhooks(repo_at);
697685 create index if not exists idx_webhook_deliveries_webhook_id on webhook_deliveries(webhook_id);
698698- create index if not exists idx_site_deploys_repo_at on site_deploys(repo_at);
699686 create index if not exists idx_newsletter_prefs_user_did on newsletter_preferences(user_did);
700687 `)
701688 if err != nil {
···1544153115451532 drop table pipeline_statuses;
15461533 alter table pipeline_statuses_new rename to pipeline_statuses;
15341534+ `)
15351535+ return err
15361536+ })
15371537+ conn.ExecContext(ctx, "pragma foreign_keys = on;")
15381538+15391539+ orm.RunMigration(conn, logger, "add-repo-renames", func(tx *sql.Tx) error {
15401540+ res, err := tx.Exec(`
15411541+ update repos
15421542+ set name = name || '-renamed-' || id || '-' || lower(hex(randomblob(4)))
15431543+ where id in (
15441544+ select id from (
15451545+ select id, row_number() over (
15461546+ partition by did, knot, name
15471547+ order by created desc, id desc
15481548+ ) as rn
15491549+ from repos
15501550+ ) where rn > 1
15511551+ );
15521552+ `)
15531553+ if err != nil {
15541554+ return err
15551555+ }
15561556+ if n, _ := res.RowsAffected(); n > 0 {
15571557+ logger.Warn("suffixed legacy duplicate repo names before adding unique index", "rows", n)
15581558+ }
15591559+15601560+ var remaining int
15611561+ if err := tx.QueryRow(`
15621562+ select count(*) from (
15631563+ select 1 from repos group by did, knot, name having count(*) > 1
15641564+ )
15651565+ `).Scan(&remaining); err != nil {
15661566+ return fmt.Errorf("checking for residual duplicate (did, knot, name) groups: %w", err)
15671567+ }
15681568+ if remaining > 0 {
15691569+ return fmt.Errorf("add-repo-renames: %d duplicate (did, knot, name) groups remain after suffix pass; manual cleanup required before unique index can be created", remaining)
15701570+ }
15711571+15721572+ _, err = tx.Exec(`
15731573+ create table if not exists repo_renames (
15741574+ owner_did text not null,
15751575+ old_rkey text not null,
15761576+ repo_did text not null,
15771577+ renamed_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
15781578+ primary key (owner_did, old_rkey)
15791579+ );
15801580+ create unique index if not exists idx_repos_owner_knot_name
15811581+ on repos(did, knot, name);
15821582+ `)
15831583+ return err
15841584+ })
15851585+15861586+ orm.RunMigration(conn, logger, "repos-canonical-rkey-uniqueness", func(tx *sql.Tx) error {
15871587+ _, err := tx.Exec(`
15881588+ drop index if exists idx_repos_owner_knot_name;
15891589+ create unique index if not exists idx_repos_did_rkey
15901590+ on repos(did, rkey);
15911591+ `)
15921592+ return err
15931593+ })
15941594+15951595+ orm.RunMigration(conn, logger, "repo-did-references", func(tx *sql.Tx) error {
15961596+ tables := []struct{ table, oldCol, newCol string }{
15971597+ {"issues", "repo_at", "repo_did"},
15981598+ {"pulls", "repo_at", "repo_did"},
15991599+ {"pull_comments", "repo_at", "repo_did"},
16001600+ {"stars", "subject_at", "subject_did"},
16011601+ {"artifacts", "repo_at", "repo_did"},
16021602+ {"webhooks", "repo_at", "repo_did"},
16031603+ {"repo_sites", "repo_at", "repo_did"},
16041604+ {"site_deploys", "repo_at", "repo_did"},
16051605+ {"collaborators", "repo_at", "repo_did"},
16061606+ {"repo_issue_seqs", "repo_at", "repo_did"},
16071607+ {"repo_pull_seqs", "repo_at", "repo_did"},
16081608+ {"repo_languages", "repo_at", "repo_did"},
16091609+ {"repo_labels", "repo_at", "repo_did"},
16101610+ }
16111611+16121612+ stmts := ""
16131613+ for _, t := range tables {
16141614+ stmts += fmt.Sprintf(
16151615+ `ALTER TABLE %s ADD COLUMN %s TEXT;
16161616+ UPDATE %s SET %s = (SELECT repos.repo_did FROM repos WHERE repos.at_uri = %s.%s);
16171617+ CREATE INDEX IF NOT EXISTS idx_%s_%s ON %s(%s);
16181618+ `, t.table, t.newCol, t.table, t.newCol, t.table, t.oldCol, t.table, t.newCol, t.table, t.newCol)
16191619+ }
16201620+16211621+ stmts += `ALTER TABLE pulls ADD COLUMN source_repo_did TEXT;
16221622+ UPDATE pulls SET source_repo_did = (SELECT repos.repo_did FROM repos WHERE repos.at_uri = pulls.source_repo_at);
16231623+16241624+ UPDATE profile_pinned_repositories SET pin = (
16251625+ SELECT repos.repo_did FROM repos WHERE repos.at_uri = profile_pinned_repositories.pin
16261626+ ) WHERE pin LIKE 'at://%'
16271627+ AND EXISTS (SELECT 1 FROM repos WHERE repos.at_uri = profile_pinned_repositories.pin AND repos.repo_did IS NOT NULL AND repos.repo_did != '');
16281628+ `
16291629+16301630+ _, err := tx.Exec(stmts)
16311631+ return err
16321632+ })
16331633+16341634+ orm.RunMigration(conn, logger, "backfill-pds-rewrites-star-issue-pull-collab", func(tx *sql.Tx) error {
16351635+ type source struct {
16361636+ userDidCol string
16371637+ table string
16381638+ nsid string
16391639+ fkCol string
16401640+ }
16411641+ sources := []source{
16421642+ {"did", "stars", "sh.tangled.feed.star", "subject_at"},
16431643+ {"did", "issues", "sh.tangled.repo.issue", "repo_at"},
16441644+ {"owner_did", "pulls", "sh.tangled.repo.pull", "repo_at"},
16451645+ {"did", "collaborators", "sh.tangled.repo.collaborator", "repo_at"},
16461646+ }
16471647+16481648+ for _, src := range sources {
16491649+ _, err := tx.Exec(fmt.Sprintf(`
16501650+ INSERT INTO pds_migration (name, did, collection, rkey, status)
16511651+ SELECT 'add-repo-did', t.%s, '%s', t.rkey, 'pending'
16521652+ FROM %s t
16531653+ JOIN repos r ON r.at_uri = t.%s
16541654+ WHERE r.repo_did IS NOT NULL AND r.repo_did != ''
16551655+ ON CONFLICT(name, did, collection, rkey) DO NOTHING
16561656+ `, src.userDidCol, src.nsid, src.table, src.fkCol))
16571657+ if err != nil {
16581658+ return fmt.Errorf("backfill pds rewrites for %s: %w", src.table, err)
16591659+ }
16601660+ }
16611661+16621662+ return nil
16631663+ })
16641664+16651665+ orm.RunMigration(conn, logger, "backfill-pds-rewrites-profiles", func(tx *sql.Tx) error {
16661666+ _, err := tx.Exec(`
16671667+ INSERT INTO pds_migration (name, did, collection, rkey, status)
16681668+ SELECT DISTINCT 'add-repo-did', pp.did, 'sh.tangled.actor.profile', 'self', 'pending'
16691669+ FROM profile_pinned_repositories pp
16701670+ JOIN repos r ON r.at_uri = pp.pin
16711671+ WHERE pp.pin LIKE 'at://%'
16721672+ AND r.repo_did IS NOT NULL AND r.repo_did != ''
16731673+ ON CONFLICT(name, did, collection, rkey) DO NOTHING
16741674+ `)
16751675+ if err != nil {
16761676+ return fmt.Errorf("backfill pds rewrites for profiles: %w", err)
16771677+ }
16781678+ return nil
16791679+ })
16801680+16811681+ conn.ExecContext(ctx, "pragma foreign_keys = off;")
16821682+ orm.RunMigration(conn, logger, "drop-old-at-uri-columns", func(tx *sql.Tx) error {
16831683+ _, err := tx.Exec(`
16841684+ CREATE TABLE repos_new (
16851685+ id INTEGER PRIMARY KEY AUTOINCREMENT,
16861686+ did TEXT NOT NULL,
16871687+ name TEXT NOT NULL,
16881688+ knot TEXT NOT NULL,
16891689+ rkey TEXT NOT NULL,
16901690+ at_uri TEXT NOT NULL UNIQUE,
16911691+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
16921692+ description TEXT CHECK (length(description) <= 200),
16931693+ source TEXT,
16941694+ spindle TEXT,
16951695+ website TEXT,
16961696+ topics TEXT,
16971697+ repo_did TEXT,
16981698+ UNIQUE(did, rkey)
16991699+ );
17001700+ INSERT INTO repos_new (id, did, name, knot, rkey, at_uri, created, description, source, spindle, website, topics, repo_did)
17011701+ SELECT id, did, name, knot, rkey, at_uri, created, description, source, spindle, website, topics, repo_did
17021702+ FROM repos;
17031703+ DROP TABLE repos;
17041704+ ALTER TABLE repos_new RENAME TO repos;
17051705+ CREATE UNIQUE INDEX idx_repos_repo_did ON repos(repo_did);
17061706+ CREATE UNIQUE INDEX idx_repos_did_rkey ON repos(did, rkey);
17071707+17081708+ CREATE TABLE issues_new (
17091709+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17101710+ did TEXT NOT NULL,
17111711+ rkey TEXT NOT NULL,
17121712+ at_uri TEXT GENERATED ALWAYS AS ('at://' || did || '/' || 'sh.tangled.repo.issue' || '/' || rkey) STORED,
17131713+ repo_did TEXT NOT NULL,
17141714+ issue_id INTEGER NOT NULL,
17151715+ title TEXT NOT NULL,
17161716+ body TEXT NOT NULL,
17171717+ open INTEGER NOT NULL DEFAULT 1,
17181718+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17191719+ edited TEXT,
17201720+ deleted TEXT,
17211721+ UNIQUE(did, rkey),
17221722+ UNIQUE(repo_did, issue_id),
17231723+ UNIQUE(at_uri),
17241724+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
17251725+ );
17261726+ INSERT INTO issues_new (id, did, rkey, repo_did, issue_id, title, body, open, created, edited, deleted)
17271727+ SELECT id, did, rkey, repo_did, issue_id, title, body, open, created, edited, deleted
17281728+ FROM issues WHERE repo_did IS NOT NULL AND repo_did != '';
17291729+ DROP TABLE issues;
17301730+ ALTER TABLE issues_new RENAME TO issues;
17311731+ CREATE INDEX idx_issues_repo_did ON issues(repo_did);
17321732+17331733+ CREATE TABLE pulls_new (
17341734+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17351735+ pull_id INTEGER NOT NULL,
17361736+ at_uri TEXT GENERATED ALWAYS AS ('at://' || owner_did || '/' || 'sh.tangled.repo.pull' || '/' || rkey) STORED,
17371737+ repo_did TEXT NOT NULL,
17381738+ owner_did TEXT NOT NULL,
17391739+ rkey TEXT NOT NULL,
17401740+ title TEXT NOT NULL,
17411741+ body TEXT NOT NULL,
17421742+ target_branch TEXT NOT NULL,
17431743+ state INTEGER NOT NULL DEFAULT 0 CHECK (state IN (0, 1, 2, 3)),
17441744+ source_branch TEXT,
17451745+ source_repo_did TEXT,
17461746+ change_id TEXT,
17471747+ dependent_on TEXT,
17481748+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17491749+ UNIQUE(repo_did, pull_id),
17501750+ UNIQUE(at_uri),
17511751+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
17521752+ );
17531753+ INSERT INTO pulls_new (id, pull_id, repo_did, owner_did, rkey, title, body, target_branch, state, source_branch, source_repo_did, change_id, dependent_on, created)
17541754+ SELECT id, pull_id, repo_did, owner_did, rkey, title, body, target_branch, state, source_branch, source_repo_did, change_id, dependent_on, created
17551755+ FROM pulls WHERE repo_did IS NOT NULL AND repo_did != '';
17561756+ DROP TABLE pulls;
17571757+ ALTER TABLE pulls_new RENAME TO pulls;
17581758+ CREATE INDEX idx_pulls_repo_did ON pulls(repo_did);
17591759+ CREATE INDEX idx_pulls_source_repo_did ON pulls(source_repo_did);
17601760+17611761+ CREATE TABLE pull_comments_new (
17621762+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17631763+ pull_id INTEGER NOT NULL,
17641764+ submission_id INTEGER NOT NULL,
17651765+ repo_did TEXT NOT NULL,
17661766+ owner_did TEXT NOT NULL,
17671767+ comment_at TEXT NOT NULL,
17681768+ body TEXT NOT NULL,
17691769+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17701770+ FOREIGN KEY (repo_did, pull_id) REFERENCES pulls(repo_did, pull_id) ON DELETE CASCADE,
17711771+ FOREIGN KEY (submission_id) REFERENCES pull_submissions(id) ON DELETE CASCADE
17721772+ );
17731773+ INSERT INTO pull_comments_new (id, pull_id, submission_id, repo_did, owner_did, comment_at, body, created)
17741774+ SELECT id, pull_id, submission_id, repo_did, owner_did, comment_at, body, created
17751775+ FROM pull_comments WHERE repo_did IS NOT NULL AND repo_did != '';
17761776+ DROP TABLE pull_comments;
17771777+ ALTER TABLE pull_comments_new RENAME TO pull_comments;
17781778+ CREATE INDEX idx_pull_comments_repo_did ON pull_comments(repo_did);
17791779+17801780+ CREATE TABLE stars_new (
17811781+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17821782+ did TEXT NOT NULL,
17831783+ rkey TEXT NOT NULL,
17841784+ subject_type TEXT NOT NULL CHECK (subject_type IN ('repo', 'string')),
17851785+ subject TEXT NOT NULL,
17861786+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17871787+ UNIQUE(did, rkey),
17881788+ UNIQUE(did, subject)
17891789+ );
17901790+ INSERT INTO stars_new (id, did, rkey, subject_type, subject, created)
17911791+ SELECT id, did, rkey, 'repo', subject_did, created
17921792+ FROM stars
17931793+ WHERE subject_did IS NOT NULL AND subject_did != '';
17941794+ INSERT OR IGNORE INTO stars_new (id, did, rkey, subject_type, subject, created)
17951795+ SELECT id, did, rkey, 'string', subject_at, created
17961796+ FROM stars
17971797+ WHERE (subject_did IS NULL OR subject_did = '')
17981798+ AND subject_at LIKE 'at://%/sh.tangled.string/%';
17991799+ DROP TABLE stars;
18001800+ ALTER TABLE stars_new RENAME TO stars;
18011801+ CREATE INDEX idx_stars_subject ON stars(subject);
18021802+ CREATE INDEX idx_stars_subject_type ON stars(subject_type);
18031803+ CREATE INDEX idx_stars_created ON stars(created);
18041804+18051805+ CREATE TABLE collaborators_new (
18061806+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18071807+ did TEXT NOT NULL,
18081808+ rkey TEXT,
18091809+ subject_did TEXT NOT NULL,
18101810+ repo_did TEXT NOT NULL,
18111811+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18121812+ UNIQUE(did, rkey),
18131813+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18141814+ );
18151815+ INSERT INTO collaborators_new (id, did, rkey, subject_did, repo_did, created)
18161816+ SELECT id, did, NULLIF(rkey, ''), subject_did, repo_did, created
18171817+ FROM collaborators WHERE repo_did IS NOT NULL AND repo_did != '';
18181818+ DROP TABLE collaborators;
18191819+ ALTER TABLE collaborators_new RENAME TO collaborators;
18201820+ CREATE INDEX idx_collaborators_repo_did ON collaborators(repo_did);
18211821+18221822+ CREATE TABLE artifacts_new (
18231823+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18241824+ did TEXT NOT NULL,
18251825+ rkey TEXT NOT NULL,
18261826+ repo_did TEXT NOT NULL,
18271827+ tag BINARY(20) NOT NULL,
18281828+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18291829+ blob_cid TEXT NOT NULL,
18301830+ name TEXT NOT NULL,
18311831+ size INTEGER NOT NULL DEFAULT 0,
18321832+ mimetype TEXT NOT NULL DEFAULT '*/*',
18331833+ UNIQUE(did, rkey),
18341834+ UNIQUE(repo_did, tag, name),
18351835+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18361836+ );
18371837+ INSERT INTO artifacts_new (id, did, rkey, repo_did, tag, created, blob_cid, name, size, mimetype)
18381838+ SELECT id, did, rkey, repo_did, tag, created, blob_cid, name, size, mimetype
18391839+ FROM artifacts WHERE repo_did IS NOT NULL AND repo_did != '';
18401840+ DROP TABLE artifacts;
18411841+ ALTER TABLE artifacts_new RENAME TO artifacts;
18421842+ CREATE INDEX idx_artifacts_repo_did ON artifacts(repo_did);
18431843+18441844+ CREATE TABLE webhooks_new (
18451845+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18461846+ repo_did TEXT NOT NULL,
18471847+ url TEXT NOT NULL,
18481848+ secret TEXT,
18491849+ active INTEGER NOT NULL DEFAULT 1,
18501850+ events TEXT NOT NULL,
18511851+ created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18521852+ updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18531853+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18541854+ );
18551855+ INSERT INTO webhooks_new (id, repo_did, url, secret, active, events, created_at, updated_at)
18561856+ SELECT id, repo_did, url, secret, active, events, created_at, updated_at
18571857+ FROM webhooks WHERE repo_did IS NOT NULL AND repo_did != '';
18581858+ DROP TABLE webhooks;
18591859+ ALTER TABLE webhooks_new RENAME TO webhooks;
18601860+ CREATE INDEX idx_webhooks_repo_did ON webhooks(repo_did);
18611861+18621862+ CREATE TABLE repo_sites_new (
18631863+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18641864+ repo_did TEXT NOT NULL UNIQUE,
18651865+ branch TEXT NOT NULL,
18661866+ dir TEXT NOT NULL DEFAULT '/',
18671867+ is_index INTEGER NOT NULL DEFAULT 0,
18681868+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18691869+ updated TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18701870+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18711871+ );
18721872+ INSERT INTO repo_sites_new (id, repo_did, branch, dir, is_index, created, updated)
18731873+ SELECT id, repo_did, branch, dir, is_index, created, updated
18741874+ FROM repo_sites WHERE repo_did IS NOT NULL AND repo_did != '';
18751875+ DROP TABLE repo_sites;
18761876+ ALTER TABLE repo_sites_new RENAME TO repo_sites;
18771877+18781878+ CREATE TABLE site_deploys_new (
18791879+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18801880+ repo_did TEXT NOT NULL,
18811881+ branch TEXT NOT NULL,
18821882+ dir TEXT NOT NULL DEFAULT '/',
18831883+ commit_sha TEXT NOT NULL DEFAULT '',
18841884+ status TEXT NOT NULL CHECK (status IN ('success', 'failure')),
18851885+ trigger TEXT NOT NULL CHECK (trigger IN ('config_change', 'push')),
18861886+ error TEXT NOT NULL DEFAULT '',
18871887+ created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18881888+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18891889+ );
18901890+ INSERT INTO site_deploys_new (id, repo_did, branch, dir, commit_sha, status, trigger, error, created_at)
18911891+ SELECT id, repo_did, branch, dir, commit_sha, status, trigger, error, created_at
18921892+ FROM site_deploys WHERE repo_did IS NOT NULL AND repo_did != '';
18931893+ DROP TABLE site_deploys;
18941894+ ALTER TABLE site_deploys_new RENAME TO site_deploys;
18951895+ CREATE INDEX idx_site_deploys_repo_did ON site_deploys(repo_did);
18961896+18971897+ CREATE TABLE repo_issue_seqs_new (
18981898+ repo_did TEXT PRIMARY KEY,
18991899+ next_issue_id INTEGER NOT NULL DEFAULT 1,
19001900+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
19011901+ );
19021902+ INSERT INTO repo_issue_seqs_new (repo_did, next_issue_id)
19031903+ SELECT repo_did, next_issue_id
19041904+ FROM repo_issue_seqs WHERE repo_did IS NOT NULL AND repo_did != '';
19051905+ DROP TABLE repo_issue_seqs;
19061906+ ALTER TABLE repo_issue_seqs_new RENAME TO repo_issue_seqs;
19071907+19081908+ CREATE TABLE repo_pull_seqs_new (
19091909+ repo_did TEXT PRIMARY KEY,
19101910+ next_pull_id INTEGER NOT NULL DEFAULT 1,
19111911+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
19121912+ );
19131913+ INSERT INTO repo_pull_seqs_new (repo_did, next_pull_id)
19141914+ SELECT repo_did, next_pull_id
19151915+ FROM repo_pull_seqs WHERE repo_did IS NOT NULL AND repo_did != '';
19161916+ DROP TABLE repo_pull_seqs;
19171917+ ALTER TABLE repo_pull_seqs_new RENAME TO repo_pull_seqs;
19181918+19191919+ CREATE TABLE repo_languages_new (
19201920+ id INTEGER PRIMARY KEY AUTOINCREMENT,
19211921+ repo_did TEXT NOT NULL,
19221922+ ref TEXT NOT NULL,
19231923+ is_default_ref INTEGER NOT NULL DEFAULT 0,
19241924+ language TEXT NOT NULL,
19251925+ bytes INTEGER NOT NULL CHECK (bytes >= 0),
19261926+ UNIQUE(repo_did, ref, language),
19271927+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
19281928+ );
19291929+ INSERT INTO repo_languages_new (id, repo_did, ref, is_default_ref, language, bytes)
19301930+ SELECT id, repo_did, ref, is_default_ref, language, bytes
19311931+ FROM repo_languages WHERE repo_did IS NOT NULL AND repo_did != '';
19321932+ DROP TABLE repo_languages;
19331933+ ALTER TABLE repo_languages_new RENAME TO repo_languages;
19341934+19351935+ CREATE TABLE repo_labels_new (
19361936+ id INTEGER PRIMARY KEY AUTOINCREMENT,
19371937+ repo_did TEXT NOT NULL,
19381938+ label_at TEXT NOT NULL,
19391939+ UNIQUE(repo_did, label_at),
19401940+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
19411941+ );
19421942+ INSERT INTO repo_labels_new (id, repo_did, label_at)
19431943+ SELECT id, repo_did, label_at
19441944+ FROM repo_labels WHERE repo_did IS NOT NULL AND repo_did != '';
19451945+ DROP TABLE repo_labels;
19461946+ ALTER TABLE repo_labels_new RENAME TO repo_labels;
15471947 `)
15481948 return err
15491949 })
+1-1
appview/models/artifact.go
···1515 Did string
1616 Rkey string
17171818- RepoAt syntax.ATURI
1818+ RepoDid syntax.DID
1919 Tag plumbing.Hash
2020 CreatedAt time.Time
2121
+1-1
appview/models/collaborator.go
···14141515 // content
1616 SubjectDid syntax.DID
1717- RepoAt syntax.ATURI
1717+ RepoDid syntax.DID
18181919 // meta
2020 Created time.Time