1 -- Updatescript von Version SQLedger 2.x auf 2.00
2 -- H.Lindemann Lx-System GbR
7 LOCK TABLE gl IN ACCESS EXCLUSIVE MODE;
8 LOCK TABLE ar IN ACCESS EXCLUSIVE MODE;
9 LOCK TABLE ap IN ACCESS EXCLUSIVE MODE;
10 LOCK TABLE vendor IN ACCESS EXCLUSIVE MODE;
11 LOCK TABLE customer IN ACCESS EXCLUSIVE MODE;
12 LOCK TABLE employee IN ACCESS EXCLUSIVE MODE;
13 LOCK TABLE shipto IN ACCESS EXCLUSIVE MODE;
15 CREATE SEQUENCE glid start 1 increment 1 maxvalue 9223372036854775807 minvalue 1 cache 1;
17 CREATE FUNCTION _glid()
19 AS 'DECLARE lv record;
21 SELECT INTO lv last_value from id;
22 execute ''SELECT pg_catalog.setval(''''glid'''', '' || lv.last_value || '' , true)'';
23 return cast(lv.last_value as text);
27 drop function _glid();
30 ALTER TABLE gl ALTER COLUMN id SET DEFAULT nextval('glid'::text);
31 ALTER TABLE gl ADD COLUMN gldate date;
32 ALTER TABLE gl ALTER COLUMN gldate SET DEFAULT date('now'::text);
33 ALTER TABLE gl ADD COLUMN taxinxluded boolean;
36 ALTER TABLE chart ADD COLUMN taxkey_id integer;
37 ALTER TABLE chart ADD COLUMN pos_ustva integer;
38 ALTER TABLE chart ADD COLUMN pos_bwa integer;
39 ALTER TABLE chart ADD COLUMN pos_bilanz integer;
40 ALTER TABLE chart ADD COLUMN pos_eur integer;
43 --ALTER TABLE defaults drop COLUMN audittrail;
46 ALTER TABLE acc_trans ADD COLUMN taxkey integer;
47 ALTER TABLE acc_trans ADD COLUMN gldate date;
48 ALTER TABLE acc_trans ALTER COLUMN gldate SET DEFAULT date('now'::text);
51 CREATE TABLE newvendor (
52 id integer DEFAULT nextval('id'::text),
53 name character varying(75),
54 street character varying(75),
55 zipcode character varying(10),
56 city character varying(75),
57 country character varying(75),
58 contact character varying(75),
59 phone character varying(30),
60 fax character varying(30),
64 terms smallint DEFAULT 0,
74 creditlimit double precision
76 INSERT INTO newvendor (
77 id, name, street,zipcode,city,country,contact,phone,fax,homepage,email,notes,terms,taxincluded,
78 vendornumber,cc,bcc,gifi_accno,business_id,taxnumber,sic_code,discount,creditlimit)
80 id, name, address1,zipcode,city,country,contact,phone, fax,null,email,notes,terms,taxincluded,
81 vendornumber,cc,bcc,gifi_accno,business_id,taxnumber,sic_code,discount,creditlimit
83 --address2, state, iban, bic, employee_id, language_code, pricegroup_id, curr
85 ALTER TABLE newvendor RENAME TO vendor;
88 CREATE TABLE newcustomer (
89 id integer DEFAULT nextval('id'::text),
90 name character varying(75),
91 street character varying(75),
92 zipcode character varying(10),
93 city character varying(75),
94 country character varying(75),
95 contact character varying(75),
96 phone character varying(30),
97 fax character varying(30),
103 creditlimit double precision DEFAULT 0,
104 terms smallint DEFAULT 0,
112 INSERT INTO newcustomer (
113 id,name,street,zipcode,city,country,contact,phone,fax,homepage,email,notes,discount,taxincluded,creditlimit,
114 terms,customernumber,cc,bcc,business_id,taxnumber,sic_code)
116 id,name,address1,zipcode,city,country,contact,phone,fax,null,email,notes,discount,taxincluded,creditlimit,
117 terms,customernumber,cc,bcc,business_id,taxnumber,sic_code
119 --address2, state, iban, bic, employee_id, language_code, pricegroup_id, curr
121 ALTER TABLE newcustomer RENAME TO customer;
124 CREATE TABLE contacts (
125 cp_id integer DEFAULT nextval('id'::text),
127 cp_greeting character varying(75),
128 cp_title character varying(75),
129 cp_givenname character varying(75),
130 cp_name character varying(75),
132 cp_phone1 character varying(75),
133 cp_phone2 character varying(75)
137 ALTER TABLE parts ADD COLUMN shop boolean;
138 ALTER TABLE parts ALTER COLUMN shop SET DEFAULT false;
141 ALTER TABLE ar ALTER COLUMN id SET DEFAULT nextval('glid'::text);
142 ALTER TABLE ar ADD COLUMN gldate date;
143 ALTER TABLE ar ALTER COLUMN gldate SET DEFAULT date('now'::text);
144 --ALTER TABLE ar DROP COLUMN language_code;
145 --ALTER TABLE ar DROP COLUMN till;
148 ALTER TABLE ap ALTER COLUMN id SET DEFAULT nextval('glid'::text);
149 ALTER TABLE ap ADD COLUMN gldate date;
150 ALTER TABLE ap ALTER COLUMN gldate SET DEFAULT date('now'::text);
151 --ALTER TABLE ap DROP COLUMN language_code;
152 --ALTER TABLE ap DROP COLUMN till;
155 ALTER TABLE tax ADD COLUMN taxkey integer;
156 ALTER TABLE tax ADD COLUMN taxdescription text;
159 ALTER TABLE oe DROP COLUMN language_code;
162 CREATE TABLE newemployee (
163 id integer DEFAULT nextval('id'::text),
165 name character varying(35),
166 addr1 character varying(35),
167 addr2 character varying(35),
168 addr3 character varying(35),
169 addr4 character varying(35),
170 workphone character varying(20),
171 homephone character varying(20),
172 startdate date DEFAULT date('now'::text),
176 sales boolean DEFAULT true
178 INSERT INTO newemployee (
179 id,login,name,addr1,addr2,addr3,addr4,workphone,homephone,startdate,enddate,notes,role,sales)
181 id,login,name,address1,zipcode,city,address2, workphone,homephone,startdate,enddate,notes,role,sales
183 --address2,state, country, email, sin, iban, bic, managerid
185 ALTER TABLE newemployee RENAME TO employee;
188 CREATE TABLE newshipto (
190 shiptoname character varying(75),
191 shiptostreet character varying(75),
192 shiptozipcode character varying(75),
193 shiptocity character varying(75),
194 shiptocountry character varying(75),
195 shiptocontact character varying(75),
196 shiptophone character varying(30),
197 shiptofax character varying(30),
200 INSERT INTO newshipto(
201 trans_id,shiptoname,shiptostreet,shiptozipcode,shiptocity,shiptocountry,shiptocontact,shiptophone,shiptofax,shiptoemail)
203 trans_id,shiptoname,shiptoaddress1,shiptozipcode,shiptocity,shiptocountry,shiptocontact,shiptophone,shiptofax,shiptoemail
205 -- shiptoaddress2,shiptostate,
207 ALTER TABLE newshipto RENAME TO shipto;
210 ALTER TABLE sic ADD COLUMN newcode text;
211 UPDATE sic set newcode=code;
212 ALTER TABLE sic drop COLUMN code;
213 ALTER TABLE sic RENAME COLUMN newcode TO code;
216 --DROP TABLE yearend;
219 --DROP TABLE partsvendor;
222 --DROP TABLE pricegroup;
225 --DROP TABLE partscustomer;
228 --DROP TABLE language;
231 --DROP TABLE audittrail;
234 --DROP TABLE translation;
237 CREATE INDEX contact_name_key ON contacts USING btree (cp_name);
239 update defaults set version = '2.0.0';