nyanoblog/migrations/20221207230140_create_follows.sql
2022-12-25 15:57:33 +01:00

10 lines
418 B
SQL

CREATE TABLE follows (
id BIGSERIAL PRIMARY KEY,
iri VARCHAR,
follower_id BIGINT REFERENCES accounts (id) ON DELETE CASCADE,
followee_id BIGINT REFERENCES accounts (id) ON DELETE CASCADE,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX index_follows_on_iri ON follows(iri);
CREATE UNIQUE INDEX index_follows_on_follower_id_and_followee_id ON follows (follower_id, followee_id);