This commit was generated by cvs2svn to compensate for changes in r3880,
[freeside.git] / sql-ledger / old / sql-ledger / sql / Pg-upgrade-1.8.5-2.0.0.sql
1 --
2 alter table customer add column cc text;
3 alter table customer add column bcc text;
4 --
5 alter table vendor add column cc text;
6 alter table vendor add column bcc text;
7 --
8 create table shipto (
9   trans_id int,
10   shiptoname varchar(35),
11   shiptoaddr1 varchar(35),
12   shiptoaddr2 varchar(35),
13   shiptoaddr3 varchar(35),
14   shiptoaddr4 varchar(35),
15   shiptocontact varchar(35),
16   shiptophone varchar(20),
17   shiptofax varchar(20),
18   shiptoemail text
19 );
20 --
21 insert into shipto (trans_id, shiptoname, shiptoaddr1, shiptoaddr2, shiptoaddr3, shiptoaddr4, shiptocontact, shiptophone, shiptofax, shiptoemail) select id, shiptoname, shiptoaddr1, shiptoaddr2, shiptoaddr3, shiptoaddr4, shiptocontact, shiptophone, shiptofax, shiptoemail from customer where shiptoname != '' or shiptoname is not null;
22 --
23 insert into shipto (trans_id, shiptoname, shiptoaddr1, shiptoaddr2, shiptoaddr3, shiptoaddr4, shiptocontact, shiptophone, shiptofax, shiptoemail) select distinct on (a.id) a.id, c.shiptoname, c.shiptoaddr1, c.shiptoaddr2, c.shiptoaddr3, c.shiptoaddr4, c.shiptocontact, c.shiptophone, c.shiptofax, c.shiptoemail from customer c, ar a where a.customer_id = c.id;
24 --
25 insert into shipto (trans_id, shiptoname, shiptoaddr1, shiptoaddr2, shiptoaddr3, shiptoaddr4, shiptocontact, shiptophone, shiptofax, shiptoemail) select distinct on (o.id) o.id, c.shiptoname, c.shiptoaddr1, c.shiptoaddr2, c.shiptoaddr3, c.shiptoaddr4, c.shiptocontact, c.shiptophone, c.shiptofax, c.shiptoemail from customer c, oe o where o.customer_id = c.id;
26 --
27 create index shipto_trans_id_key on shipto (trans_id);
28 --
29 create table custome (
30   id int default nextval('id'),
31   name varchar(35),
32   addr1 varchar(35),
33   addr2 varchar(35),
34   addr3 varchar(35),
35   addr4 varchar(35),
36   contact varchar(35),
37   phone varchar(20),
38   fax varchar(20),
39   email text,
40   notes text,
41   discount float4,
42   taxincluded bool,
43   creditlimit float DEFAULT 0,
44   terms int2 DEFAULT 0,
45   customernumber text,
46   cc text,
47   bcc text
48 );
49 insert into custome (id, name, addr1, addr2, addr3, addr4, contact, phone, fax, email, notes, discount, taxincluded, creditlimit, terms, customernumber) select id, name, addr1, addr2, addr3, addr4, contact, phone, fax, email, notes, discount, taxincluded, creditlimit, terms, customernumber from customer;
50 --
51 drop table customer;
52 alter table custome rename to customer;
53 create index customer_id_key on customer (id);
54 create index customer_name_key on customer (name);
55 create index customer_contact_key on customer (contact);
56 --
57 alter table parts add column bom boolean;
58 alter table parts alter column bom set default 'f';
59 update parts set bom = 'f';
60 update parts set bom = 't' where assembly;
61 alter table parts add column image text;
62 alter table parts add column drawing text;
63 alter table parts add column microfiche text;
64 --
65 alter table gl add column notes text;
66 --
67 alter table oe add column closed bool;
68 alter table oe alter column closed set default 'f';
69 update oe set closed = 'f';
70 --
71 create table project (
72   id int default nextval('id'),
73   projectnumber text,
74   description text
75 );
76 --
77 create index project_id_key on project (id);
78 --
79 alter table acc_trans add column project_id int;
80 update acc_trans set cleared = '0' where cleared = '1';
81 --
82 alter table invoice add column project_id int;
83 alter table invoice add column deliverydate date;
84 alter table orderitems add column project_id int;
85 alter table orderitems add column reqdate date;
86 --
87 alter table gl rename source to reference;
88 create index gl_reference_key on gl (reference);
89 create index acc_trans_source_key on acc_trans (lower(source));
90 --
91 update defaults set version = '2.0.0';
92 --