Skip to content

Commit

Permalink
Fix secret owner table PK
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Apr 10, 2024
1 parent f8db388 commit e0415bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions domain/schema/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ CREATE TABLE
CREATE TABLE
secret_application_owner (
secret_id TEXT PRIMARY KEY,
secret_id TEXT NOT NULL,
application_uuid TEXT NOT NULL,
label TEXT,
CONSTRAINT fk_secret_application_owner_secret_id
Expand All @@ -210,14 +210,15 @@ CREATE TABLE
CONSTRAINT fk_secret_application_owner_application_uuid
FOREIGN KEY (application_uuid)
REFERENCES application (uuid)
PRIMARY KEY (secret_id, application_uuid)
);
-- We need to ensure the label is unique per the application.
CREATE UNIQUE INDEX idx_secret_application_owner_label ON secret_application_owner (label,application_uuid) WHERE label != '';
CREATE TABLE
secret_unit_owner (
secret_id TEXT PRIMARY KEY,
secret_id TEXT NOT NULL,
unit_uuid TEXT NOT NULL,
label TEXT,
CONSTRAINT fk_secret_unit_owner_secret_id
Expand All @@ -226,6 +227,7 @@ CREATE TABLE
CONSTRAINT fk_secret_unit_owner_unit_uuid
FOREIGN KEY (unit_uuid)
REFERENCES unit (uuid)
PRIMARY KEY (secret_id, unit_uuid)
);
-- We need to ensure the label is unique per unit.
Expand Down

0 comments on commit e0415bf

Please sign in to comment.