Skip to content

Commit a514dbe

Browse files
authored
Added database migrations for blocks table (#548)
Added database migrations for `blocks` table ref https://linear.app/ghost/issue/AP-1082 Added a database table that will store a record of an account block. We will later query this table to determine if an account has blocked another account / is being blocked by another account
1 parent 442e975 commit a514dbe

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE IF EXISTS blocks;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE blocks (
2+
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
3+
created_at TIMESTAMP(6) NULL DEFAULT CURRENT_TIMESTAMP(6),
4+
5+
blocker_id INT UNSIGNED NOT NULL,
6+
blocked_id INT UNSIGNED NOT NULL,
7+
8+
UNIQUE KEY unique_blocker_blocked (blocker_id, blocked_id),
9+
10+
FOREIGN KEY (blocker_id) REFERENCES accounts(id) ON DELETE CASCADE ON UPDATE CASCADE,
11+
FOREIGN KEY (blocked_id) REFERENCES accounts(id) ON DELETE CASCADE ON UPDATE CASCADE,
12+
13+
KEY idx_blocks_blocked_id_blocker_id (blocked_id, blocker_id)
14+
);

0 commit comments

Comments
 (0)