-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Easi 3774/existing model link refactor (#916)
* feat: update the schema for a high level existing models structure * feat: add field_name to existing model link in database and go model * chore: fix migration syntax * feat: work in progress first pass to add field name to loader and merge statement * chore: make existing model modelName field not null in GQL * chore: add missing comma to merge statement * feat: add constraints and update audit table config * feat: add upcoming field enum to test constraints * feat: update data loader to return data by compound key * feat: update postman collection for existing model links * feat: expose fieldName and modelPlanID on ExistingModelLinks type * chore: rename migration * feat: first pass return an array of names for a collection of Existing Model Links * feat: correct bad unit test, add first unit test for getting names * feat: add ordering to the names query * feat: add unit test to make sure only relevant fields are returned * chore: remove old comments * chore: remove old todo * update queries and ran scripts/dev gql * udpated query and update payload * renamed migration due to conflict * chore: correct capitalization of table alias * Update schema and translation files to make sure data goes to CSV * udpate tests and snaps * remove .only in test * adding one more conditional --------- Co-authored-by: Gary Zhao <[email protected]> Co-authored-by: Gary Zhao <[email protected]>
- Loading branch information
1 parent
4cef085
commit 56ce40a
Showing
44 changed files
with
1,452 additions
and
620 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
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
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
46 changes: 46 additions & 0 deletions
46
migrations/V143__Add_Field_Name_To_Existing_Model_Link.sql
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- Create the new type | ||
CREATE TYPE EXISITING_MODEL_LINK_FIELD_TYPE AS ENUM ( | ||
'GEN_CHAR_RESEMBLES_EXISTING_MODEL_WHICH', | ||
'GEN_CHAR_PARTICIPATION_EXISTING_MODEL_WHICH' | ||
); | ||
|
||
-- add the column to the table | ||
ALTER TABLE existing_model_link | ||
ADD COLUMN field_name EXISITING_MODEL_LINK_FIELD_TYPE; | ||
|
||
-- Update existing data to point to the new column (this is the only field in use currently) | ||
UPDATE existing_model_link | ||
SET field_name = 'GEN_CHAR_RESEMBLES_EXISTING_MODEL_WHICH', | ||
modified_by = '00000001-0001-0001-0001-000000000001', | ||
modified_dts = CURRENT_TIMESTAMP; | ||
|
||
|
||
ALTER TABLE existing_model_link | ||
ALTER COLUMN field_name SET NOT NULL; | ||
|
||
/* Update Audit table to insert the field when link is created*/ | ||
UPDATE audit.table_config | ||
SET | ||
insert_fields = '{existing_model_id,current_model_plan_id,field_name}', | ||
modified_by = '00000001-0001-0001-0001-000000000001', --system_account | ||
modified_dts = CURRENT_TIMESTAMP | ||
WHERE name = 'existing_model_link'; | ||
|
||
|
||
|
||
|
||
ALTER TABLE existing_model_link | ||
DROP CONSTRAINT unique_existing_model_link_existing; | ||
|
||
/* Add constraint requiring that you can only link a model and existing model once per field*/ | ||
ALTER TABLE existing_model_link | ||
ADD CONSTRAINT unique_existing_model_link_existing_field_name UNIQUE (model_plan_id, existing_model_id, field_name); | ||
COMMENT ON CONSTRAINT unique_existing_model_link_existing_field_name ON existing_model_link IS 'This constraint requires that there is not a duplicate link per model_plan, existing model, and field name'; | ||
|
||
|
||
ALTER TABLE existing_model_link | ||
DROP CONSTRAINT unique_existing_model_link_current_model; | ||
/* Add constraint requiring that you can only link a model and current model once per field*/ | ||
ALTER TABLE existing_model_link | ||
ADD CONSTRAINT unique_existing_model_link_current_model_field_name UNIQUE (model_plan_id, current_model_plan_id, field_name); | ||
COMMENT ON CONSTRAINT unique_existing_model_link_current_model_field_name ON existing_model_link IS 'This constraint requires that there is not a duplicate link per model_plan, current_model, and field name'; |
Oops, something went wrong.