Created
January 19, 2020 13:24
-
-
Save yutakahashi114/8e1af26fd43aa4b0537ce929d42e3888 to your computer and use it in GitHub Desktop.
This file contains 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 users( | |
id BIGSERIAL, | |
first_name VARCHAR(20) NOT NULL, | |
last_name VARCHAR(20) NOT NULL, | |
first_name_kana VARCHAR(20), | |
last_name_kana VARCHAR(20), | |
version BIGINT NOT NULL, | |
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
deleted_at TIMESTAMP, | |
PRIMARY KEY (id) | |
); | |
create table friends( | |
id BIGSERIAL, | |
user_id BIGINT NOT NULL, | |
friend_id BIGINT NOT NULL, | |
version BIGINT NOT NULL, | |
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
deleted_at TIMESTAMP, | |
PRIMARY KEY (id), | |
FOREIGN KEY (user_id) REFERENCES users (id), | |
FOREIGN KEY (friend_id) REFERENCES users (id) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment