Added Attachment of Documents and a couple of links from supplier invoice/crfedit...
[fa-stable.git] / sql / alter2.1.sql
1 DROP TABLE IF EXISTS `0_attachments`;
2
3 CREATE TABLE `0_attachments` (
4   `id` int(11) NOT NULL auto_increment,
5   `description` varchar(60) NOT NULL default '',
6   `type_no` int(11) NOT NULL default '0',
7   `trans_no` int(11) NOT NULL default '0',
8   `bin_data` mediumblob NOT NULL,
9   `tran_date` date NOT NULL default '0000-00-00',
10   `filename` varchar(60) NOT NULL default '',
11   `filesize` int(11) NOT NULL default '0',
12   `filetype` varchar(60) NOT NULL default '',
13   PRIMARY KEY  (`id`),
14   KEY `type_no` (`type_no`,`trans_no`)
15 ) TYPE=MyISAM AUTO_INCREMENT=1 ;
16
17 DROP TABLE IF EXISTS `0_groups`;
18
19 CREATE TABLE `0_groups` (
20   `id` int(11) NOT NULL auto_increment,
21   `description` varchar(60) NOT NULL default '',
22   PRIMARY KEY  (`id`),
23   UNIQUE KEY `description` (`description`)
24 ) TYPE=MyISAM AUTO_INCREMENT=1 ;
25
26 INSERT INTO `0_groups` VALUES ('1', 'Small');
27 INSERT INTO `0_groups` VALUES ('2', 'Medium');
28 INSERT INTO `0_groups` VALUES ('3', 'Large');
29
30 DROP TABLE IF EXISTS `0_recurrent_invoices`;
31
32 CREATE TABLE `0_recurrent_invoices` (
33   `id` int(11) NOT NULL auto_increment,
34   `description` varchar(60) NOT NULL default '',
35   `order_no` int(11) NOT NULL default '0',
36   `debtor_no` int(11) NOT NULL default '0',
37   `group_no` int(11) NOT NULL default '0',
38   `days` int(11) NOT NULL default '0',
39   `monthly` int(11) NOT NULL default '0',
40   `begin` date NOT NULL default '0000-00-00',
41   `end` date NOT NULL default '0000-00-00',
42   `last_sent` date NOT NULL default '0000-00-00',
43   PRIMARY KEY  (`id`),
44   UNIQUE KEY `description` (`description`)
45 ) TYPE=InnoDB AUTO_INCREMENT=1 ;
46
47 ALTER TABLE `0_cust_branch` ADD `group_no` int(11) NOT NULL default '0';
48
49 ALTER TABLE `0_debtor_trans` ADD `dimension_id` int(11) NOT NULL default '0';
50 ALTER TABLE `0_debtor_trans` ADD `dimension2_id` int(11) NOT NULL default '0';
51
52 DROP TABLE IF EXISTS `0_bank_trans_types`;
53
54 ALTER TABLE `0_bank_accounts` DROP PRIMARY KEY;
55 ALTER TABLE `0_bank_accounts` ADD `id` SMALLINT(6) AUTO_INCREMENT PRIMARY KEY;
56 ALTER TABLE `0_bank_accounts` ADD KEY (`account_code`);
57
58 # Version for any MySQL but usable with digital only gl account codes:
59 # UPDATE 0_bank_accounts SET id = account_code;
60 # For any Applicable only to  MySQL >=4.0.4 :
61 UPDATE `0_bank_trans`, `0_bank_accounts` SET 0_bank_trans.bank_act=0_bank_accounts.id 
62         WHERE 0_bank_trans.bank_act=0_bank_accounts.account_code; 
63
64
65 ALTER TABLE `0_users` ADD `query_size` TINYINT(1) DEFAULT '10';
66
67 DROP TABLE IF EXISTS `0_sales_pos`;
68
69 CREATE TABLE `0_sales_pos` (
70   `id` smallint(6) NOT NULL auto_increment,
71   `pos_name` varchar(30) NOT NULL,
72   `cash_sale` tinyint(1) NOT NULL,
73   `credit_sale` tinyint(1) NOT NULL,
74   `pos_location` varchar(5) NOT NULL,
75   `pos_account` varchar(11) NOT NULL,
76   PRIMARY KEY  (`id`),
77   UNIQUE KEY(`pos_name`)
78 ) TYPE=MyISAM AUTO_INCREMENT=1;
79
80 INSERT INTO `0_sales_pos` VALUES ('1', 'Default', '1', '1', 'DEF', '1');
81
82 ALTER TABLE `0_users` ADD `pos` SMALLINT(6) DEFAULT '1';
83
84 DROP TABLE IF EXISTS `0_quick_entries`;
85
86 CREATE TABLE `0_quick_entries` (
87   `id` smallint(6) NOT NULL auto_increment,
88   `description` varchar(60) NOT NULL,
89   `deposit` tinyint(1) NOT NULL default '0',
90   `bank_only` tinyint(1) NOT NULL default '0',
91   PRIMARY KEY  (`id`),
92   KEY `description` (`description`)
93 ) TYPE=MyISAM AUTO_INCREMENT=1;
94
95 INSERT INTO `0_quick_entries` VALUES ('1', 'Maintenance', '0', '1');
96 INSERT INTO `0_quick_entries` VALUES ('2', 'Phone', '0', '1');
97 INSERT INTO `0_quick_entries` VALUES ('3', 'Cash Sales', '1', '1');
98
99 DROP TABLE IF EXISTS `0_quick_entry_lines`;
100
101 CREATE TABLE `0_quick_entry_lines` (
102   `id` smallint(6) NOT NULL auto_increment,
103   `qid` smallint(6) NOT NULL,
104   `account` varchar(11) NOT NULL,
105   `tax_acc` tinyint(1) NOT NULL default '0',
106   `pct` tinyint(1) NOT NULL default '0',
107   `amount` double default NULL default '0',
108   `dimension_id` int(11) NOT NULL default '0',
109   `dimension2_id` int(11) NOT NULL default '0',
110   PRIMARY KEY  (`id`),
111   KEY `qid` (`qid`)
112 ) TYPE=MyISAM AUTO_INCREMENT=1;
113
114 INSERT INTO `0_quick_entry_lines` VALUES ('1', '1', '6600', '1', '0', 0, '0', '0');
115 INSERT INTO `0_quick_entry_lines` VALUES ('2', '2', '6730', '1', '0', 0, '0', '0');
116 INSERT INTO `0_quick_entry_lines` VALUES ('3', '3', '3000', '1', '0', 0, '0', '0');
117
118 ALTER TABLE `0_users` ADD `print_profile` VARCHAR(30) DEFAULT '' AFTER `show_hints` ;
119 ALTER TABLE `0_users` ADD `rep_popup` TINYINT(1) DEFAULT '1' AFTER `print_profile` ;
120
121 DROP TABLE IF EXISTS `0_print_profiles`;
122 CREATE TABLE `0_print_profiles` (
123   `id` tinyint(11) NOT NULL auto_increment,
124   `profile` varchar(30) NOT NULL,
125   `report` varchar(5) NOT NULL,
126   `printer` tinyint(5) NOT NULL,
127   PRIMARY KEY  (`id`),
128   UNIQUE KEY `profile` (`profile`,`report`)
129 ) TYPE=MyISAM AUTO_INCREMENT=10;
130
131 INSERT INTO `0_print_profiles` VALUES ('1', 'Out of office', '', '0');
132 INSERT INTO `0_print_profiles` VALUES ('2', 'Sales Department', '', '0');
133 INSERT INTO `0_print_profiles` VALUES ('3', 'Central', '', '2');
134 INSERT INTO `0_print_profiles` VALUES ('4', 'Sales Department', '104', '2');
135 INSERT INTO `0_print_profiles` VALUES ('5', 'Sales Department', '105', '2');
136 INSERT INTO `0_print_profiles` VALUES ('6', 'Sales Department', '107', '2');
137 INSERT INTO `0_print_profiles` VALUES ('7', 'Sales Department', '109', '2');
138 INSERT INTO `0_print_profiles` VALUES ('8', 'Sales Department', '110', '2');
139 INSERT INTO `0_print_profiles` VALUES ('9', 'Sales Department', '201', '2');
140
141 DROP TABLE IF EXISTS `0_printers`;
142
143 CREATE TABLE `0_printers` (
144   `id` smallint(6) NOT NULL auto_increment,
145   `name` varchar(20) NOT NULL,
146   `description` varchar(60) NOT NULL,
147   `queue` varchar(20) NOT NULL,
148   `host` varchar(40) NOT NULL,
149   `port` smallint(11) unsigned NOT NULL,
150   `timeout` tinyint(3) unsigned NOT NULL,
151   PRIMARY KEY  (`id`),
152   UNIQUE KEY `name` (`name`)
153 ) TYPE=MyISAM AUTO_INCREMENT=4;
154
155 INSERT INTO `0_printers` VALUES ('1', 'QL500', 'Label printer', 'QL500', 'server', '127', '20');
156 INSERT INTO `0_printers` VALUES ('2', 'Samsung', 'Main network printer', 'scx4521F', 'server', '515', '5');
157 INSERT INTO `0_printers` VALUES ('3', 'Local', 'Local print server at user IP', 'lp', '', '515', '10');