Skip to content
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

OP-1359 | Add missing FK for Auditable entities #1464

Merged
merged 18 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sql/step_04_all_following_steps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ source step_a111_add_missing_lock_columns.sql;
source step_a112_users_and_groups_soft_deletion.sql;
source step_a113_alter_table_medicalinventory.sql;
source step_a114_medical_type_soft_deletion.sql;
source step_a115_add_missing_foreign_key_for_auditable_entities.sql
61 changes: 61 additions & 0 deletions sql/step_a115_add_missing_foreign_key_for_auditable_entities.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
--- MEDICALDSRINVENTORY --
ALTER TABLE OH_MEDICALDSRINVENTORY
ArnaudFofou marked this conversation as resolved.
Show resolved Hide resolved
DROP CONSTRAINT FK_MEDICALDSRINVENTORY_USER;

ALTER TABLE OH_MEDICALDSRINVENTORY
ADD CONSTRAINT FK_MEDICALDSRINVENTORY_USER_1
FOREIGN KEY (MINVT_US_ID_A) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE OH_MEDICALDSRINVENTORY
ADD CONSTRAINT FK_MEDICALDSRINVENTORY_USER_2
FOREIGN KEY (MINVT_CREATED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE OH_MEDICALDSRINVENTORY
ADD CONSTRAINT FK_MEDICALDSRINVENTORY_USER_3
FOREIGN KEY (MINVT_LAST_MODIFIED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- OH_MEDICALDSRINVENTORYROW --

ALTER TABLE OH_MEDICALDSRINVENTORYROW
ADD CONSTRAINT FK_MEDICALDSRINVENTORYROW_USER_1
FOREIGN KEY (MINVTR_CREATED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE OH_MEDICALDSRINVENTORYROW
ADD CONSTRAINT FK_MEDICALDSRINVENTORYROW_USER_2
FOREIGN KEY (MINVTR_LAST_MODIFIED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- OH_MEDICALDSRSTOCK --
ALTER TABLE OH_MEDICALDSRSTOCK
ArnaudFofou marked this conversation as resolved.
Show resolved Hide resolved
MODIFY COLUMN MS_CREATED_BY VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE OH_MEDICALDSRSTOCK
MODIFY COLUMN MS_LAST_MODIFIED_BY VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE OH_MEDICALDSRSTOCK
ADD CONSTRAINT FK_MEDICALDSRSTOCK_USER_1
FOREIGN KEY (MS_CREATED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE OH_MEDICALDSRSTOCK
ADD CONSTRAINT FK_MEDICALDSRSTOCK_USER_2
FOREIGN KEY (MS_LAST_MODIFIED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;
ArnaudFofou marked this conversation as resolved.
Show resolved Hide resolved


mwithi marked this conversation as resolved.
Show resolved Hide resolved
-- OH_USER_SETTINGS --

ALTER TABLE OH_USER_SETTINGS
ADD CONSTRAINT FK_USER_SETTINGS_USER_1
FOREIGN KEY (USS_CREATED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE OH_USER_SETTINGS
ADD CONSTRAINT FK_USER_SETTINGS_USER_2
FOREIGN KEY (USS_LAST_MODIFIED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;
ArnaudFofou marked this conversation as resolved.
Show resolved Hide resolved

-- OH_PATIENT_CONSENSUS --

ALTER TABLE OH_PATIENT_CONSENSUS
ADD CONSTRAINT FK_PATIENT_CONSENSUS_USER_1
FOREIGN KEY (PTC_CREATED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE OH_PATIENT_CONSENSUS
ADD CONSTRAINT FK_PATIENT_CONSENSUS_USER_2
FOREIGN KEY (PTC_LAST_MODIFIED_BY) REFERENCES OH_USER (US_ID_A) ON DELETE NO ACTION ON UPDATE NO ACTION;
Loading