-
Notifications
You must be signed in to change notification settings - Fork 1
BI-2163 - Add multiple species to the species list when creating a program #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
506ca69
a7d4a5b
21ff9ce
e11c662
db001ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| ALTER TABLE species | ||
| ADD CONSTRAINT unique_common_name UNIQUE (common_name); | ||
|
|
||
| DO $$ | ||
| DECLARE | ||
| user_id UUID; | ||
| BEGIN | ||
|
|
||
| user_id := (SELECT id FROM bi_user WHERE name = 'system'); | ||
|
|
||
| -- just putting blank strings in for descriptions until later date, can update if needed | ||
| INSERT INTO species (common_name, description, created_by, updated_by) | ||
| VALUES | ||
| ('Hydrangea', '', user_id, user_id), | ||
| ('Red Clover', '', user_id, user_id), | ||
| ('Potato', '', user_id, user_id), | ||
| ('Blackberry', '', user_id, user_id), | ||
| ('Raspberry', '', user_id, user_id), | ||
| ('Sugar Beet', '', user_id, user_id), | ||
| ('Strawberry', '', user_id, user_id), | ||
| ('Coffee', '', user_id, user_id), | ||
| ('Hop', '', user_id, user_id) ON CONFLICT DO NOTHING; | ||
|
Comment on lines
+29
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will this do if, for example, Hydrangea exists in the database but the others do not? Will it do a partial insert or just abort the whole statement? Might be better to do one insert per species. There's a chance one or more of these species will be manually added to production before the next major release if there is an urgent need for it, so it would be best to account for that and assume that at least one of these species will already exist in the database.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I saw it's supposed to continue on if one fails and do the rest, I can test and make sure that's the case and change it if not.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Working as expected when Hydrangea exists in the database prior to the migration, all the rest are added. |
||
|
|
||
| END $$; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check qa-test and rel-test for duplicates as well as production?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did, they don't have duplicates