summaryrefslogtreecommitdiff
path: root/sql/Pg-upgrade-1.2.7-1.4.0.sql
blob: 04e1a794388a1b3de6cc9635545e9240e272accc (plain)
  1. --
  2. CREATE TABLE newap (
  3. id int DEFAULT nextval ( 'id' ),
  4. invnumber text,
  5. transdate date DEFAULT current_date,
  6. vendor int,
  7. taxincluded bool DEFAULT FALSE,
  8. amount float,
  9. netamount float,
  10. paid float,
  11. datepaid date,
  12. duedate date,
  13. invoice bool DEFAULT FALSE,
  14. ordnumber text
  15. );
  16. --
  17. INSERT INTO newap (id, invnumber, transdate, vendor, amount, netamount, paid,
  18. datepaid, duedate, invoice, ordnumber)
  19. SELECT id, invnumber, transdate, vendor, amount, netamount, paid,
  20. datepaid, duedate, invoice, ordnumber
  21. FROM ap;
  22. --
  23. DROP TABLE ap;
  24. ALTER TABLE newap RENAME TO ap;
  25. --
  26. CREATE TABLE newar (
  27. id int DEFAULT nextval ( 'id' ),
  28. invnumber text,
  29. transdate date DEFAULT current_date,
  30. customer int,
  31. taxincluded bool DEFAULT FALSE,
  32. amount float,
  33. netamount float,
  34. paid float,
  35. datepaid date,
  36. duedate date,
  37. invoice bool DEFAULT FALSE,
  38. shippingpoint text,
  39. terms int2,
  40. notes text
  41. );
  42. --
  43. INSERT INTO newar (id, invnumber, transdate, customer, amount, netamount, paid,
  44. datepaid, duedate, invoice, shippingpoint, terms, notes)
  45. SELECT id, invnumber, transdate, customer, amount, netamount, paid,
  46. datepaid, duedate, invoice, shippingpoint, terms, notes
  47. FROM ar;
  48. --
  49. DROP TABLE ar;
  50. ALTER TABLE newar RENAME TO ar;
  51. --
  52. CREATE TABLE newcustomer (
  53. id int DEFAULT nextval ( 'id' ),
  54. name varchar(35),
  55. addr1 varchar(35),
  56. addr2 varchar(35),
  57. addr3 varchar(35),
  58. contact varchar(35),
  59. phone varchar(20),
  60. fax varchar(20),
  61. email text,
  62. notes text,
  63. ytd float,
  64. discount float4,
  65. taxincluded bool,
  66. creditlimit float,
  67. terms int2,
  68. shiptoname varchar(35),
  69. shiptoaddr1 varchar(35),
  70. shiptoaddr2 varchar(35),
  71. shiptoaddr3 varchar(35),
  72. shiptocontact varchar(20),
  73. shiptophone varchar(20),
  74. shiptofax varchar(20),
  75. shiptoemail text
  76. );
  77. INSERT INTO newcustomer (
  78. id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, ytd,
  79. discount, creditlimit, terms, shiptoname, shiptoaddr1, shiptoaddr2,
  80. shiptoaddr3, shiptocontact, shiptophone, shiptofax, shiptoemail )
  81. SELECT id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, ytd,
  82. discount, creditlimit, terms, shiptoname, shiptoaddr1, shiptoaddr2,
  83. shiptoaddr3, shiptocontact, shiptophone, shiptofax, shiptoemail
  84. FROM customer;
  85. --
  86. DROP TABLE customer;
  87. ALTER TABLE newcustomer RENAME TO customer;
  88. --
  89. CREATE TABLE customertax (
  90. customer_id int,
  91. chart_id int
  92. );
  93. --
  94. CREATE TABLE newdefaults (
  95. inventory_accno int,
  96. income_accno int,
  97. expense_accno int,
  98. invnumber text,
  99. ponumber text,
  100. yearend varchar(5),
  101. nativecurr varchar(3),
  102. weightunit varchar(5)
  103. );
  104. --
  105. INSERT INTO newdefaults (
  106. inventory_accno, income_accno, expense_accno, invnumber, ponumber)
  107. SELECT inventory_accno, income_accno, expense_accno, invnumber, ponumber
  108. FROM defaults;
  109. --
  110. DROP TABLE defaults;
  111. ALTER TABLE newdefaults RENAME TO defaults;
  112. UPDATE defaults SET yearend = '1/31', nativecurr = 'CAD', weightunit = 'kg';
  113. --
  114. CREATE TABLE partstax (
  115. parts_id int,
  116. chart_id int
  117. );
  118. --
  119. CREATE TABLE tax (
  120. chart_id int,
  121. rate float,
  122. number text
  123. );
  124. --
  125. CREATE TABLE newvendor (
  126. id int DEFAULT nextval ( 'id' ),
  127. name varchar(35),
  128. addr1 varchar(35),
  129. addr2 varchar(35),
  130. addr3 varchar(35),
  131. contact varchar(35),
  132. phone varchar(20),
  133. fax varchar(20),
  134. email text,
  135. notes text,
  136. ytd float,
  137. discount float4,
  138. taxincluded bool,
  139. creditlimit float,
  140. terms int2
  141. );
  142. --
  143. INSERT INTO newvendor (
  144. id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, ytd )
  145. SELECT id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, ytd
  146. FROM vendor;
  147. --
  148. DROP TABLE vendor;
  149. ALTER TABLE newvendor RENAME TO vendor;
  150. --
  151. CREATE TABLE vendortax (
  152. vendor_id int,
  153. chart_id int
  154. );
  155. --
  156. ALTER TABLE chart RENAME TO oldchart;
  157. --
  158. CREATE TABLE chart (
  159. id int DEFAULT nextval( 'id' ),
  160. accno int UNIQUE,
  161. description text,
  162. balance float,
  163. type char(1),
  164. gifi int,
  165. category char(1),
  166. link text
  167. );
  168. --
  169. INSERT INTO chart SELECT * FROM oldchart;
  170. --
  171. DROP TABLE oldchart;
  172. --