diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-17 13:21:20 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-17 13:21:20 -0700 |
commit | 5feeb70f930e733587ad7fa33d361cf24602abca (patch) | |
tree | 5344789210b3f81500a9b4413e0249633442e704 /rust/migrations/2018-05-12-001226_init | |
parent | 1c708d6a4ea155710c7f1b752e9bcb01ac75f98d (diff) | |
download | fatcat-5feeb70f930e733587ad7fa33d361cf24602abca.tar.gz fatcat-5feeb70f930e733587ad7fa33d361cf24602abca.zip |
UNIQUE constraint on edits (ident per editgroup)
Diffstat (limited to 'rust/migrations/2018-05-12-001226_init')
-rw-r--r-- | rust/migrations/2018-05-12-001226_init/up.sql | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index 7550364c..a6384f4e 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -91,11 +91,10 @@ CREATE TABLE creator_edit ( rev_id UUID REFERENCES creator_rev(id), redirect_id UUID REFERENCES creator_ident(id), prev_rev UUID REFERENCES creator_rev(id), - extra_json JSONB + extra_json JSONB, + UNIQUE (editgroup_id, ident_id) ); -CREATE INDEX creator_edit_idx ON creator_edit(editgroup_id); - -------------------- Containers -------------------------------------------- CREATE TABLE container_rev ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), @@ -132,11 +131,10 @@ CREATE TABLE container_edit ( rev_id UUID REFERENCES container_rev(id), redirect_id UUID REFERENCES container_ident(id), prev_rev UUID REFERENCES container_rev(id), - extra_json JSONB + extra_json JSONB, + UNIQUE (editgroup_id, ident_id) ); -CREATE INDEX container_edit_idx ON container_edit(editgroup_id); - -------------------- Files ------------------------------------------------- CREATE TABLE file_rev ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), @@ -180,11 +178,10 @@ CREATE TABLE file_edit ( rev_id UUID REFERENCES file_rev(id), redirect_id UUID REFERENCES file_ident(id), prev_rev UUID REFERENCES file_rev(id), - extra_json JSONB + extra_json JSONB, + UNIQUE (editgroup_id, ident_id) ); -CREATE INDEX file_edit_idx ON file_edit(editgroup_id); - -------------------- Release ----------------------------------------------- CREATE TABLE release_rev ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), @@ -248,11 +245,10 @@ CREATE TABLE release_edit ( rev_id UUID REFERENCES release_rev(id), redirect_id UUID REFERENCES release_ident(id), prev_rev UUID REFERENCES release_rev(id), - extra_json JSONB + extra_json JSONB, + UNIQUE (editgroup_id, ident_id) ); -CREATE INDEX release_edit_idx ON release_edit(editgroup_id); - -------------------- Works -------------------------------------------------- CREATE TABLE work_rev ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), @@ -276,11 +272,10 @@ CREATE TABLE work_edit ( rev_id UUID REFERENCES work_rev(id), redirect_id UUID REFERENCES work_ident(id), prev_rev UUID REFERENCES work_rev(id), - extra_json JSONB + extra_json JSONB, + UNIQUE (editgroup_id, ident_id) ); -CREATE INDEX work_edit_idx ON work_edit(editgroup_id); - ALTER TABLE release_rev ADD CONSTRAINT release_containeridentid_fkey FOREIGN KEY (work_ident_id) REFERENCES work_ident(id); |