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 INSERT INTO `0_sales_pos` VALUES ('1', 'Default', '1', '1', 'DEF', '1', '0');
94 ALTER TABLE `0_users` ADD `pos` SMALLINT(6) DEFAULT '1';
96 DROP TABLE IF EXISTS `0_quick_entries`;
98 CREATE TABLE `0_quick_entries` (
99 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
100 `type` tinyint(1) NOT NULL default '0',
101 `description` varchar(60) NOT NULL,
102 `base_amount` double NOT NULL default '0',
103 `base_desc` varchar(60) NULL,
105 KEY `description` (`description`)
106 ) TYPE=MyISAM AUTO_INCREMENT=1;
108 INSERT INTO `0_quick_entries` VALUES ('1', '1', 'Maintenance', '0', 'Amount');
109 INSERT INTO `0_quick_entries` VALUES ('2', '1', 'Phone', '0', 'Amount');
110 INSERT INTO `0_quick_entries` VALUES ('3', '2', 'Cash Sales', '0', 'Amount');
112 DROP TABLE IF EXISTS `0_quick_entry_lines`;
114 CREATE TABLE `0_quick_entry_lines` (
115 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
116 `qid` smallint(6) UNSIGNED NOT NULL,
117 `amount` double default NULL default '0',
118 `action` varchar(2) NOT NULL,
119 `dest_id` varchar(11) NOT NULL,
120 `dimension_id` smallint(6) UNSIGNED NULL default NULL,
121 `dimension2_id` smallint(6) UNSIGNED NULL default NULL,
124 ) TYPE=MyISAM AUTO_INCREMENT=1;
126 INSERT INTO `0_quick_entry_lines` VALUES ('1', '1','0','=', '6600', '0', '0');
127 INSERT INTO `0_quick_entry_lines` VALUES ('2', '2','0','=', '6730', '0', '0');
128 INSERT INTO `0_quick_entry_lines` VALUES ('3', '3','0','=', '3000', '0', '0');
130 ALTER TABLE `0_users` ADD `print_profile` VARCHAR(30) NOT NULL DEFAULT '1';
131 ALTER TABLE `0_users` ADD `rep_popup` TINYINT(1) DEFAULT '1';
133 DROP TABLE IF EXISTS `0_print_profiles`;
134 CREATE TABLE `0_print_profiles` (
135 `id` smallint(6) UNSIGNED NOT NULL auto_increment,
136 `profile` varchar(30) NOT NULL,
137 `report` varchar(5) NULL default NULL,
138 `printer` tinyint(3) UNSIGNED NULL default NULL,
140 UNIQUE KEY `profile` (`profile`,`report`)
141 ) TYPE=MyISAM AUTO_INCREMENT=10;
143 INSERT INTO `0_print_profiles` VALUES ('1', 'Out of office', '', '0');
144 INSERT INTO `0_print_profiles` VALUES ('2', 'Sales Department', '', '0');
145 INSERT INTO `0_print_profiles` VALUES ('3', 'Central', '', '2');
146 INSERT INTO `0_print_profiles` VALUES ('4', 'Sales Department', '104', '2');
147 INSERT INTO `0_print_profiles` VALUES ('5', 'Sales Department', '105', '2');
148 INSERT INTO `0_print_profiles` VALUES ('6', 'Sales Department', '107', '2');
149 INSERT INTO `0_print_profiles` VALUES ('7', 'Sales Department', '109', '2');
150 INSERT INTO `0_print_profiles` VALUES ('8', 'Sales Department', '110', '2');
151 INSERT INTO `0_print_profiles` VALUES ('9', 'Sales Department', '201', '2');
153 DROP TABLE IF EXISTS `0_printers`;
155 CREATE TABLE `0_printers` (
156 `id` tinyint(3) UNSIGNED NOT NULL auto_increment,
157 `name` varchar(20) NOT NULL,
158 `description` varchar(60) NOT NULL,
159 `queue` varchar(20) NOT NULL,
160 `host` varchar(40) NOT NULL,
161 `port` smallint(11) unsigned NOT NULL,
162 `timeout` tinyint(3) unsigned NOT NULL,
164 UNIQUE KEY `name` (`name`)
165 ) TYPE=MyISAM AUTO_INCREMENT=4;
167 INSERT INTO `0_printers` VALUES ('1', 'QL500', 'Label printer', 'QL500', 'server', '127', '20');
168 INSERT INTO `0_printers` VALUES ('2', 'Samsung', 'Main network printer', 'scx4521F', 'server', '515', '5');
169 INSERT INTO `0_printers` VALUES ('3', 'Local', 'Local print server at user IP', 'lp', '', '515', '10');
171 DROP TABLE IF EXISTS `0_item_codes`;
173 CREATE TABLE `0_item_codes` (
174 `id` int(11) UNSIGNED NOT NULL auto_increment,
175 `item_code` varchar(20) NOT NULL,
176 `stock_id` varchar(20) NOT NULL,
177 `description` varchar(200) NOT NULL default '',
178 `category_id` smallint(6) UNSIGNED NOT NULL,
179 `quantity` double NOT NULL default '1',
180 `is_foreign` tinyint(1) NOT NULL default 0,
181 `inactive` tinyint(1) NOT NULL default 0,
183 UNIQUE KEY(`stock_id`, `item_code`)
184 ) TYPE=MyISAM AUTO_INCREMENT=1;
186 ALTER TABLE `0_company` ADD `foreign_codes` TINYINT(1) NOT NULL DEFAULT '0';
188 ALTER TABLE `0_company` ADD `accumulate_shipping` TINYINT(1) NOT NULL DEFAULT '0';
190 ALTER TABLE `0_company` ADD `legal_text` tinytext NOT NULL DEFAULT '';
192 ALTER TABLE `0_suppliers` ADD `supp_address` tinytext NOT NULL DEFAULT '' AFTER `address`;
194 ALTER TABLE `0_suppliers` ADD `phone` varchar(30) NOT NULL DEFAULT '' AFTER `supp_address`;
196 ALTER TABLE `0_suppliers` ADD `fax` varchar(30) NOT NULL DEFAULT '' AFTER `phone`;
198 ALTER TABLE `0_suppliers` ADD `gst_no` varchar(25) NOT NULL DEFAULT '' AFTER `fax`;
200 ALTER TABLE `0_suppliers` ADD `contact` varchar(60) NOT NULL DEFAULT '' AFTER `gst_no`;
202 ALTER TABLE `0_suppliers` ADD `credit_limit` double NOT NULL DEFAULT '0' AFTER `tax_group_id`;
204 ALTER TABLE `0_suppliers` ADD `supp_account_no` varchar(40) NOT NULL DEFAULT '' AFTER `contact`;
206 ALTER TABLE `0_suppliers` ADD `website` varchar(100) NOT NULL DEFAULT '' AFTER `email`;
208 ALTER TABLE `0_suppliers` ADD `notes` tinytext NOT NULL DEFAULT '';
210 ALTER TABLE `0_chart_types` DROP INDEX `name`, ADD INDEX `name` ( `name` );
212 DROP TABLE IF EXISTS `0_sql_trail`;
214 CREATE TABLE IF NOT EXISTS `0_sql_trail` (
215 `id` int(11) UNSIGNED NOT NULL auto_increment,
217 `result` tinyint(1) NOT NULL,
218 `msg` varchar(255) NOT NULL,
222 ALTER TABLE `0_tax_types` DROP COLUMN `out`;
224 ALTER TABLE `0_chart_master` DROP COLUMN `tax_code`;
226 ALTER TABLE `0_chart_master` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
228 ALTER TABLE `0_currencies` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
230 ALTER TABLE `0_bank_accounts` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
232 ALTER TABLE `0_debtors_master` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
234 ALTER TABLE `0_stock_master` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
236 ALTER TABLE `0_workcentres` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
238 ALTER TABLE `0_locations` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
240 ALTER TABLE `0_sales_types` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
242 ALTER TABLE `0_areas` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
244 ALTER TABLE `0_salesman` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
246 ALTER TABLE `0_shippers` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
248 ALTER TABLE `0_credit_status` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
250 ALTER TABLE `0_payment_terms` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
252 ALTER TABLE `0_suppliers` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
254 ALTER TABLE `0_stock_category` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
256 ALTER TABLE `0_item_units` ADD `inactive` tinyint(1) NOT NULL DEFAULT '0';
258 DROP TABLE IF EXISTS `0_trans_tax_details`;
260 CREATE TABLE `0_trans_tax_details` (
261 `id` int(11) NOT NULL auto_increment,
262 `trans_type` smallint(6) default NULL,
263 `trans_no` int(11) default NULL,
264 `tran_date` date NOT NULL,
265 `tax_type_id` int(11) NOT NULL default '0',
266 `rate` double NOT NULL default '0',
267 `ex_rate` double NOT NULL default '1',
268 `included_in_price` tinyint(1) NOT NULL default '0',
269 `net_amount` double NOT NULL default '0',
270 `amount` double NOT NULL default '0',
271 `memo` tinytext default NULL,
273 ) TYPE=InnoDB AUTO_INCREMENT=1 ;