-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix sql script, add column etc #10517
- Loading branch information
Showing
1 changed file
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |