Skip to content

Commit

Permalink
conditional INSERT of dataset type #10517
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Sep 4, 2024
1 parent 373005a commit b7b9b7d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/resources/db/migration/V6.3.0.3.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
-- Dataset types have been added. See #10517 and #10694
--
-- Insert the default dataset type: dataset.
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
INSERT INTO datasettype
(name)
SELECT 'dataset'
WHERE
NOT EXISTS (
SELECT name FROM datasettype WHERE name = 'dataset'
);
--
-- Add the new column (if it doesn't exist).
ALTER TABLE dataset ADD COLUMN IF NOT EXISTS datasettype_id bigint;
Expand Down

0 comments on commit b7b9b7d

Please sign in to comment.