···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 {
···1514150115151502 drop table vouches;
15161503 alter table vouches_new rename to vouches;
15041504+ `)
15051505+ return err
15061506+ })
15071507+ conn.ExecContext(ctx, "pragma foreign_keys = on;")
15081508+15091509+ orm.RunMigration(conn, logger, "add-repo-renames", func(tx *sql.Tx) error {
15101510+ res, err := tx.Exec(`
15111511+ update repos
15121512+ set name = name || '-renamed-' || id || '-' || lower(hex(randomblob(4)))
15131513+ where id in (
15141514+ select id from (
15151515+ select id, row_number() over (
15161516+ partition by did, knot, name
15171517+ order by created desc, id desc
15181518+ ) as rn
15191519+ from repos
15201520+ ) where rn > 1
15211521+ );
15221522+ `)
15231523+ if err != nil {
15241524+ return err
15251525+ }
15261526+ if n, _ := res.RowsAffected(); n > 0 {
15271527+ logger.Warn("suffixed legacy duplicate repo names before adding unique index", "rows", n)
15281528+ }
15291529+15301530+ var remaining int
15311531+ if err := tx.QueryRow(`
15321532+ select count(*) from (
15331533+ select 1 from repos group by did, knot, name having count(*) > 1
15341534+ )
15351535+ `).Scan(&remaining); err != nil {
15361536+ return fmt.Errorf("checking for residual duplicate (did, knot, name) groups: %w", err)
15371537+ }
15381538+ if remaining > 0 {
15391539+ 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)
15401540+ }
15411541+15421542+ _, err = tx.Exec(`
15431543+ create table if not exists repo_renames (
15441544+ owner_did text not null,
15451545+ old_rkey text not null,
15461546+ repo_did text not null,
15471547+ renamed_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
15481548+ primary key (owner_did, old_rkey)
15491549+ );
15501550+ create unique index if not exists idx_repos_owner_knot_name
15511551+ on repos(did, knot, name);
15521552+ `)
15531553+ return err
15541554+ })
15551555+15561556+ orm.RunMigration(conn, logger, "repos-canonical-rkey-uniqueness", func(tx *sql.Tx) error {
15571557+ _, err := tx.Exec(`
15581558+ drop index if exists idx_repos_owner_knot_name;
15591559+ create unique index if not exists idx_repos_did_rkey
15601560+ on repos(did, rkey);
15611561+ `)
15621562+ return err
15631563+ })
15641564+15651565+ orm.RunMigration(conn, logger, "repo-did-references", func(tx *sql.Tx) error {
15661566+ tables := []struct{ table, oldCol, newCol string }{
15671567+ {"issues", "repo_at", "repo_did"},
15681568+ {"pulls", "repo_at", "repo_did"},
15691569+ {"pull_comments", "repo_at", "repo_did"},
15701570+ {"stars", "subject_at", "subject_did"},
15711571+ {"artifacts", "repo_at", "repo_did"},
15721572+ {"webhooks", "repo_at", "repo_did"},
15731573+ {"repo_sites", "repo_at", "repo_did"},
15741574+ {"site_deploys", "repo_at", "repo_did"},
15751575+ {"collaborators", "repo_at", "repo_did"},
15761576+ {"repo_issue_seqs", "repo_at", "repo_did"},
15771577+ {"repo_pull_seqs", "repo_at", "repo_did"},
15781578+ {"repo_languages", "repo_at", "repo_did"},
15791579+ {"repo_labels", "repo_at", "repo_did"},
15801580+ }
15811581+15821582+ stmts := ""
15831583+ for _, t := range tables {
15841584+ stmts += fmt.Sprintf(
15851585+ `ALTER TABLE %s ADD COLUMN %s TEXT;
15861586+ UPDATE %s SET %s = (SELECT repos.repo_did FROM repos WHERE repos.at_uri = %s.%s);
15871587+ CREATE INDEX IF NOT EXISTS idx_%s_%s ON %s(%s);
15881588+ `, t.table, t.newCol, t.table, t.newCol, t.table, t.oldCol, t.table, t.newCol, t.table, t.newCol)
15891589+ }
15901590+15911591+ stmts += `ALTER TABLE pulls ADD COLUMN source_repo_did TEXT;
15921592+ UPDATE pulls SET source_repo_did = (SELECT repos.repo_did FROM repos WHERE repos.at_uri = pulls.source_repo_at);
15931593+15941594+ UPDATE profile_pinned_repositories SET pin = (
15951595+ SELECT repos.repo_did FROM repos WHERE repos.at_uri = profile_pinned_repositories.pin
15961596+ ) WHERE pin LIKE 'at://%'
15971597+ 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 != '');
15981598+ `
15991599+16001600+ _, err := tx.Exec(stmts)
16011601+ return err
16021602+ })
16031603+16041604+ orm.RunMigration(conn, logger, "backfill-pds-rewrites-star-issue-pull-collab", func(tx *sql.Tx) error {
16051605+ type source struct {
16061606+ userDidCol string
16071607+ table string
16081608+ nsid string
16091609+ fkCol string
16101610+ }
16111611+ sources := []source{
16121612+ {"did", "stars", "sh.tangled.feed.star", "subject_at"},
16131613+ {"did", "issues", "sh.tangled.repo.issue", "repo_at"},
16141614+ {"owner_did", "pulls", "sh.tangled.repo.pull", "repo_at"},
16151615+ {"did", "collaborators", "sh.tangled.repo.collaborator", "repo_at"},
16161616+ }
16171617+16181618+ for _, src := range sources {
16191619+ _, err := tx.Exec(fmt.Sprintf(`
16201620+ INSERT INTO pds_migration (name, did, collection, rkey, status)
16211621+ SELECT 'add-repo-did', t.%s, '%s', t.rkey, 'pending'
16221622+ FROM %s t
16231623+ JOIN repos r ON r.at_uri = t.%s
16241624+ WHERE r.repo_did IS NOT NULL AND r.repo_did != ''
16251625+ ON CONFLICT(name, did, collection, rkey) DO NOTHING
16261626+ `, src.userDidCol, src.nsid, src.table, src.fkCol))
16271627+ if err != nil {
16281628+ return fmt.Errorf("backfill pds rewrites for %s: %w", src.table, err)
16291629+ }
16301630+ }
16311631+16321632+ return nil
16331633+ })
16341634+16351635+ orm.RunMigration(conn, logger, "backfill-pds-rewrites-profiles", func(tx *sql.Tx) error {
16361636+ _, err := tx.Exec(`
16371637+ INSERT INTO pds_migration (name, did, collection, rkey, status)
16381638+ SELECT DISTINCT 'add-repo-did', pp.did, 'sh.tangled.actor.profile', 'self', 'pending'
16391639+ FROM profile_pinned_repositories pp
16401640+ JOIN repos r ON r.at_uri = pp.pin
16411641+ WHERE pp.pin LIKE 'at://%'
16421642+ AND r.repo_did IS NOT NULL AND r.repo_did != ''
16431643+ ON CONFLICT(name, did, collection, rkey) DO NOTHING
16441644+ `)
16451645+ if err != nil {
16461646+ return fmt.Errorf("backfill pds rewrites for profiles: %w", err)
16471647+ }
16481648+ return nil
16491649+ })
16501650+16511651+ conn.ExecContext(ctx, "pragma foreign_keys = off;")
16521652+ orm.RunMigration(conn, logger, "drop-old-at-uri-columns", func(tx *sql.Tx) error {
16531653+ _, err := tx.Exec(`
16541654+ CREATE TABLE repos_new (
16551655+ id INTEGER PRIMARY KEY AUTOINCREMENT,
16561656+ did TEXT NOT NULL,
16571657+ name TEXT NOT NULL,
16581658+ knot TEXT NOT NULL,
16591659+ rkey TEXT NOT NULL,
16601660+ at_uri TEXT NOT NULL UNIQUE,
16611661+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
16621662+ description TEXT CHECK (length(description) <= 200),
16631663+ source TEXT,
16641664+ spindle TEXT,
16651665+ website TEXT,
16661666+ topics TEXT,
16671667+ repo_did TEXT,
16681668+ UNIQUE(did, rkey)
16691669+ );
16701670+ INSERT INTO repos_new (id, did, name, knot, rkey, at_uri, created, description, source, spindle, website, topics, repo_did)
16711671+ SELECT id, did, name, knot, rkey, at_uri, created, description, source, spindle, website, topics, repo_did
16721672+ FROM repos;
16731673+ DROP TABLE repos;
16741674+ ALTER TABLE repos_new RENAME TO repos;
16751675+ CREATE UNIQUE INDEX idx_repos_repo_did ON repos(repo_did);
16761676+ CREATE UNIQUE INDEX idx_repos_did_rkey ON repos(did, rkey);
16771677+16781678+ CREATE TABLE issues_new (
16791679+ id INTEGER PRIMARY KEY AUTOINCREMENT,
16801680+ did TEXT NOT NULL,
16811681+ rkey TEXT NOT NULL,
16821682+ at_uri TEXT GENERATED ALWAYS AS ('at://' || did || '/' || 'sh.tangled.repo.issue' || '/' || rkey) STORED,
16831683+ repo_did TEXT NOT NULL,
16841684+ issue_id INTEGER NOT NULL,
16851685+ title TEXT NOT NULL,
16861686+ body TEXT NOT NULL,
16871687+ open INTEGER NOT NULL DEFAULT 1,
16881688+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
16891689+ edited TEXT,
16901690+ deleted TEXT,
16911691+ UNIQUE(did, rkey),
16921692+ UNIQUE(repo_did, issue_id),
16931693+ UNIQUE(at_uri),
16941694+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
16951695+ );
16961696+ INSERT INTO issues_new (id, did, rkey, repo_did, issue_id, title, body, open, created, edited, deleted)
16971697+ SELECT id, did, rkey, repo_did, issue_id, title, body, open, created, edited, deleted
16981698+ FROM issues WHERE repo_did IS NOT NULL AND repo_did != '';
16991699+ DROP TABLE issues;
17001700+ ALTER TABLE issues_new RENAME TO issues;
17011701+ CREATE INDEX idx_issues_repo_did ON issues(repo_did);
17021702+17031703+ CREATE TABLE pulls_new (
17041704+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17051705+ pull_id INTEGER NOT NULL,
17061706+ at_uri TEXT GENERATED ALWAYS AS ('at://' || owner_did || '/' || 'sh.tangled.repo.pull' || '/' || rkey) STORED,
17071707+ repo_did TEXT NOT NULL,
17081708+ owner_did TEXT NOT NULL,
17091709+ rkey TEXT NOT NULL,
17101710+ title TEXT NOT NULL,
17111711+ body TEXT NOT NULL,
17121712+ target_branch TEXT NOT NULL,
17131713+ state INTEGER NOT NULL DEFAULT 0 CHECK (state IN (0, 1, 2, 3)),
17141714+ source_branch TEXT,
17151715+ source_repo_did TEXT,
17161716+ change_id TEXT,
17171717+ dependent_on TEXT,
17181718+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17191719+ UNIQUE(repo_did, pull_id),
17201720+ UNIQUE(at_uri),
17211721+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
17221722+ );
17231723+ 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)
17241724+ SELECT id, pull_id, repo_did, owner_did, rkey, title, body, target_branch, state, source_branch, source_repo_did, change_id, dependent_on, created
17251725+ FROM pulls WHERE repo_did IS NOT NULL AND repo_did != '';
17261726+ DROP TABLE pulls;
17271727+ ALTER TABLE pulls_new RENAME TO pulls;
17281728+ CREATE INDEX idx_pulls_repo_did ON pulls(repo_did);
17291729+ CREATE INDEX idx_pulls_source_repo_did ON pulls(source_repo_did);
17301730+17311731+ CREATE TABLE pull_comments_new (
17321732+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17331733+ pull_id INTEGER NOT NULL,
17341734+ submission_id INTEGER NOT NULL,
17351735+ repo_did TEXT NOT NULL,
17361736+ owner_did TEXT NOT NULL,
17371737+ comment_at TEXT NOT NULL,
17381738+ body TEXT NOT NULL,
17391739+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17401740+ FOREIGN KEY (repo_did, pull_id) REFERENCES pulls(repo_did, pull_id) ON DELETE CASCADE,
17411741+ FOREIGN KEY (submission_id) REFERENCES pull_submissions(id) ON DELETE CASCADE
17421742+ );
17431743+ INSERT INTO pull_comments_new (id, pull_id, submission_id, repo_did, owner_did, comment_at, body, created)
17441744+ SELECT id, pull_id, submission_id, repo_did, owner_did, comment_at, body, created
17451745+ FROM pull_comments WHERE repo_did IS NOT NULL AND repo_did != '';
17461746+ DROP TABLE pull_comments;
17471747+ ALTER TABLE pull_comments_new RENAME TO pull_comments;
17481748+ CREATE INDEX idx_pull_comments_repo_did ON pull_comments(repo_did);
17491749+17501750+ CREATE TABLE stars_new (
17511751+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17521752+ did TEXT NOT NULL,
17531753+ rkey TEXT NOT NULL,
17541754+ subject_type TEXT NOT NULL CHECK (subject_type IN ('repo', 'string')),
17551755+ subject TEXT NOT NULL,
17561756+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17571757+ UNIQUE(did, rkey),
17581758+ UNIQUE(did, subject)
17591759+ );
17601760+ INSERT INTO stars_new (id, did, rkey, subject_type, subject, created)
17611761+ SELECT id, did, rkey, 'repo', subject_did, created
17621762+ FROM stars
17631763+ WHERE subject_did IS NOT NULL AND subject_did != '';
17641764+ INSERT OR IGNORE INTO stars_new (id, did, rkey, subject_type, subject, created)
17651765+ SELECT id, did, rkey, 'string', subject_at, created
17661766+ FROM stars
17671767+ WHERE (subject_did IS NULL OR subject_did = '')
17681768+ AND subject_at LIKE 'at://%/sh.tangled.string/%';
17691769+ DROP TABLE stars;
17701770+ ALTER TABLE stars_new RENAME TO stars;
17711771+ CREATE INDEX idx_stars_subject ON stars(subject);
17721772+ CREATE INDEX idx_stars_subject_type ON stars(subject_type);
17731773+ CREATE INDEX idx_stars_created ON stars(created);
17741774+17751775+ CREATE TABLE collaborators_new (
17761776+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17771777+ did TEXT NOT NULL,
17781778+ rkey TEXT,
17791779+ subject_did TEXT NOT NULL,
17801780+ repo_did TEXT NOT NULL,
17811781+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17821782+ UNIQUE(did, rkey),
17831783+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
17841784+ );
17851785+ INSERT INTO collaborators_new (id, did, rkey, subject_did, repo_did, created)
17861786+ SELECT id, did, NULLIF(rkey, ''), subject_did, repo_did, created
17871787+ FROM collaborators WHERE repo_did IS NOT NULL AND repo_did != '';
17881788+ DROP TABLE collaborators;
17891789+ ALTER TABLE collaborators_new RENAME TO collaborators;
17901790+ CREATE INDEX idx_collaborators_repo_did ON collaborators(repo_did);
17911791+17921792+ CREATE TABLE artifacts_new (
17931793+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17941794+ did TEXT NOT NULL,
17951795+ rkey TEXT NOT NULL,
17961796+ repo_did TEXT NOT NULL,
17971797+ tag BINARY(20) NOT NULL,
17981798+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
17991799+ blob_cid TEXT NOT NULL,
18001800+ name TEXT NOT NULL,
18011801+ size INTEGER NOT NULL DEFAULT 0,
18021802+ mimetype TEXT NOT NULL DEFAULT '*/*',
18031803+ UNIQUE(did, rkey),
18041804+ UNIQUE(repo_did, tag, name),
18051805+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18061806+ );
18071807+ INSERT INTO artifacts_new (id, did, rkey, repo_did, tag, created, blob_cid, name, size, mimetype)
18081808+ SELECT id, did, rkey, repo_did, tag, created, blob_cid, name, size, mimetype
18091809+ FROM artifacts WHERE repo_did IS NOT NULL AND repo_did != '';
18101810+ DROP TABLE artifacts;
18111811+ ALTER TABLE artifacts_new RENAME TO artifacts;
18121812+ CREATE INDEX idx_artifacts_repo_did ON artifacts(repo_did);
18131813+18141814+ CREATE TABLE webhooks_new (
18151815+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18161816+ repo_did TEXT NOT NULL,
18171817+ url TEXT NOT NULL,
18181818+ secret TEXT,
18191819+ active INTEGER NOT NULL DEFAULT 1,
18201820+ events TEXT NOT NULL,
18211821+ created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18221822+ updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18231823+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18241824+ );
18251825+ INSERT INTO webhooks_new (id, repo_did, url, secret, active, events, created_at, updated_at)
18261826+ SELECT id, repo_did, url, secret, active, events, created_at, updated_at
18271827+ FROM webhooks WHERE repo_did IS NOT NULL AND repo_did != '';
18281828+ DROP TABLE webhooks;
18291829+ ALTER TABLE webhooks_new RENAME TO webhooks;
18301830+ CREATE INDEX idx_webhooks_repo_did ON webhooks(repo_did);
18311831+18321832+ CREATE TABLE repo_sites_new (
18331833+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18341834+ repo_did TEXT NOT NULL UNIQUE,
18351835+ branch TEXT NOT NULL,
18361836+ dir TEXT NOT NULL DEFAULT '/',
18371837+ is_index INTEGER NOT NULL DEFAULT 0,
18381838+ created TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18391839+ updated TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18401840+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18411841+ );
18421842+ INSERT INTO repo_sites_new (id, repo_did, branch, dir, is_index, created, updated)
18431843+ SELECT id, repo_did, branch, dir, is_index, created, updated
18441844+ FROM repo_sites WHERE repo_did IS NOT NULL AND repo_did != '';
18451845+ DROP TABLE repo_sites;
18461846+ ALTER TABLE repo_sites_new RENAME TO repo_sites;
18471847+18481848+ CREATE TABLE site_deploys_new (
18491849+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18501850+ repo_did TEXT NOT NULL,
18511851+ branch TEXT NOT NULL,
18521852+ dir TEXT NOT NULL DEFAULT '/',
18531853+ commit_sha TEXT NOT NULL DEFAULT '',
18541854+ status TEXT NOT NULL CHECK (status IN ('success', 'failure')),
18551855+ trigger TEXT NOT NULL CHECK (trigger IN ('config_change', 'push')),
18561856+ error TEXT NOT NULL DEFAULT '',
18571857+ created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
18581858+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18591859+ );
18601860+ INSERT INTO site_deploys_new (id, repo_did, branch, dir, commit_sha, status, trigger, error, created_at)
18611861+ SELECT id, repo_did, branch, dir, commit_sha, status, trigger, error, created_at
18621862+ FROM site_deploys WHERE repo_did IS NOT NULL AND repo_did != '';
18631863+ DROP TABLE site_deploys;
18641864+ ALTER TABLE site_deploys_new RENAME TO site_deploys;
18651865+ CREATE INDEX idx_site_deploys_repo_did ON site_deploys(repo_did);
18661866+18671867+ CREATE TABLE repo_issue_seqs_new (
18681868+ repo_did TEXT PRIMARY KEY,
18691869+ next_issue_id INTEGER NOT NULL DEFAULT 1,
18701870+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18711871+ );
18721872+ INSERT INTO repo_issue_seqs_new (repo_did, next_issue_id)
18731873+ SELECT repo_did, next_issue_id
18741874+ FROM repo_issue_seqs WHERE repo_did IS NOT NULL AND repo_did != '';
18751875+ DROP TABLE repo_issue_seqs;
18761876+ ALTER TABLE repo_issue_seqs_new RENAME TO repo_issue_seqs;
18771877+18781878+ CREATE TABLE repo_pull_seqs_new (
18791879+ repo_did TEXT PRIMARY KEY,
18801880+ next_pull_id INTEGER NOT NULL DEFAULT 1,
18811881+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18821882+ );
18831883+ INSERT INTO repo_pull_seqs_new (repo_did, next_pull_id)
18841884+ SELECT repo_did, next_pull_id
18851885+ FROM repo_pull_seqs WHERE repo_did IS NOT NULL AND repo_did != '';
18861886+ DROP TABLE repo_pull_seqs;
18871887+ ALTER TABLE repo_pull_seqs_new RENAME TO repo_pull_seqs;
18881888+18891889+ CREATE TABLE repo_languages_new (
18901890+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18911891+ repo_did TEXT NOT NULL,
18921892+ ref TEXT NOT NULL,
18931893+ is_default_ref INTEGER NOT NULL DEFAULT 0,
18941894+ language TEXT NOT NULL,
18951895+ bytes INTEGER NOT NULL CHECK (bytes >= 0),
18961896+ UNIQUE(repo_did, ref, language),
18971897+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
18981898+ );
18991899+ INSERT INTO repo_languages_new (id, repo_did, ref, is_default_ref, language, bytes)
19001900+ SELECT id, repo_did, ref, is_default_ref, language, bytes
19011901+ FROM repo_languages WHERE repo_did IS NOT NULL AND repo_did != '';
19021902+ DROP TABLE repo_languages;
19031903+ ALTER TABLE repo_languages_new RENAME TO repo_languages;
19041904+19051905+ CREATE TABLE repo_labels_new (
19061906+ id INTEGER PRIMARY KEY AUTOINCREMENT,
19071907+ repo_did TEXT NOT NULL,
19081908+ label_at TEXT NOT NULL,
19091909+ UNIQUE(repo_did, label_at),
19101910+ FOREIGN KEY (repo_did) REFERENCES repos(repo_did) ON DELETE CASCADE
19111911+ );
19121912+ INSERT INTO repo_labels_new (id, repo_did, label_at)
19131913+ SELECT id, repo_did, label_at
19141914+ FROM repo_labels WHERE repo_did IS NOT NULL AND repo_did != '';
19151915+ DROP TABLE repo_labels;
19161916+ ALTER TABLE repo_labels_new RENAME TO repo_labels;
15171917 `)
15181918 return err
15191919 })
+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