Skip to content

Commit

Permalink
implementing database upgrade script for easier upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsetsystems committed Dec 18, 2008
1 parent 40c5f10 commit 3630042
Show file tree
Hide file tree
Showing 8 changed files with 388 additions and 64 deletions.
24 changes: 17 additions & 7 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Be sure to use the -p flag when using tar, as certain permissions must be preser

OpenEMR will be extracted into a directory named openemr.

Alternatively a Debian package may be available as a file named
openemr-<version>.deb. This may work with some other Debian-like
Linux distributions such as Ubuntu.

III. Setup

To run OpenEMR, MySQL and Apache or another PHP-capable webserver must be configured.
Expand Down Expand Up @@ -169,24 +173,30 @@ these extended access controls later.

V. Upgrading

Be sure to back up your OpenEMR installation and database before upgrading!

Upgrading OpenEMR is currently done by replacing the old openemr directory with
a newer version. Before replacing the old openemr directory, copy the following
two files out, and replace them into the new openemr folder afterwards:
files out, and replace them into the new openemr folder afterwards:

openemr/interface/globals.php
openemr/library/sqlconf.php
openemr/library/sql-ledger.inc
openemr/includes/config.php (if you have modified it)

But before replacing them, compare the old and new files in case there are
new parameters that need to be included. If there are other files that you
have customized, then you will also need to treat those carefully.

