Created
August 30, 2018 08:44
-
-
Save filinvadim/4e170930e9f8dbd62647267f2bb607cf to your computer and use it in GitHub Desktop.
MtM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE user_friend ( | |
id BIGSERIAL NOT NULL, | |
user_id BIGINT NOT NULL, | |
friend_id BIGINT NOT NULL, | |
created_at TIMESTAMP(0) NOT NULL DEFAULT now(), | |
CONSTRAINT pk_user_friend_id PRIMARY KEY (id), | |
CONSTRAINT fk_user_friend_user_id FOREIGN KEY (user_id) REFERENCES "user" (id) ON DELETE CASCADE, | |
UNIQUE(user_id, friend_id), | |
CONSTRAINT not_equal_id CHECK (user_id != friend_id) | |
); | |
ALTER TABLE user_friend | |
owner TO app; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment