Created
March 8, 2019 04:40
-
-
Save kmacgugan/518470dfa08f35dc92df031989abf87c 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 IF NOT EXISTS supervisor ( | |
id SERIAL PRIMARY KEY, | |
Application TEXT NOT NULL DEFAULT '', | |
Environment TEXT NOT NULL DEFAULT '' | |
); | |
CREATE TABLE IF NOT EXISTS service_group ( | |
id SERIAL PRIMARY KEY, | |
name TEXT NOT NULL | |
); | |
CREATE TABLE IF NOT EXISTS service ( | |
id SERIAL PRIMARY KEY, | |
origin TEXT NOT NULL, | |
name TEXT NOT NULL, | |
version TEXT NOT NULL, | |
release TEXT NOT NULL, | |
status TEXT NOT NULL, | |
health TEXT NOT NULL, | |
group_id TEXT NOT NULL REFERENCES service_group (id) ON DELETE CASCADE, | |
sup_id TEXT NOT NULL REFERENCES supervisor (id) ON DELETE CASCADE | |
); | |
CREATE UNIQUE INDEX service_id_idx | |
ON service (sup_id, origin, name); |
What I disagree with is the ID you are using in the supervisor table. We have the ID coming from habitat so we should NOT generate one ourselves. Let us talk over zoom! But really thank you for looking at my proposal -- You are awesome! 💯
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I agree that we need a unique index but I don't think we should do it with
CREATE UNIQUE INDEX
but instead just aUNIQUE
constraint on the creation of the table. (I will update my PR)