When upgrading, check the directory openemr/sql/ for files named *upgrade.sql
Those files have sql statements to modify tables in your database so they will
match the layout of the current version.
Be sure to backup the content of your database before doing so.
To upgrade the database, run the sql_upgrade.php script from your web
browser (for example http:https://openemr.location/sql_upgrade.php). It will
prompt you to select the old release number, and will display the SQL
commands issued as the upgrade occurs.

Next, if you are converting from SQL-Ledger to OpenEMR's internal A/R
management (normally you should), run the sl_convert.php script
(e.g. http:https://openemr.location/sl_convert.php). Note this script may
run for several minutes or longer.

If phpGACL is installed, then you should should upgrade your Access Controls
If phpGACL is installed, then you should also upgrade your Access Controls
by running the acl_upgrade.php program using your web browser
(e.g. http:https://openemr.location/acl_upgrade.php).
9 changes: 6 additions & 3 deletions sql/2_7_3-to-2_8_0_upgrade.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#IfNotTable batchcom
##
## Table structure for table `batchcom`
##

##
CREATE TABLE IF NOT EXISTS `batchcom` (
`id` bigint(20) NOT NULL auto_increment,
`patient_id` int(11) NOT NULL default '0',
Expand All @@ -12,6 +12,9 @@ CREATE TABLE IF NOT EXISTS `batchcom` (
`msg_date_sent` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM ;
#EndIf

#IfNotColumnType billing code varchar(9)
ALTER TABLE billing
MODIFY `code` varchar(9) DEFAULT NULL;
#EndIf
17 changes: 15 additions & 2 deletions sql/2_8_0-to-2_8_1_upgrade.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#IfNotTable lang_constants

## ########################################################

##
Expand Down Expand Up @@ -56,20 +58,26 @@ INSERT INTO `lang_languages` (`lang_id`, `lang_code`, `lang_description`) VALUES
INSERT INTO `lang_languages` (`lang_id`, `lang_code`, `lang_description`) VALUES (2, 'se', 'Swedish');
INSERT INTO `lang_languages` (`lang_id`, `lang_code`, `lang_description`) VALUES (3, 'es', 'Spanish');

#EndIf



#IfMissingColumn lists outcome
ALTER TABLE lists
ADD outcome int(11) NOT NULL DEFAULT 0,
ADD destination varchar(255) DEFAULT NULL;
#EndIf

#IfMissingColumn pnotes title
ALTER TABLE pnotes
ADD title varchar(255) NOT NULL DEFAULT 'Unassigned',
ADD assigned_to varchar(255) NOT NULL DEFAULT '';
#EndIf

#IfMissingColumn users see_auth
ALTER TABLE users ADD see_auth int(11) NOT NULL DEFAULT 1;
UPDATE users SET see_auth = 3 WHERE authorized = 1;
#EndIf

#IfNotTable payments
CREATE TABLE `payments` (
`id` bigint(20) NOT NULL auto_increment,
`pid` bigint(20) NOT NULL DEFAULT 0,
Expand All @@ -83,12 +91,17 @@ CREATE TABLE `payments` (
`posted2` decimal(7,2) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ;
#EndIf

#IfNotColumnType form_vitals temperature float(5,2)
ALTER TABLE form_vitals
MODIFY temperature float(5,2) default 0,
MODIFY pulse float(5,2) default 0,
MODIFY respiration float(5,2) default 0,
MODIFY waist_circ float(5,2) default 0;
#EndIf

#IfNotColumnType form_clinical_notes followup_required int(11)
ALTER TABLE form_clinical_notes
MODIFY followup_required int(11) NOT NULL DEFAULT 0;
#EndIf
67 changes: 54 additions & 13 deletions sql/2_8_1-to-2_8_2_upgrade.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#IfNotRow lang_constants cons_id 6

##
## Data for language translations
##

## phpMyAdmin SQL Dump
## version 2.6.4-pl1-Debian-1ubuntu1.1
## http:https://www.phpmyadmin.net
##
##
## Host: localhost
## Generation Time: Feb 07, 2006 at 05:39 PM
## Server version: 4.1.12
## PHP Version: 4.4.0-3ubuntu1
##
##
## Database: `openemr`
##
##

##
##
## Dumping data for table `lang_constants`
##
##

INSERT INTO `lang_constants` VALUES (6, 'Group');
INSERT INTO `lang_constants` VALUES (8, 'Username:');
Expand Down Expand Up @@ -260,29 +262,39 @@ INSERT INTO `lang_definitions` VALUES (171, 177, 3, 'Correo Electr�ico');
INSERT INTO `lang_definitions` VALUES (172, 176, 3, 'Lista de llamadas telef�icas');
INSERT INTO `lang_definitions` VALUES (173, 178, 3, 'Cualquier');

#EndIf

#IfMissingColumn registry priority
## alters to categorize forms / per Mark

ALTER TABLE registry ADD COLUMN priority INT DEFAULT 0 AFTER date;
ALTER TABLE registry ADD COLUMN category VARCHAR(255) DEFAULT "category" AFTER priority;
ALTER TABLE registry ADD COLUMN nickname VARCHAR(255) DEFAULT '' AFTER category;
#EndIf

#IfMissingColumn patient_data phone_pharmacy
ALTER TABLE patient_data
ADD phone_pharmacy varchar(255) NOT NULL default '';
#EndIf

#IfNotTable array
## array table for storing configuration data and string lists etc...

CREATE TABLE `array` (
`array_key` varchar(255) default NULL,
`array_value` longtext
) TYPE=MyISAM;
) ENGINE=MyISAM;
#EndIf

#IfMissingColumn patient_data drivers_license
ALTER TABLE patient_data
ADD drivers_license varchar(255) NOT NULL default '';
#EndIf

#IfNotColumnType form_vitals oxygen_saturation float(5,2)
ALTER TABLE form_vitals
MODIFY oxygen_saturation float(5,2) default 0;
#EndIf

#IfNotTable drugs
CREATE TABLE drugs (
drug_id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL DEFAULT '',
Expand All @@ -298,7 +310,6 @@ CREATE TABLE drugs (
substitute int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (drug_id)
) TYPE=MyISAM;

CREATE TABLE drug_inventory (
inventory_id int(11) NOT NULL auto_increment,
drug_id int(11) NOT NULL,
Expand All @@ -309,7 +320,6 @@ CREATE TABLE drug_inventory (
last_notify date NOT NULL DEFAULT '0000-00-00',
PRIMARY KEY (inventory_id)
) TYPE=MyISAM;

CREATE TABLE drug_sales (
sale_id int(11) NOT NULL auto_increment,
drug_id int(11) NOT NULL,
Expand All @@ -322,31 +332,45 @@ CREATE TABLE drug_sales (
quantity int(11) NOT NULL DEFAULT 0,
fee decimal(7,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (sale_id)
) TYPE=MyISAM;
) ENGINE=MyISAM;
#EndIf

#IfMissingColumn prescriptions drug_id
ALTER TABLE prescriptions
ADD drug_id int(11) NOT NULL DEFAULT 0;
#EndIf

#IfMissingColumn patient_data pharmacy_id
ALTER TABLE patient_data
ADD pharmacy_id int(11) NOT NULL DEFAULT 0,
ADD referral_source varchar(30) NOT NULL DEFAULT '';
#EndIf

#new options in lang tables
#IfNotRow lang_languages lang_id 4
# new options in lang tables
INSERT INTO `lang_languages` (`lang_id`, `lang_code`, `lang_description`) VALUES (4, 'de', 'German');
INSERT INTO `lang_languages` (`lang_id`, `lang_code`, `lang_description`) VALUES (5, 'du', 'Dutch');
INSERT INTO `lang_languages` (`lang_id`, `lang_code`, `lang_description`) VALUES (6, 'he', 'Hebrew');
#EndIf

#IfMissingColumn openemr_postcalendar_events pc_prefcatid
ALTER TABLE openemr_postcalendar_events
ADD pc_prefcatid int(11) NOT NULL DEFAULT 0;
#EndIf

#IfMissingColumn prescriptions medication
# Option to deal with prescriptions on the medication list
ALTER TABLE prescriptions
ADD medication int(11);
#EndIf

#IfMissingColumn facility fax
# Add fax to facility table
ALTER TABLE facility
ADD fax varchar(30) default NULL;
#EndIf

#IfNotTable drug_templates
CREATE TABLE drug_templates (
drug_id int(11) NOT NULL,
selector varchar(255) NOT NULL,
Expand All @@ -355,26 +379,38 @@ CREATE TABLE drug_templates (
quantity int(11) NOT NULL DEFAULT 0,
refills int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (drug_id, selector)
) TYPE=MyISAM;
) ENGINE=MyISAM;
#EndIf

#IfMissingColumn drug_inventory destroy_date
ALTER TABLE drug_inventory
ADD destroy_date date DEFAULT NULL,
ADD destroy_method varchar(255) NOT NULL DEFAULT '',
ADD destroy_witness varchar(255) NOT NULL DEFAULT '',
ADD destroy_notes varchar(255) NOT NULL DEFAULT '';
#EndIf

#IfNotColumnType prescriptions size float
ALTER TABLE prescriptions
MODIFY `size` float unsigned DEFAULT NULL;
#EndIf

#IfNotColumnType drugs size float
ALTER TABLE drugs
MODIFY `size` float unsigned NOT NULL DEFAULT 0;
#EndIf

#IfMissingColumn form_encounter sensitivity
ALTER TABLE form_encounter
ADD sensitivity varchar(30) NOT NULL DEFAULT '';
#EndIf

#IfMissingColumn lists returndate
ALTER TABLE lists
ADD returndate date DEFAULT NULL;
#EndIf

#IfMissingColumn users active
ALTER TABLE users
ADD active tinyint(1) NOT NULL DEFAULT 1,
ADD npi varchar(15) NOT NULL DEFAULT '',
Expand All @@ -397,11 +433,16 @@ ALTER TABLE users
ADD city2 varchar(30) NOT NULL DEFAULT '',
ADD state2 varchar(30) NOT NULL DEFAULT '',
ADD zip2 varchar(20) NOT NULL DEFAULT '';
#EndIf

#IfMissingColumn patient_data hipaa_notice
ALTER TABLE patient_data
ADD `hipaa_notice` VARCHAR(3) DEFAULT 'NO' NOT NULL,
ADD `hipaa_message` VARCHAR(20);
#EndIf

#IfNotColumnType prescriptions dosage varchar(100)
ALTER TABLE prescriptions
MODIFY `dosage` varchar(100) DEFAULT NULL,
MODIFY `quantity` varchar(11) DEFAULT NULL;
#EndIf
Loading

0 comments on commit 3630042

Please sign in to comment.