Skip to content

Instantly share code, notes, and snippets.

@kmacgugan
Created March 8, 2019 04:40
Show Gist options
  • Save kmacgugan/518470dfa08f35dc92df031989abf87c to your computer and use it in GitHub Desktop.
Save kmacgugan/518470dfa08f35dc92df031989abf87c to your computer and use it in GitHub Desktop.
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);
@afiune
Copy link

afiune commented Mar 8, 2019

I agree that we need a unique index but I don't think we should do it with CREATE UNIQUE INDEX but instead just a UNIQUE constraint on the creation of the table. (I will update my PR)

@afiune
Copy link

afiune commented Mar 8, 2019

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