migrations for repo_rev tracking and backlinks table

This commit is contained in:
lewis
2026-01-14 22:22:07 +02:00
parent 71d9ed7d38
commit 1a916aa30e
2 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
ALTER TABLE user_blocks ADD COLUMN IF NOT EXISTS repo_rev TEXT;
UPDATE user_blocks ub
SET repo_rev = r.repo_rev
FROM repos r
WHERE ub.user_id = r.user_id AND ub.repo_rev IS NULL;
CREATE INDEX IF NOT EXISTS idx_user_blocks_repo_rev ON user_blocks(user_id, repo_rev);

View File

@@ -0,0 +1,10 @@
CREATE TABLE backlinks (
uri TEXT NOT NULL,
path TEXT NOT NULL,
link_to TEXT NOT NULL,
repo_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
PRIMARY KEY (uri, path)
);
CREATE INDEX backlinks_path_link_to_idx ON backlinks(path, link_to);
CREATE INDEX backlinks_repo_id_idx ON backlinks(repo_id);