Skip to content

Commit

Permalink
fix sql script, add column etc #10517
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jul 29, 2024
1 parent b5b8c40 commit bf668a9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/resources/db/migration/V6.3.0.2.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
-- Dataset types have been added. See #10517 and #10694
--
-- First, insert some types (dataset is the default).
-- Insert some types (dataset is the default).
INSERT INTO datasettype (name) VALUES ('dataset');
INSERT INTO datasettype (name) VALUES ('software');
INSERT INTO datasettype (name) VALUES ('workflow');
--
-- Then, give existing datasets a type of "dataset".
-- Add the new column (if it doesn't exist) and foreign key.
ALTER TABLE dataset ADD COLUMN IF NOT EXISTS datasettype_id bigint;
ALTER TABLE dataset ADD CONSTRAINT fk_dataset_datasettype_id FOREIGN KEY (datasettype_id) REFERENCES datasettype(id);
--
-- Give existing datasets a type of "dataset".
UPDATE dataset SET datasettype_id = (SELECT id FROM datasettype WHERE name = 'dataset');
--
-- Make the column non-null
ALTER TABLE dataset ALTER COLUMN datasettype_id SET NOT NULL;

0 comments on commit bf668a9

Please sign in to comment.