favourited notes

This commit is contained in:
Mateusz Gruszczyński
2026-09-07 16:39:58 +02:00
parent 87b61d6088
commit f9cf17554a
25 changed files with 1534 additions and 22 deletions
+19
View File
@@ -0,0 +1,19 @@
CREATE TABLE user_pad_favorites (
user_id BIGINT NOT NULL,
pad_id BIGINT NOT NULL,
created_at VARCHAR(64) NOT NULL DEFAULT (CURRENT_TIMESTAMP),
PRIMARY KEY (user_id, pad_id),
CONSTRAINT fk_user_pad_favorites_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT fk_user_pad_favorites_pad FOREIGN KEY (pad_id) REFERENCES pads(id) ON DELETE CASCADE,
INDEX idx_user_pad_favorites_user_created (user_id, created_at)
) ENGINE=InnoDB;
CREATE TABLE user_note_favorites (
user_id BIGINT NOT NULL,
note_id BIGINT NOT NULL,
created_at VARCHAR(64) NOT NULL DEFAULT (CURRENT_TIMESTAMP),
PRIMARY KEY (user_id, note_id),
CONSTRAINT fk_user_note_favorites_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT fk_user_note_favorites_note FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE,
INDEX idx_user_note_favorites_user_created (user_id, created_at)
) ENGINE=InnoDB;