15.0.0-16.0.0.sql 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. --
  2. -- Be carefull to requests order.
  3. -- This file must be loaded by calling /install/index.php page
  4. -- when current version is 15.0.0 or higher.
  5. --
  6. -- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
  7. -- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
  8. -- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
  9. -- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
  10. -- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
  11. -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
  12. -- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
  13. -- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
  14. -- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field);
  15. -- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table;
  16. -- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex;
  17. -- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
  18. -- To make pk to be auto increment (postgres):
  19. -- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid;
  20. -- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid);
  21. -- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq');
  22. -- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table;
  23. -- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL;
  24. -- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
  25. -- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL;
  26. -- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL;
  27. -- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
  28. -- Note: fields with type BLOB/TEXT can't have default value.
  29. -- To rebuild sequence for postgresql after insert by forcing id autoincrement fields:
  30. -- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences();
  31. -- Missing in v15 or lower
  32. ALTER TABLE llx_c_availability MODIFY COLUMN label varchar(128);
  33. ALTER TABLE llx_c_civility MODIFY COLUMN label varchar(128);
  34. ALTER TABLE llx_c_country MODIFY COLUMN label varchar(128);
  35. ALTER TABLE llx_c_currencies MODIFY COLUMN label varchar(128);
  36. ALTER TABLE llx_c_effectif MODIFY COLUMN libelle varchar(128);
  37. ALTER TABLE llx_c_exp_tax_cat MODIFY COLUMN label varchar(128);
  38. ALTER TABLE llx_c_hrm_department MODIFY COLUMN label varchar(128);
  39. ALTER TABLE llx_c_hrm_function MODIFY COLUMN label varchar(128);
  40. ALTER TABLE llx_c_input_reason MODIFY COLUMN label varchar(128);
  41. ALTER TABLE llx_c_lead_status MODIFY COLUMN label varchar(128);
  42. ALTER TABLE llx_c_paper_format MODIFY COLUMN label varchar(128);
  43. ALTER TABLE llx_c_partnership_type MODIFY COLUMN label varchar(128);
  44. ALTER TABLE llx_c_product_nature MODIFY COLUMN label varchar(128);
  45. ALTER TABLE llx_c_productbatch_qcstatus MODIFY COLUMN label varchar(128);
  46. ALTER TABLE llx_c_propalst MODIFY COLUMN label varchar(128);
  47. ALTER TABLE llx_c_prospectcontactlevel MODIFY COLUMN label varchar(128);
  48. ALTER TABLE llx_c_prospectlevel MODIFY COLUMN label varchar(128);
  49. ALTER TABLE llx_c_recruitment_origin MODIFY COLUMN label varchar(128);
  50. ALTER TABLE llx_c_shipment_package_type MODIFY COLUMN label varchar(128);
  51. ALTER TABLE llx_c_type_container MODIFY COLUMN label varchar(128);
  52. ALTER TABLE llx_c_type_fees MODIFY COLUMN label varchar(128);
  53. ALTER TABLE llx_c_type_resource MODIFY COLUMN label varchar(128);
  54. ALTER TABLE llx_c_units MODIFY COLUMN label varchar(128);
  55. ALTER TABLE llx_c_actioncomm MODIFY COLUMN libelle varchar(128);
  56. ALTER TABLE llx_c_barcode_type MODIFY COLUMN libelle varchar(128);
  57. ALTER TABLE llx_c_chargesociales MODIFY COLUMN libelle varchar(128);
  58. ALTER TABLE llx_c_input_method MODIFY COLUMN libelle varchar(128);
  59. ALTER TABLE llx_c_paiement MODIFY COLUMN libelle varchar(128);
  60. ALTER TABLE llx_c_shipment_mode MODIFY COLUMN libelle varchar(128);
  61. ALTER TABLE llx_c_stcomm MODIFY COLUMN libelle varchar(128);
  62. ALTER TABLE llx_c_stcommcontact MODIFY COLUMN libelle varchar(128);
  63. ALTER TABLE llx_c_type_contact MODIFY COLUMN libelle varchar(128);
  64. ALTER TABLE llx_c_typent MODIFY COLUMN libelle varchar(128);
  65. UPDATE llx_rights_def SET perms = 'writeall' WHERE perms = 'writeall_advance' AND module = 'holiday';
  66. -- v16
  67. ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL;
  68. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_MODIFY','Customer proposal modified','Executed when a customer proposal is modified','propal',2);
  69. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_MODIFY','Customer order modified','Executed when a customer order is set modified','commande',5);
  70. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_MODIFY','Customer invoice modified','Executed when a customer invoice is modified','facture',7);
  71. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_MODIFY','Price request modified','Executed when a commercial proposal is modified','proposal_supplier',10);
  72. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_MODIFY','Supplier order request modified','Executed when a supplier order is modified','order_supplier',13);
  73. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_MODIFY','Supplier invoice modified','Executed when a supplier invoice is modified','invoice_supplier',15);
  74. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_MODIFY','Contract modified','Executed when a contract is modified','contrat',18);
  75. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_MODIFY','Shipping modified','Executed when a shipping is modified','shipping',20);
  76. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_MODIFY','Intervention modify','Executed when a intervention is modify','ficheinter',30);
  77. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41);
  78. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',202);
  79. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',212);
  80. ALTER TABLE llx_ticket ADD COLUMN date_last_msg_sent datetime AFTER date_read;
  81. CREATE TABLE llx_stock_mouvement_extrafields (
  82. rowid integer AUTO_INCREMENT PRIMARY KEY,
  83. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  84. fk_object integer NOT NULL,
  85. import_key varchar(14)
  86. )ENGINE=innodb;
  87. ALTER TABLE llx_stock_mouvement_extrafields ADD INDEX idx_stock_mouvement_extrafields (fk_object);
  88. -- Facture fourn rec
  89. CREATE TABLE llx_facture_fourn_rec
  90. (
  91. rowid integer AUTO_INCREMENT PRIMARY KEY,
  92. titre varchar(200) NOT NULL,
  93. ref_supplier varchar(180) NOT NULL,
  94. entity integer DEFAULT 1 NOT NULL,
  95. fk_soc integer NOT NULL,
  96. datec datetime,
  97. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  98. suspended integer DEFAULT 0,
  99. libelle varchar(255),
  100. amount double(24, 8) DEFAULT 0 NOT NULL,
  101. remise real DEFAULT 0,
  102. vat_src_code varchar(10) DEFAULT '',
  103. localtax1 double(24,8) DEFAULT 0,
  104. localtax2 double(24,8) DEFAULT 0,
  105. total_ht double(24,8) DEFAULT 0,
  106. total_tva double(24,8) DEFAULT 0,
  107. total_ttc double(24,8) DEFAULT 0,
  108. fk_user_author integer,
  109. fk_user_modif integer,
  110. fk_projet integer,
  111. fk_account integer,
  112. fk_cond_reglement integer,
  113. fk_mode_reglement integer,
  114. date_lim_reglement date,
  115. note_private text,
  116. note_public text,
  117. modelpdf varchar(255),
  118. fk_multicurrency integer,
  119. multicurrency_code varchar(3),
  120. multicurrency_tx double(24,8) DEFAULT 1,
  121. multicurrency_total_ht double(24,8) DEFAULT 0,
  122. multicurrency_total_tva double(24,8) DEFAULT 0,
  123. multicurrency_total_ttc double(24,8) DEFAULT 0,
  124. usenewprice integer DEFAULT 0,
  125. frequency integer,
  126. unit_frequency varchar(2) DEFAULT 'm',
  127. date_when datetime DEFAULT NULL,
  128. date_last_gen datetime DEFAULT NULL,
  129. nb_gen_done integer DEFAULT NULL,
  130. nb_gen_max integer DEFAULT NULL,
  131. auto_validate integer DEFAULT 0,
  132. generate_pdf integer DEFAULT 1
  133. )ENGINE=innodb;
  134. ALTER TABLE llx_facture_fourn_rec ADD UNIQUE INDEX uk_facture_fourn_rec_ref (titre, entity);
  135. ALTER TABLE llx_facture_fourn_rec ADD UNIQUE INDEX uk_facture_fourn_rec_ref_supplier (ref_supplier, fk_soc, entity);
  136. ALTER TABLE llx_facture_fourn_rec ADD INDEX idx_facture_fourn_rec_date_lim_reglement (date_lim_reglement);
  137. ALTER TABLE llx_facture_fourn_rec ADD INDEX idx_facture_fourn_rec_fk_soc (fk_soc);
  138. ALTER TABLE llx_facture_fourn_rec ADD INDEX idx_facture_fourn_rec_fk_user_author (fk_user_author);
  139. ALTER TABLE llx_facture_fourn_rec ADD INDEX idx_facture_fourn_rec_fk_projet (fk_projet);
  140. ALTER TABLE llx_facture_fourn_rec ADD CONSTRAINT fk_facture_fourn_rec_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
  141. ALTER TABLE llx_facture_fourn_rec ADD CONSTRAINT fk_facture_fourn_rec_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
  142. ALTER TABLE llx_facture_fourn_rec ADD CONSTRAINT fk_facture_fourn_rec_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);
  143. CREATE TABLE llx_facture_fourn_rec_extrafields
  144. (
  145. rowid integer AUTO_INCREMENT PRIMARY KEY,
  146. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  147. fk_object integer NOT NULL,
  148. import_key varchar(14) -- import key
  149. ) ENGINE=innodb;
  150. ALTER TABLE llx_facture_fourn_rec_extrafields ADD INDEX idx_facture_fourn_rec_extrafields (fk_object);
  151. CREATE TABLE llx_facture_fourn_det_rec
  152. (
  153. rowid integer AUTO_INCREMENT PRIMARY KEY,
  154. fk_facture_fourn integer NOT NULL,
  155. fk_parent_line integer NULL,
  156. fk_product integer NULL,
  157. ref varchar(50),
  158. label varchar(255) DEFAULT NULL,
  159. description text,
  160. pu_ht double(24,8),
  161. pu_ttc double(24,8),
  162. qty real,
  163. remise_percent real DEFAULT 0,
  164. fk_remise_except integer NULL,
  165. vat_src_code varchar(10) DEFAULT '',
  166. tva_tx double(7,4),
  167. localtax1_tx double(7,4) DEFAULT 0,
  168. localtax1_type varchar(10) NULL,
  169. localtax2_tx double(7,4) DEFAULT 0,
  170. localtax2_type varchar(10) NULL,
  171. total_ht double(24,8),
  172. total_tva double(24,8),
  173. total_localtax1 double(24,8) DEFAULT 0,
  174. total_localtax2 double(24,8) DEFAULT 0,
  175. total_ttc double(24,8),
  176. product_type integer DEFAULT 0,
  177. date_start integer DEFAULT NULL,
  178. date_end integer DEFAULT NULL,
  179. info_bits integer DEFAULT 0,
  180. special_code integer UNSIGNED DEFAULT 0,
  181. rang integer DEFAULT 0,
  182. fk_unit integer DEFAULT NULL,
  183. import_key varchar(14),
  184. fk_user_author integer,
  185. fk_user_modif integer,
  186. fk_multicurrency integer,
  187. multicurrency_code varchar(3),
  188. multicurrency_subprice double(24,8) DEFAULT 0,
  189. multicurrency_total_ht double(24,8) DEFAULT 0,
  190. multicurrency_total_tva double(24,8) DEFAULT 0,
  191. multicurrency_total_ttc double(24,8) DEFAULT 0
  192. )ENGINE=innodb;
  193. ALTER TABLE llx_facture_fourn_det_rec ADD CONSTRAINT fk_facture_fourn_det_rec_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
  194. CREATE TABLE llx_facture_fourn_det_rec_extrafields
  195. (
  196. rowid integer AUTO_INCREMENT PRIMARY KEY,
  197. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  198. fk_object integer NOT NULL, -- object id
  199. import_key varchar(14) -- import key
  200. )ENGINE=innodb;
  201. ALTER TABLE llx_facture_fourn_det_rec_extrafields ADD INDEX idx_facture_fourn_det_rec_extrafields (fk_object);
  202. ALTER TABLE llx_facture_fourn ADD COLUMN fk_fac_rec_source integer;
  203. ALTER TABLE llx_mrp_mo ADD COLUMN fk_parent_line integer;
  204. ALTER TABLE llx_projet_task ADD COLUMN status integer DEFAULT 1 NOT NULL;
  205. ALTER TABLE llx_product_attribute_value MODIFY COLUMN ref VARCHAR(180) NOT NULL;
  206. ALTER TABLE llx_product_attribute_value MODIFY COLUMN value VARCHAR(255) NOT NULL;
  207. ALTER TABLE llx_product_attribute_value ADD COLUMN position INTEGER NOT NULL DEFAULT 0;
  208. ALTER TABLE llx_product_attribute CHANGE rang position INTEGER DEFAULT 0 NOT NULL;
  209. ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget;
  210. ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity);
  211. create table llx_inventory_extrafields
  212. (
  213. rowid integer AUTO_INCREMENT PRIMARY KEY,
  214. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  215. fk_object integer NOT NULL,
  216. import_key varchar(14) -- import key
  217. ) ENGINE=innodb;
  218. ALTER TABLE llx_inventory_extrafields ADD INDEX idx_inventory_extrafields (fk_object);
  219. ALTER TABLE llx_reception MODIFY COLUMN ref_supplier varchar(128);
  220. ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER domiciliation;