From 5b784d934abd89e432beb57e620ce3579771d76e Mon Sep 17 00:00:00 2001 From: Youri K Date: Thu, 22 Nov 2018 11:13:13 +0100 Subject: [PATCH] add annotation dataset foreign key and fix pull number from #3415 --- .../033-tasktype-recommendedConfiguration.sql | 2 +- .../034-add-annotation-dataset-foreign-key.sql | 10 ++++++++++ .../034-add-annotation-dataset-foreign-key.sql | 10 ++++++++++ tools/postgres/schema.sql | 5 +++-- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 conf/evolutions/034-add-annotation-dataset-foreign-key.sql create mode 100644 conf/evolutions/reversions/034-add-annotation-dataset-foreign-key.sql diff --git a/conf/evolutions/033-tasktype-recommendedConfiguration.sql b/conf/evolutions/033-tasktype-recommendedConfiguration.sql index 071de94d30a..a60128621de 100644 --- a/conf/evolutions/033-tasktype-recommendedConfiguration.sql +++ b/conf/evolutions/033-tasktype-recommendedConfiguration.sql @@ -1,4 +1,4 @@ --- https://github.com/scalableminds/webknossos/pull/TODO +-- https://github.com/scalableminds/webknossos/pull/3415 START TRANSACTION; diff --git a/conf/evolutions/034-add-annotation-dataset-foreign-key.sql b/conf/evolutions/034-add-annotation-dataset-foreign-key.sql new file mode 100644 index 00000000000..c273fffd29f --- /dev/null +++ b/conf/evolutions/034-add-annotation-dataset-foreign-key.sql @@ -0,0 +1,10 @@ +-- https://github.com/scalableminds/webknossos/pull/TODO + +START TRANSACTION; + +ALTER TABLE webknossos.annotations + ADD CONSTRAINT dataSet_ref FOREIGN KEY(_dataSet) REFERENCES webknossos.dataSets(_id) DEFERRABLE; + +UPDATE webknossos.releaseInformation SET schemaVersion = 34; + +COMMIT TRANSACTION; \ No newline at end of file diff --git a/conf/evolutions/reversions/034-add-annotation-dataset-foreign-key.sql b/conf/evolutions/reversions/034-add-annotation-dataset-foreign-key.sql new file mode 100644 index 00000000000..57bf15248f2 --- /dev/null +++ b/conf/evolutions/reversions/034-add-annotation-dataset-foreign-key.sql @@ -0,0 +1,10 @@ +-- https://github.com/scalableminds/webknossos/pull/TODO + +START TRANSACTION; + +ALTER TABLE webknossos.annotations + DROP CONSTRAINT dataSet_ref; + +UPDATE webknossos.releaseInformation SET schemaVersion = 33; + +COMMIT TRANSACTION; \ No newline at end of file diff --git a/tools/postgres/schema.sql b/tools/postgres/schema.sql index 77786d4f39b..19d107b2eaf 100644 --- a/tools/postgres/schema.sql +++ b/tools/postgres/schema.sql @@ -21,7 +21,7 @@ START TRANSACTION; CREATE TABLE webknossos.releaseInformation ( schemaVersion BIGINT NOT NULL ); -INSERT INTO webknossos.releaseInformation(schemaVersion) values(33); +INSERT INTO webknossos.releaseInformation(schemaVersion) values(34); COMMIT TRANSACTION; CREATE TABLE webknossos.analytics( @@ -329,7 +329,8 @@ ALTER TABLE webknossos.analytics ALTER TABLE webknossos.annotations ADD CONSTRAINT task_ref FOREIGN KEY(_task) REFERENCES webknossos.tasks(_id) ON DELETE SET NULL DEFERRABLE, ADD CONSTRAINT team_ref FOREIGN KEY(_team) REFERENCES webknossos.teams(_id) DEFERRABLE, - ADD CONSTRAINT user_ref FOREIGN KEY(_user) REFERENCES webknossos.users(_id) DEFERRABLE; + ADD CONSTRAINT user_ref FOREIGN KEY(_user) REFERENCES webknossos.users(_id) DEFERRABLE, + ADD CONSTRAINT dataSet_ref FOREIGN KEY(_dataSet) REFERENCES webknossos.dataSets(_id) DEFERRABLE; ALTER TABLE webknossos.dataSets ADD CONSTRAINT organization_ref FOREIGN KEY(_organization) REFERENCES webknossos.organizations(_id) DEFERRABLE, ADD CONSTRAINT dataStore_ref FOREIGN KEY(_dataStore) REFERENCES webknossos.dataStores(name) DEFERRABLE;