summaryrefslogtreecommitdiff
path: root/sql/Pg-upgrade-2.6.18-2.6.19.sql
blob: dd8583eb26b53d28c5ed7ded3d542c6492d11100 (plain)
  1. ALTER TABLE ap ADD PRIMARY KEY (id);
  2. ALTER TABLE ar ADD PRIMARY KEY (id);
  3. ALTER TABLE assembly ADD PRIMARY KEY (id, parts_id);
  4. ALTER TABLE business ADD PRIMARY KEY (id);
  5. ALTER TABLE customer ADD PRIMARY KEY (id);
  6. ALTER TABLE customertax ADD PRIMARY KEY (customer_id, chart_id);
  7. ALTER TABLE defaults ADD PRIMARY KEY (version);
  8. ALTER TABLE department ADD PRIMARY KEY (id);
  9. ALTER TABLE dpt_trans ADD PRIMARY KEY (trans_id);
  10. ALTER TABLE employee ADD PRIMARY KEY (id);
  11. ALTER TABLE exchangerate ADD PRIMARY KEY (curr, transdate);
  12. ALTER TABLE gifi ADD PRIMARY KEY (accno);
  13. ALTER TABLE gl ADD PRIMARY KEY (id);
  14. ALTER TABLE invoice ADD PRIMARY KEY (id);
  15. ALTER TABLE jcitems ADD PRIMARY KEY (id);
  16. ALTER TABLE language ADD PRIMARY KEY (code);
  17. ALTER TABLE makemodel ADD PRIMARY KEY (parts_id);
  18. ALTER TABLE oe ADD PRIMARY KEY (id);
  19. ALTER TABLE orderitems ADD PRIMARY KEY (id);
  20. ALTER TABLE parts ADD PRIMARY KEY (id);
  21. ALTER TABLE partsgroup ADD PRIMARY KEY (id);
  22. ALTER TABLE partstax ADD PRIMARY KEY (parts_id, chart_id);
  23. ALTER TABLE pricegroup ADD PRIMARY KEY (id);
  24. ALTER TABLE project ADD PRIMARY KEY (id);
  25. ALTER TABLE recurringemail ADD PRIMARY KEY (id);
  26. ALTER TABLE recurring ADD PRIMARY KEY (id);
  27. ALTER TABLE recurringprint ADD PRIMARY KEY (id);
  28. ALTER TABLE sic ADD PRIMARY KEY (code);
  29. ALTER TABLE status ADD PRIMARY KEY (trans_id);
  30. ALTER TABLE tax ADD PRIMARY KEY (chart_id);
  31. ALTER TABLE tax ADD FOREIGN KEY (chart_id) REFERENCES chart (id);
  32. ALTER TABLE translation ADD PRIMARY KEY (trans_id, language_code);
  33. ALTER TABLE vendor ADD PRIMARY KEY (id);
  34. ALTER TABLE vendortax ADD PRIMARY KEY (vendor_id, chart_id);
  35. ALTER TABLE warehouse ADD PRIMARY KEY (id);
  36. ALTER TABLE yearend ADD PRIMARY KEY (trans_id);
  37. LOCK inventory in EXCLUSIVE mode;
  38. ALTER TABLE inventory ADD COLUMN entry_id bigint;
  39. CREATE SEQUENCE inventory_entry_id_seq;
  40. ALTER TABLE inventory ALTER COLUMN entry_id
  41. SET DEFAULT nextval('inventory_entry_id_seq');
  42. UPDATE inventory SET entry_id = nextval('inventory_entry_id_seq');
  43. ALTER TABLE inventory ADD PRIMARY key (entry_id);
  44. LOCK partscustomer IN EXCLUSIVE MODE;
  45. ALTER TABLE partscustomer ADD COLUMN entry_id int;
  46. CREATE SEQUENCE partscustomer_entry_id_seq;
  47. ALTER TABLE partscustomer ALTER COLUMN entry_id
  48. SET DEFAULT nextval('partscustomer_entry_id_seq');
  49. UPDATE partscustomer SET entry_id = nextval('partscustomer_entry_id_seq');
  50. ALTER TABLE partscustomer ADD PRIMARY KEY (entry_id);
  51. LOCK partsvendor IN EXCLUSIVE MODE;
  52. ALTER TABLE partsvendor ADD COLUMN entry_id int;
  53. CREATE SEQUENCE partsvendor_entry_id_seq;
  54. ALTER TABLE partsvendor ALTER COLUMN entry_id
  55. SET DEFAULT nextval('partsvendor_entry_id_seq');
  56. UPDATE partsvendor SET entry_id = nextval('partsvendor_entry_id_seq');
  57. ALTER TABLE partsvendor ADD PRIMARY KEY (entry_id);
  58. LOCK audittrail IN EXCLUSIVE MODE;
  59. ALTER TABLE audittrail ADD COLUMN entry_id int;
  60. CREATE SEQUENCE audittrail_entry_id_seq ;
  61. ALTER TABLE audittrail ALTER COLUMN entry_id
  62. SET DEFAULT nextval('audittrail_entry_id_seq');
  63. UPDATE audittrail SET entry_id = nextval('audittrail_entry_id_seq');
  64. ALTER TABLE audittrail ADD PRIMARY KEY (entry_id);
  65. LOCK shipto IN EXCLUSIVE MODE;
  66. ALTER TABLE shipto ADD COLUMN entry_id int;
  67. CREATE SEQUENCE shipto_entry_id_seq ;
  68. ALTER TABLE shipto ALTER COLUMN entry_id
  69. SET DEFAULT nextval('shipto_entry_id_seq');
  70. UPDATE shipto SET entry_id = nextval('shipto_entry_id_seq');
  71. ALTER TABLE shipto ADD PRIMARY KEY (entry_id);
  72. CREATE TABLE taxmodule (
  73. taxmodule_id serial PRIMARY KEY,
  74. taxmodulename text NOT NULL
  75. );
  76. INSERT INTO taxmodule (
  77. taxmodule_id, taxmodulename
  78. ) VALUES (
  79. 1, 'Simple'
  80. );
  81. LOCK tax IN EXCLUSIVE MODE;
  82. ALTER TABLE tax ADD COLUMN pass int DEFAULT 0;
  83. UPDATE tax SET pass = 0;
  84. ALTER TABLE tax ALTER COLUMN pass SET NOT NULL;
  85. ALTER TABLE tax ADD COLUMN taxmodule_id int REFERENCES taxmodule DEFAULT 1;
  86. UPDATE tax SET taxmodule_id = 1;
  87. ALTER TABLE tax ALTER COLUMN taxmodule_id SET NOT NULL;
  88. -- Fixed session table --
  89. ALTER TABLE session ADD CONSTRAINT session_token_check check (length(token::text) = 32);