mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-02-08 21:30:08 +00:00
migrations for repo_rev tracking and backlinks table
This commit is contained in:
8
migrations/20260107_add_repo_rev_to_user_blocks.sql
Normal file
8
migrations/20260107_add_repo_rev_to_user_blocks.sql
Normal 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);
|
||||
10
migrations/20260114_backlinks.sql
Normal file
10
migrations/20260114_backlinks.sql
Normal 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);
|
||||
Reference in New Issue
Block a user