We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 373005a commit b7b9b7dCopy full SHA for b7b9b7d
src/main/resources/db/migration/V6.3.0.3.sql
@@ -1,7 +1,14 @@
1
-- Dataset types have been added. See #10517 and #10694
2
--
3
--- Insert the default dataset type: dataset.
4
-INSERT INTO datasettype (name) VALUES ('dataset');
+-- Insert the default dataset type: dataset (if not present).
+-- Inspired by https://stackoverflow.com/questions/4069718/postgres-insert-if-does-not-exist-already/13342031#13342031
5
+INSERT INTO datasettype
6
+ (name)
7
+SELECT 'dataset'
8
+WHERE
9
+ NOT EXISTS (
10
+ SELECT name FROM datasettype WHERE name = 'dataset'
11
+ );
12
13
-- Add the new column (if it doesn't exist).
14
ALTER TABLE dataset ADD COLUMN IF NOT EXISTS datasettype_id bigint;
0 commit comments