11 lines
437 B
MySQL
11 lines
437 B
MySQL
|
CREATE TABLE likes (
|
||
|
id BIGSERIAL PRIMARY KEY,
|
||
|
note_id BIGINT REFERENCES notes (id) ON DELETE CASCADE,
|
||
|
account_id BIGINT REFERENCES accounts (id) ON DELETE CASCADE,
|
||
|
created_at TIMESTAMP NOT NULL DEFAULT now()
|
||
|
);
|
||
|
|
||
|
CREATE INDEX index_likes_on_note_id ON likes (note_id);
|
||
|
CREATE INDEX index_likes_on_account_id ON likes (account_id);
|
||
|
CREATE UNIQUE INDEX index_likes_on_note_id_and_account_id ON likes (note_id, account_id);
|