summaryrefslogtreecommitdiff
path: root/sql/Pg-upgrade-2.3.4-2.3.5.sql
blob: f4ab90baae85e69304ab10893f0b6f0384b485fd (plain)
  1. --
  2. create table temp (
  3. id int default nextval('id'),
  4. name varchar(64),
  5. address1 varchar(32),
  6. address2 varchar(32),
  7. city varchar(32),
  8. state varchar(32),
  9. zipcode varchar(10),
  10. country varchar(32),
  11. contact varchar(64),
  12. phone varchar(20),
  13. fax varchar(20),
  14. email text,
  15. notes text,
  16. discount float4,
  17. taxincluded bool default 'f',
  18. creditlimit float default 0,
  19. terms int2 default 0,
  20. customernumber varchar(32),
  21. cc text,
  22. bcc text,
  23. business_id int,
  24. taxnumber varchar(32),
  25. sic_code varchar(6),
  26. iban varchar(34),
  27. bic varchar(11),
  28. employee_id int
  29. );
  30. --
  31. insert into temp (id,name,address1,city,country,state,contact,phone,fax,email,notes,discount,taxincluded,creditlimit,terms,customernumber,cc,bcc,business_id,taxnumber,sic_code,iban,bic,employee_id) select id,name,substr(addr1,1,32),substr(addr2,1,32),substr(addr3,1,32),substr(addr4,1,32),contact,phone,fax,email,notes,discount,taxincluded,creditlimit,terms,substr(customernumber,1,32),cc,bcc,business_id,substr(taxnumber,1,32),sic_code,iban,bic,employee_id from customer;
  32. --
  33. drop table customer;
  34. alter table temp rename to customer;
  35. --
  36. create index customer_id_key on customer (id);
  37. create index customer_customernumber_key on customer (customernumber);
  38. create index customer_name_key on customer (name);
  39. create index customer_contact_key on customer (contact);
  40. --
  41. create trigger del_customer after delete on customer for each row execute procedure del_customer();
  42. -- end trigger
  43. --
  44. create table temp (
  45. id int default nextval('id'),
  46. name varchar(64),
  47. address1 varchar(32),
  48. address2 varchar(32),
  49. city varchar(32),
  50. state varchar(32),
  51. zipcode varchar(10),
  52. country varchar(32),
  53. contact varchar(64),
  54. phone varchar(20),
  55. fax varchar(20),
  56. email text,
  57. notes text,
  58. terms int2 default 0,
  59. taxincluded bool default 'f',
  60. vendornumber varchar(32),
  61. cc text,
  62. bcc text,
  63. gifi_accno varchar(30),
  64. business_id int,
  65. taxnumber varchar(32),
  66. sic_code varchar(6),
  67. discount float4,
  68. creditlimit float default 0,
  69. iban varchar(34),
  70. bic varchar(11),
  71. employee_id int
  72. );
  73. --
  74. insert into temp (id,name,address1,city,country,state,contact,phone,fax,email,notes,terms,taxincluded,vendornumber,cc,bcc,gifi_accno,business_id,taxnumber,sic_code,discount,creditlimit,iban,bic,employee_id) select id,name,substr(addr1,1,32),substr(addr2,1,32),substr(addr3,1,32),substr(addr4,1,32),contact,phone,fax,email,notes,terms,taxincluded,substr(vendornumber,1,32),cc,bcc,gifi_accno,business_id,substr(taxnumber,1,32),sic_code,discount,creditlimit,iban,bic,employee_id from vendor;
  75. --
  76. drop table vendor;
  77. alter table temp rename to vendor;
  78. --
  79. create index vendor_id_key on vendor (id);
  80. create index vendor_name_key on vendor (name);
  81. create index vendor_vendornumber_key on vendor (vendornumber);
  82. create index vendor_contact_key on vendor (contact);
  83. --
  84. create trigger del_vendor after delete on vendor for each row execute procedure del_vendor();
  85. -- end trigger
  86. --
  87. create table temp (
  88. trans_id int,
  89. shiptoname varchar(64),
  90. shiptoaddress1 varchar(32),
  91. shiptoaddress2 varchar(32),
  92. shiptocity varchar(32),
  93. shiptostate varchar(32),
  94. shiptozipcode varchar(10),
  95. shiptocountry varchar(32),
  96. shiptocontact varchar(64),
  97. shiptophone varchar(20),
  98. shiptofax varchar(20),
  99. shiptoemail text
  100. );
  101. --
  102. insert into temp (trans_id,shiptoname,shiptoaddress1,shiptocity,shiptocountry,shiptostate,shiptocontact,shiptophone,shiptofax,shiptoemail) select trans_id,shiptoname,substr(shiptoaddr1,1,32),substr(shiptoaddr2,1,32),substr(shiptoaddr3,1,32),substr(shiptoaddr4,1,32),shiptocontact,shiptophone,shiptofax,shiptoemail from shipto;
  103. --
  104. drop table shipto;
  105. alter table temp rename to shipto;
  106. create index shipto_trans_id_key on shipto (trans_id);
  107. --
  108. create table temp (
  109. id int default nextval('id'),
  110. login text,
  111. name varchar(64),
  112. address1 varchar(32),
  113. address2 varchar(32),
  114. city varchar(32),
  115. state varchar(32),
  116. zipcode varchar(10),
  117. country varchar(32),
  118. workphone varchar(20),
  119. homephone varchar(20),
  120. startdate date default current_date,
  121. enddate date,
  122. notes text,
  123. role varchar(20),
  124. sales bool default 'f',
  125. email text,
  126. sin varchar(20),
  127. iban varchar(34),
  128. bic varchar(11),
  129. managerid int
  130. );
  131. --
  132. insert into temp (id,login,name,address1,city,country,state,workphone,homephone,startdate,enddate,notes,role,sales,email,sin,iban,bic,managerid) select id,login,name,substr(addr1,1,32),substr(addr2,1,32),substr(addr3,1,32),substr(addr4,1,32),workphone,homephone,startdate,enddate,notes,role,sales,email,sin,iban,bic,managerid from employee;
  133. --
  134. drop table employee;
  135. alter table temp rename to employee;
  136. --
  137. create index employee_id_key on employee (id);
  138. create unique index employee_login_key on employee (login);
  139. create index employee_name_key on employee (name);
  140. --
  141. update defaults set version = '2.3.5';