CREATE TABLE likes ( iri VARCHAR, 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(), CONSTRAINT likes_pkey PRIMARY KEY (note_id, account_id) ); CREATE UNIQUE INDEX index_likes_on_iri ON likes (iri);