Skip to content

Instantly share code, notes, and snippets.

@pinkeshbadjatiya
Created July 9, 2016 11:39
Show Gist options
  • Save pinkeshbadjatiya/c4a3be700db2cb88b5f8cc343795eb86 to your computer and use it in GitHub Desktop.
Save pinkeshbadjatiya/c4a3be700db2cb88b5f8cc343795eb86 to your computer and use it in GitHub Desktop.
SQL schema change(tables) : listen -> listen + listen_json
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