2 # Database upgrade script Front Accounting
3 # Source version: 2.0.x
4 # Target version: 2.1.0
6 # To make upgrades clean and failsafe:
7 # * Precede all CREATE TABLE statment with DROP TABLE IF EXISTS
8 # * Precede all ALTER TABLE statements using ADD column with respective
9 # ALTER TABLE with DROP column
10 # * Move all other DROP queries (e.g. removing obsolete tables) to installer
11 # - they are not executed during non-forced upgrade.
14 DROP TABLE IF EXISTS `0_attachments`;
16 CREATE TABLE `0_attachments` (
17 `id` int(11) UNSIGNED NOT NULL auto_increment,
18 `description` varchar(60) NOT NULL default '',
19 `type_no` int(11) NOT NULL default '0',
20 `trans_no` int(11) NOT NULL default '0',
21 `unique_name` varchar(60) NOT NULL default '',
22 `tran_date` date NOT NULL default '0000-00-00',
23 `filename` varchar(60) NOT NULL default '',
24 `filesize` int(11) NOT NULL default '0',
25 `filetype` varchar(60) NOT NULL default '',
27 KEY `type_no` (`type_no`,`trans_no`)
28 ) TYPE=MyISAM AUTO_INCREMENT=1 ;
30 DROP TABLE IF EXISTS `0_groups`;
32 CREATE TABLE `0_groups` (
33 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
34 `description` varchar(60) NOT NULL default '',
35 `inactive` tinyint(1) NOT NULL default 0,
37 UNIQUE KEY `description` (`description`)
38 ) TYPE=MyISAM AUTO_INCREMENT=1 ;
40 INSERT INTO `0_groups` VALUES ('1', 'Small', '0');
41 INSERT INTO `0_groups` VALUES ('2', 'Medium', '0');
42 INSERT INTO `0_groups` VALUES ('3', 'Large', '0');
44 DROP TABLE IF EXISTS `0_recurrent_invoices`;
46 CREATE TABLE `0_recurrent_invoices` (
47 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
48 `description` varchar(60) NOT NULL default '',
49 `order_no` int(11) UNSIGNED NOT NULL,
50 `debtor_no` int(11) UNSIGNED NULL default NULL,
51 `group_no` smallint(6) UNSIGNED NULL default NULL,
52 `days` int(11) NOT NULL default '0',
53 `monthly` int(11) NOT NULL default '0',
54 `begin` date NOT NULL default '0000-00-00',
55 `end` date NOT NULL default '0000-00-00',
56 `last_sent` date NOT NULL default '0000-00-00',
58 UNIQUE KEY `description` (`description`)
59 ) TYPE=InnoDB AUTO_INCREMENT=1 ;
61 ALTER TABLE `0_cust_branch` ADD `group_no` int(11) NOT NULL default '0';
63 ALTER TABLE `0_debtor_trans` ADD `dimension_id` int(11) NOT NULL default '0';
64 ALTER TABLE `0_debtor_trans` ADD `dimension2_id` int(11) NOT NULL default '0';
66 ALTER TABLE `0_bank_accounts` DROP PRIMARY KEY;
67 ALTER TABLE `0_bank_accounts` ADD `id` SMALLINT(6) AUTO_INCREMENT PRIMARY KEY;
68 ALTER TABLE `0_bank_accounts` ADD `last_reconciled_date` timestamp NOT NULL default '0000-00-00';
69 ALTER TABLE `0_bank_accounts` ADD `ending_reconcile_balance` double NOT NULL default '0';
71 ALTER TABLE `0_bank_trans` DROP COLUMN `bank_trans_type_id`;
72 ALTER TABLE `0_bank_trans` ADD `reconciled` date default NULL;
74 ALTER TABLE `0_users` ADD `query_size` TINYINT(1) DEFAULT '10';
76 ALTER TABLE `0_users` ADD `graphic_links` TINYINT(1) DEFAULT '1';
78 DROP TABLE IF EXISTS `0_sales_pos`;
80 CREATE TABLE `0_sales_pos` (
81 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
82 `pos_name` varchar(30) NOT NULL,
83 `cash_sale` tinyint(1) NOT NULL,
84 `credit_sale` tinyint(1) NOT NULL,
85 `pos_location` varchar(5) NOT NULL,
86 `pos_account` smallint(6) UNSIGNED NOT NULL,
87 `inactive` tinyint(1) NOT NULL default 0,
89 UNIQUE KEY(`pos_name`)
90 ) TYPE=MyISAM AUTO_INCREMENT=1;
92 # After upgrade default POS cash sale is off. Change in POS setup if you wish.
93 INSERT INTO `0_sales_pos` VALUES ('1', 'Default', '0', '1', 'DEF', '1', '0');
95 ALTER TABLE `0_users` ADD `pos` SMALLINT(6) DEFAULT '1';
97 DROP TABLE IF EXISTS `0_quick_entries`;
99 CREATE TABLE `0_quick_entries` (
100 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
101 `type` tinyint(1) NOT NULL default '0',
102 `description` varchar(60) NOT NULL,
103 `base_amount` double NOT NULL default '0',
104 `base_desc` varchar(60) NULL,
106 KEY `description` (`description`)
107 ) TYPE=MyISAM AUTO_INCREMENT=1;
109 INSERT INTO `0_quick_entries` VALUES ('1', '1', 'Maintenance', '0', 'Amount');
110 INSERT INTO `0_quick_entries` VALUES ('2', '1', 'Phone', '0', 'Amount');
111 INSERT INTO `0_quick_entries` VALUES ('3', '2', 'Cash Sales', '0', 'Amount');
113 DROP TABLE IF EXISTS `0_quick_entry_lines`;
115 CREATE TABLE `0_quick_entry_lines` (
116 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
117 `qid` smallint(6) UNSIGNED NOT NULL,
118 `amount` double default NULL default '0',
119 `action` varchar(2) NOT NULL,
120 `dest_id` varchar(11) NOT NULL,
121 `dimension_id` smallint(6) UNSIGNED NULL default NULL,
122 `dimension2_id` smallint(6) UNSIGNED NULL default NULL,
125 ) TYPE=MyISAM AUTO_INCREMENT=1;
127 INSERT INTO `0_quick_entry_lines` VALUES ('1', '1','0','=', '6600', '0', '0');
128 INSERT INTO `0_quick_entry_lines` VALUES ('2', '2','0','=', '6730', '0', '0');
129 INSERT INTO `0_quick_entry_lines` VALUES ('3', '3','0','=', '3000', '0', '0');
131 ALTER TABLE `0_users` ADD `print_profile` VARCHAR(30) NOT NULL DEFAULT '1';
132 ALTER TABLE `0_users` ADD `rep_popup` TINYINT(1) DEFAULT '1';
134 DROP TABLE IF EXISTS `0_print_profiles`;
135 CREATE TABLE `0_print_profiles` (
136 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
137 `profile` varchar(30) NOT NULL,
138 `report` varchar(5) NULL default NULL,
139 `printer` tinyint(3) UNSIGNED NULL default NULL,
141 UNIQUE KEY `profile` (`profile`,`report`)
142 ) TYPE=MyISAM AUTO_INCREMENT=10;
144 INSERT INTO `0_print_profiles` VALUES ('1', 'Out of office', '', '0');
145 INSERT INTO `0_print_profiles` VALUES ('2', 'Sales Department', '', '0');
146 INSERT INTO `0_print_profiles` VALUES ('3', 'Central', '', '2');
147 INSERT INTO `0_print_profiles` VALUES ('4', 'Sales Department', '104', '2');
148 INSERT INTO `0_print_profiles` VALUES ('5', 'Sales Department', '105', '2');
149 INSERT INTO `0_print_profiles` VALUES ('6', 'Sales Department', '107', '2');
150 INSERT INTO `0_print_profiles` VALUES ('7', 'Sales Department', '109', '2');
151 INSERT INTO `0_print_profiles` VALUES ('8', 'Sales Department', '110', '2');
152 INSERT INTO `0_print_profiles` VALUES ('9', 'Sales Department', '201', '2');
154 DROP TABLE IF EXISTS `0_printers`;
156 CREATE TABLE `0_printers` (
157 `id` tinyint(3) UNSIGNED NOT NULL auto_increment,
158 `name` varchar(20) NOT NULL,
159 `description` varchar(60) NOT NULL,
160 `queue` varchar(20) NOT NULL,
161 `host` varchar(40) NOT NULL,
162 `port` smallint(11) unsigned NOT NULL,
163 `timeout` tinyint(3) unsigned NOT NULL,
165 UNIQUE KEY `name` (`name`)
166 ) TYPE=MyISAM AUTO_INCREMENT=4;
168 INSERT INTO `0_printers` VALUES ('1', 'QL500', 'Label printer', 'QL500', 'server', '127', '20');
169 INSERT INTO `0_printers` VALUES ('2', 'Samsung', 'Main network printer', 'scx4521F', 'server', '515', '5');
170 INSERT INTO `0_printers` VALUES ('3', 'Local', 'Local print server at user IP', 'lp', '', '515', '10');
172 DROP TABLE IF EXISTS `0_item_codes`;
174 CREATE TABLE `0_item_codes` (
175 `id` int(11) UNSIGNED NOT NULL auto_increment,
176 `item_code` varchar(20) NOT NULL,
177 `stock_id` varchar(20) NOT NULL,
178 `description` varchar(200) NOT NULL default '',
179 `category_id` smallint(6) UNSIGNED NOT NULL,
180 `quantity` double NOT NULL default '1',
181 `is_foreign` tinyint(1) NOT NULL default 0,
182 `inactive` tinyint(1) NOT NULL default 0,
184 UNIQUE KEY(`stock_id`, `item_code`)
185 ) TYPE=MyISAM AUTO_INCREMENT=1;
187 ALTER TABLE `0_company` ADD `foreign_codes` TINYINT(1) NOT NULL DEFAULT '0';
189 ALTER TABLE `0_company` ADD `accumulate_shipping` TINYINT(1) NOT NULL DEFAULT '0';
191 ALTER TABLE `0_company` ADD `legal_text` tinytext NOT NULL DEFAULT '';
193 ALTER TABLE `0_suppliers` ADD `supp_address` tinytext NOT NULL DEFAULT '' AFTER `address`;
195 ALTER TABLE `0_suppliers` ADD `phone` varchar(30) NOT NULL DEFAULT '' AFTER `supp_address`;
197 ALTER TABLE `0_suppliers` ADD `fax` varchar(30) NOT NULL DEFAULT '' AFTER `phone`;
199 ALTER TABLE `0_suppliers` ADD `gst_no` varchar(25) NOT NULL DEFAULT '' AFTER `fax`;
201 ALTER TABLE `0_suppliers` ADD `contact` varchar(60) NOT NULL DEFAULT '' AFTER `gst_no`;
203 ALTER TABLE `0_suppliers` ADD `credit_limit` double NOT NULL DEFAULT '0' AFTER `tax_group_id`;
205 ALTER TABLE `0_suppliers` ADD `supp_account_no` varchar(40) NOT NULL DEFAULT '' AFTER `contact`;
207 ALTER TABLE `0_suppliers` ADD `website` varchar(100) NOT NULL DEFAULT '' AFTER `email`;
209 ALTER TABLE `0_suppliers` ADD `notes` tinytext NOT NULL DEFAULT '';
211 ALTER TABLE `0_chart_types` DROP INDEX `name`, ADD INDEX `name` ( `name` );
213 DROP TABLE IF EXISTS `0_sql_trail`;
215 CREATE TABLE IF NOT EXISTS `0_sql_trail` (
216 `id` int(11) UNSIGNED NOT NULL auto_increment,
218 `result` tinyint(1) NOT NULL,
219 `msg` varchar(255) NOT NULL,
223 ALTER TABLE `0_tax_types` DROP COLUMN `out`;
225 ALTER TABLE `0_chart_master` DROP COLUMN `tax_code`;
227 ALTER TABLE `0_chart_master` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
229 ALTER TABLE `0_currencies` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
231 ALTER TABLE `0_bank_accounts` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
233 ALTER TABLE `0_debtors_master` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
235 ALTER TABLE `0_stock_master` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
237 ALTER TABLE `0_workcentres` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
239 ALTER TABLE `0_locations` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
241 ALTER TABLE `0_sales_types` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
243 ALTER TABLE `0_areas` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
245 ALTER TABLE `0_salesman` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
247 ALTER TABLE `0_shippers` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
249 ALTER TABLE `0_credit_status` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
251 ALTER TABLE `0_payment_terms` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
253 ALTER TABLE `0_suppliers` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
255 ALTER TABLE `0_stock_category` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
257 ALTER TABLE `0_item_units` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
259 DROP TABLE IF EXISTS `0_trans_tax_details`;
261 CREATE TABLE `0_trans_tax_details` (
262 `id` int(11) NOT NULL auto_increment,
263 `trans_type` smallint(6) default NULL,
264 `trans_no` int(11) default NULL,
265 `tran_date` date NOT NULL,
266 `tax_type_id` int(11) NOT NULL default '0',
267 `rate` double NOT NULL default '0',
268 `ex_rate` double NOT NULL default '1',
269 `included_in_price` tinyint(1) NOT NULL default '0',
270 `net_amount` double NOT NULL default '0',
271 `amount` double NOT NULL default '0',
272 `memo` tinytext default NULL,
274 ) TYPE=InnoDB AUTO_INCREMENT=1 ;