Skip to content

[policies] Add infrastructure to track user decisions to policies #9818

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,38 @@ CREATE TABLE `user_account_history` (
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- ********************************
-- tables for policies
-- ********************************

CREATE TABLE policies (
PolicyID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Version INT NOT NULL,
ModuleID INT NOT NULL,
PolicyRenewalTime INT DEFAULT 7,
PolicyRenewalTimeUnit enum('D','Y','M','H') DEFAULT 'D',
Content TEXT NULL,
SwalTitle VARCHAR(255) DEFAULT 'Terms of Use',
HeaderButton enum('Y','N') DEFAULT 'Y',
HeaderButtonText VARCHAR(255) DEFAULT 'Terms of Use',
Active enum('Y','N') DEFAULT 'Y',
AcceptButtonText VARCHAR(255) DEFAULT 'Accept',
DeclineButtonText VARCHAR(255) DEFAULT 'Decline',
CreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
UpdatedAt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE user_policy_decision (
ID INT AUTO_INCREMENT PRIMARY KEY,
UserID INT NOT NULL,
PolicyID INT NOT NULL,
Decision enum('Accepted','Declined') NOT NULL,
DecisionDate DATETIME DEFAULT CURRENT_TIMESTAMP
);


-- ********************************
-- user_login_history tables
-- ********************************
Expand Down
1 change: 1 addition & 0 deletions SQL/0000-00-01-Modules.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ INSERT INTO modules (Name, Active) VALUES ('electrophysiology_uploader', 'Y');
INSERT INTO modules (Name, Active) VALUES ('dataquery', 'Y');
INSERT INTO modules (Name, Active) VALUES ('schedule_module', 'Y');
INSERT INTO modules (Name, Active) VALUES ('redcap', 'N');
INSERT INTO modules (Name, Active) VALUES ('policy_tracker', 'Y');

ALTER TABLE issues ADD CONSTRAINT `fk_issues_7` FOREIGN KEY (`module`) REFERENCES `modules` (`ID`);
2 changes: 2 additions & 0 deletions SQL/9999-99-99-drop_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ DROP TABLE IF EXISTS `server_processes`;
DROP TABLE IF EXISTS `StatisticsTabs`;
DROP TABLE IF EXISTS `user_login_history`;
DROP TABLE IF EXISTS `user_account_history`;
DROP TABLE IF EXISTS `policies`;
DROP TABLE IF EXISTS `user_policy_decision`;
DROP TABLE IF EXISTS `data_integrity_flag`;
DROP TABLE IF EXISTS `certification_training_quiz_answers`;
DROP TABLE IF EXISTS `certification_training_quiz_questions`;
Expand Down
27 changes: 27 additions & 0 deletions SQL/New_patches/2025-05-22-Introduce-Policy-Decisions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CREATE TABLE policies (
PolicyID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Version INT NOT NULL,
ModuleID INT NOT NULL, -- Show in the header for a module
PolicyRenewalTime INT DEFAULT 7, -- Number of days before the policy is renewed
PolicyRenewalTimeUnit enum('D','Y','M','H') DEFAULT 'D', -- Unit of the renewal time
Content TEXT NULL,
SwalTitle VARCHAR(255) DEFAULT 'Terms of Use',
HeaderButton enum('Y','N') DEFAULT 'Y',
HeaderButtonText VARCHAR(255) DEFAULT 'Terms of Use',
Active enum('Y','N') DEFAULT 'Y',
AcceptButtonText VARCHAR(255) DEFAULT 'Accept',
DeclineButtonText VARCHAR(255) DEFAULT 'Decline',
CreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
UpdatedAt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE user_policy_decision (
ID INT AUTO_INCREMENT PRIMARY KEY,
UserID INT NOT NULL,
PolicyID INT NOT NULL,
Decision enum('Accepted','Declined') NOT NULL,
DecisionDate DATETIME DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO modules (`Name`, `Active`) VALUES ('policy_tracker','Y');
Loading
Loading