fix: Update patient_tracker.php (#6595)
[openemr.git] / sql / 7_0_1-to-7_0_2_upgrade.sql
blobac0a0f77b5e552ed499db856aea3ede6150c3006
1 --
2 --  Comment Meta Language Constructs:
3 --
4 --  #IfNotTable
5 --    argument: table_name
6 --    behavior: if the table_name does not exist,  the block will be executed
8 --  #IfTable
9 --    argument: table_name
10 --    behavior: if the table_name does exist, the block will be executed
12 --  #IfColumn
13 --    arguments: table_name colname
14 --    behavior:  if the table and column exist,  the block will be executed
16 --  #IfMissingColumn
17 --    arguments: table_name colname
18 --    behavior:  if the table exists but the column does not,  the block will be executed
20 --  #IfNotColumnType
21 --    arguments: table_name colname value
22 --    behavior:  If the table table_name does not have a column colname with a data type equal to value, then the block will be executed
24 --  #IfNotColumnTypeDefault
25 --    arguments: table_name colname value value2
26 --    behavior:  If the table table_name does not have a column colname with a data type equal to value and a default equal to value2, then the block will be executed
28 --  #IfNotRow
29 --    arguments: table_name colname value
30 --    behavior:  If the table table_name does not have a row where colname = value, the block will be executed.
32 --  #IfNotRow2D
33 --    arguments: table_name colname value colname2 value2
34 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2, the block will be executed.
36 --  #IfNotRow3D
37 --    arguments: table_name colname value colname2 value2 colname3 value3
38 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed.
40 --  #IfNotRow4D
41 --    arguments: table_name colname value colname2 value2 colname3 value3 colname4 value4
42 --    behavior:  If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3 AND colname4 = value4, the block will be executed.
44 --  #IfNotRow2Dx2
45 --    desc:      This is a very specialized function to allow adding items to the list_options table to avoid both redundant option_id and title in each element.
46 --    arguments: table_name colname value colname2 value2 colname3 value3
47 --    behavior:  The block will be executed if both statements below are true:
48 --               1) The table table_name does not have a row where colname = value AND colname2 = value2.
49 --               2) The table table_name does not have a row where colname = value AND colname3 = value3.
51 --  #IfRow
52 --    arguments: table_name colname value
53 --    behavior:  If the table table_name does have a row where colname = value, the block will be executed.
55 --  #IfRow2D
56 --    arguments: table_name colname value colname2 value2
57 --    behavior:  If the table table_name does have a row where colname = value AND colname2 = value2, the block will be executed.
59 --  #IfRow3D
60 --        arguments: table_name colname value colname2 value2 colname3 value3
61 --        behavior:  If the table table_name does have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed.
63 --  #IfRowIsNull
64 --    arguments: table_name colname
65 --    behavior:  If the table table_name does have a row where colname is null, the block will be executed.
67 --  #IfIndex
68 --    desc:      This function is most often used for dropping of indexes/keys.
69 --    arguments: table_name colname
70 --    behavior:  If the table and index exist the relevant statements are executed, otherwise not.
72 --  #IfNotIndex
73 --    desc:      This function will allow adding of indexes/keys.
74 --    arguments: table_name colname
75 --    behavior:  If the index does not exist, it will be created
77 --  #EndIf
78 --    all blocks are terminated with a #EndIf statement.
80 --  #IfNotListReaction
81 --    Custom function for creating Reaction List
83 --  #IfNotListOccupation
84 --    Custom function for creating Occupation List
86 --  #IfTextNullFixNeeded
87 --    desc: convert all text fields without default null to have default null.
88 --    arguments: none
90 --  #IfTableEngine
91 --    desc:      Execute SQL if the table has been created with given engine specified.
92 --    arguments: table_name engine
93 --    behavior:  Use when engine conversion requires more than one ALTER TABLE
95 --  #IfInnoDBMigrationNeeded
96 --    desc: find all MyISAM tables and convert them to InnoDB.
97 --    arguments: none
98 --    behavior: can take a long time.
100 --  #IfDocumentNamingNeeded
101 --    desc: populate name field with document names.
102 --    arguments: none
104 --  #IfUpdateEditOptionsNeeded
105 --    desc: Change Layout edit options.
106 --    arguments: mode(add or remove) layout_form_id the_edit_option comma_separated_list_of_field_ids
108 --  #IfVitalsDatesNeeded
109 --    desc: Change date from zeroes to date of vitals form creation.
110 --    arguments: none
112 #IfTable pma_bookmark
113 DROP TABLE IF EXISTS `pma_bookmark`;
114 #EndIf
116 #IfTable pma_column_info
117 DROP TABLE IF EXISTS `pma_column_info`;
118 #EndIf
120 #IfTable pma_history
121 DROP TABLE IF EXISTS `pma_history`;
122 #EndIf
124 #IfTable pma_pdf_pages
125 DROP TABLE IF EXISTS `pma_pdf_pages`;
126 #EndIf
128 #IfTable pma_relation
129 DROP TABLE IF EXISTS `pma_relation`;
130 #EndIf
132 #IfTable pma_table_coords
133 DROP TABLE IF EXISTS `pma_table_coords`;
134 #EndIf
136 #IfTable pma_table_info
137 DROP TABLE IF EXISTS `pma_table_info`;
138 #EndIf
140 #IfMissingColumn x12_partners x12_submitter_id
141 ALTER TABLE `x12_partners` ADD COLUMN `x12_submitter_id` smallint(6) DEFAULT NULL;
142 #EndIf
144 #IfNotRow2D list_options list_id abook_type option_id bill_svc
145 INSERT INTO list_options (list_id, option_id, title, seq, option_value) VALUES ('abook_type', 'bill_svc', 'Billing Service', 125, 3);
146 #EndIf
148 #IfMissingColumn users_secure last_login_fail
149 ALTER TABLE `users_secure` ADD `last_login_fail` datetime DEFAULT NULL;
150 #EndIf
152 #IfMissingColumn users_secure total_login_fail_counter
153 ALTER TABLE `users_secure` ADD `total_login_fail_counter` bigint DEFAULT 0;
154 #EndIf
156 #IfMissingColumn users_secure auto_block_emailed
157 ALTER TABLE `users_secure` ADD `auto_block_emailed` tinyint DEFAULT 0;
158 #EndIf
160 #IfNotRow globals gl_name time_reset_password_max_failed_logins
161 UPDATE `globals` SET `gl_value` = 20 WHERE `gl_name` = 'password_max_failed_logins' AND `gl_value` = 0;
162 #EndIf
164 #IfNotTable ip_tracking
165 CREATE TABLE `ip_tracking` (
166 `id` bigint NOT NULL auto_increment,
167 `ip_string` varchar(255) DEFAULT '',
168 `total_ip_login_fail_counter` bigint DEFAULT 0,
169 `ip_login_fail_counter` bigint DEFAULT 0,
170 `ip_last_login_fail` datetime DEFAULT NULL,
171 `ip_auto_block_emailed` tinyint DEFAULT 0,
172 `ip_force_block` tinyint DEFAULT 0,
173 `ip_no_prevent_timing_attack` tinyint DEFAULT 0,
174 PRIMARY KEY (`id`),
175 UNIQUE KEY `ip_string` (`ip_string`)
176 ) ENGINE=InnoDb AUTO_INCREMENT=1;
177 #EndIf
179 #IfNotTable email_queue
180 CREATE TABLE `email_queue` (
181 `id` bigint NOT NULL auto_increment,
182 `sender` varchar(255) DEFAULT '',
183 `recipient` varchar(255) DEFAULT '',
184 `subject` varchar(255) DEFAULT '',
185 `body` text,
186 `datetime_queued` datetime default NULL,
187 `sent` tinyint DEFAULT 0,
188 `datetime_sent` datetime default NULL,
189 `error` tinyint DEFAULT 0,
190 `error_message` text,
191 `datetime_error` datetime default NULL,
192 PRIMARY KEY (`id`),
193 KEY `sent` (`sent`)
194 ) ENGINE=InnoDb AUTO_INCREMENT=1;
195 #EndIf
197 #IfNotRow background_services name Email_Service
198 INSERT INTO `background_services` (`name`, `title`, `active`, `running`, `next_run`, `execute_interval`, `function`, `require_once`, `sort_order`) VALUES
199 ('Email_Service', 'Email Service', 1, 0, '2021-01-18 11:25:10', 2, 'emailServiceRun', '/library/email_service_run.php', 100);
200 #EndIf
202 #IfNotTable patient_settings
203 CREATE TABLE `patient_settings` (
204 `setting_patient`  bigint(20)   NOT NULL DEFAULT 0,
205 `setting_label` varchar(100)  NOT NULL,
206 `setting_value` varchar(255) NOT NULL DEFAULT '',
207 PRIMARY KEY (`setting_patient`, `setting_label`)
208 ) ENGINE=InnoDB;
209 #EndIf
211 #IfMissingColumn facility inactive
212 ALTER TABLE `facility` ADD COLUMN `inactive` tinyint(1) NOT NULL DEFAULT '0';
213 #EndIf
215 #IfNotRow2D list_options list_id Document_Template_Categories option_id notification_template
216 INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`) VALUES ('Document_Template_Categories','notification_template','Notification Template',105,0,0,'','','',0,0,1);
217 #EndIf