summaryrefslogtreecommitdiff
path: root/sql/legacy/Pg-upgrade-1.4.0-1.6.0.sql
blob: e0a38924654e87aa5454114ea8471c8e0c9e5fc3 (plain)
  1. alter table acc_trans rename column accno to chart_id;
  2. update acc_trans set chart_id =
  3. (select id from chart where accno = acc_trans.chart_id);
  4. --
  5. alter table parts rename column inventory_accno to inventory_accno_id;
  6. alter table parts rename column income_accno to income_accno_id;
  7. alter table parts rename column expense_accno to expense_accno_id;
  8. alter table parts rename column number to partnumber;
  9. update parts set inventory_accno_id =
  10. (select id from chart where chart.accno = parts.inventory_accno_id);
  11. update parts set income_accno_id =
  12. (select id from chart where chart.accno = parts.income_accno_id);
  13. update parts set expense_accno_id =
  14. (select id from chart where chart.accno = parts.expense_accno_id);
  15. --
  16. create table assembly (id int, parts_id int, qty float);
  17. --
  18. alter table defaults rename column inventory_accno to inventory_accno_id;
  19. alter table defaults rename column income_accno to income_accno_id;
  20. alter table defaults rename column expense_accno to expense_accno_id;
  21. alter table defaults add column businessnumber text;
  22. alter table defaults add column version varchar(8);
  23. update defaults set inventory_accno_id =
  24. (select id from chart where chart.accno = defaults.inventory_accno_id);
  25. update defaults set income_accno_id =
  26. (select id from chart where chart.accno = defaults.income_accno_id);
  27. update defaults set expense_accno_id =
  28. (select id from chart where chart.accno = defaults.expense_accno_id);
  29. update defaults set version = '1.6.0';
  30. --
  31. alter table invoice rename column inventory_accno to inventory_accno_id;
  32. alter table invoice rename column income_accno to income_accno_id;
  33. alter table invoice rename column expense_accno to expense_accno_id;
  34. alter table invoice rename column number to partnumber;
  35. alter table invoice add column assemblyitem bool;
  36. update invoice set assemblyitem = 'f';
  37. update invoice set inventory_accno_id =
  38. (select id from chart where invoice.inventory_accno_id = chart.accno);
  39. update invoice set income_accno_id =
  40. (select id from chart where invoice.income_accno_id = chart.accno);
  41. update invoice set expense_accno_id =
  42. (select id from chart where invoice.expense_accno_id = chart.accno);
  43. --
  44. alter table gl rename column comment to description;
  45. --
  46. create table newvendor (
  47. id int default nextval ( 'id' ),
  48. name varchar(35),
  49. addr1 varchar(35),
  50. addr2 varchar(35),
  51. addr3 varchar(35),
  52. addr4 varchar(35),
  53. contact varchar(35),
  54. phone varchar(20),
  55. fax varchar(20),
  56. email text,
  57. notes text,
  58. terms int2,
  59. taxincluded bool
  60. );
  61. insert into newvendor (
  62. id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, terms,
  63. taxincluded)
  64. select
  65. id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, terms,
  66. taxincluded from vendor;
  67. drop table vendor;
  68. alter table newvendor rename to vendor;
  69. --
  70. create table newcustomer (
  71. id int default nextval ( 'id' ),
  72. name varchar(35),
  73. addr1 varchar(35),
  74. addr2 varchar(35),
  75. addr3 varchar(35),
  76. addr4 varchar(35),
  77. contact varchar(35),
  78. phone varchar(20),
  79. fax varchar(20),
  80. email text,
  81. notes text,
  82. discount float4,
  83. taxincluded bool,
  84. creditlimit float,
  85. terms int2,
  86. shiptoname varchar(35),
  87. shiptoaddr1 varchar(35),
  88. shiptoaddr2 varchar(35),
  89. shiptoaddr3 varchar(35),
  90. shiptoaddr4 varchar(35),
  91. shiptocontact varchar(20),
  92. shiptophone varchar(20),
  93. shiptofax varchar(20),
  94. shiptoemail text
  95. );
  96. insert into newcustomer (
  97. id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, discount,
  98. taxincluded, creditlimit, terms, shiptoname, shiptoaddr1, shiptoaddr2,
  99. shiptoaddr3, shiptocontact, shiptophone, shiptofax, shiptoemail
  100. )
  101. select
  102. id, name, addr1, addr2, addr3, contact, phone, fax, email, notes, discount,
  103. taxincluded, creditlimit, terms, shiptoname, shiptoaddr1, shiptoaddr2,
  104. shiptoaddr3, shiptocontact, shiptophone, shiptofax, shiptoemail
  105. from customer;
  106. drop table customer;
  107. alter table newcustomer rename to customer;
  108. --
  109. drop index chart_accno_key;
  110. alter table chart rename to oldchart;
  111. create table chart (
  112. id int default nextval('id'),
  113. accno int unique,
  114. description text,
  115. charttype char(1),
  116. gifi int,
  117. category char(1),
  118. link text
  119. );
  120. insert into chart (id, accno, description, charttype, gifi, category, link)
  121. select id, accno, description, type, gifi, category, link from oldchart;
  122. drop table oldchart;
  123. --
  124. alter table tax rename column number to taxnumber;
  125. --
  126. -- apply