Created
July 9, 2016 11:39
-
-
Save pinkeshbadjatiya/c4a3be700db2cb88b5f8cc343795eb86 to your computer and use it in GitHub Desktop.
SQL schema change(tables) : listen -> listen + listen_json
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 listen ( | |
id SERIAL, | |
user_id VARCHAR NOT NULL, | |
ts TIMESTAMP WITH TIME ZONE NOT NULL, | |
artist_msid UUID NOT NULL, | |
album_msid UUID, | |
recording_msid UUID NOT NULL, | |
listen_json id, | |
); | |
CREATE TABLE listen_json ( | |
id SERIAL PRIMARY KEY, | |
raw_data JSONB, | |
raw_data_sha256 CHAR(64) NOT NULL, | |
); | |
ALTER TABLE listen ADD CONSTRAINT listen_listen_json_foreign_key FOREIGN KEY (listen_json) REFERENCES "listen_json" (id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment