13.0.0-14.0.0.sql 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. --
  2. -- Be carefull to requests order.
  3. -- This file must be loaded by calling /install/index.php page
  4. -- when current version is 14.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 v13 or lower
  32. -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
  33. -- VMYSQL4.1 update llx_propal set tms = datec where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL;
  34. -- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
  35. -- VMYSQL4.1 update llx_propal set tms = null where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL;
  36. -- VPGSQL8.2 DROP TRIGGER update_customer_modtime ON llx_ecm_directories;
  37. -- VPGSQL8.2 DROP TRIGGER update_customer_modtime ON llx_ecm_files;
  38. -- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
  39. -- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_files FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
  40. ALTER TABLE llx_ecm_files ADD COLUMN note_private text AFTER fk_user_m;
  41. ALTER TABLE llx_ecm_files ADD COLUMN note_public text AFTER note_private;
  42. ALTER TABLE llx_accounting_bookkeeping DROP INDEX idx_accounting_bookkeeping_numero_compte;
  43. ALTER TABLE llx_accounting_bookkeeping DROP INDEX idx_accounting_bookkeeping_code_journal;
  44. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
  45. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date);
  46. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte, entity);
  47. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal, entity);
  48. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_piece_num (piece_num, entity);
  49. ALTER TABLE llx_recruitment_recruitmentcandidature MODIFY COLUMN email_msgid VARCHAR(175);
  50. ALTER TABLE llx_asset CHANGE COLUMN amount amount_ht double(24,8) DEFAULT NULL;
  51. ALTER TABLE llx_asset ADD COLUMN amount_vat double(24,8) DEFAULT NULL;
  52. ALTER TABLE llx_supplier_proposal_extrafields ADD INDEX idx_supplier_proposal_extrafields (fk_object);
  53. ALTER TABLE llx_supplier_proposaldet_extrafields ADD INDEX idx_supplier_proposaldet_extrafields (fk_object);
  54. ALTER TABLE llx_asset_extrafields ADD INDEX idx_asset_extrafields (fk_object);
  55. insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4);
  56. -- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL;
  57. -- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL;
  58. UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI');
  59. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 11, 'US-BASE', 'USA basic chart of accounts', 1);
  60. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 14, 'CA-ENG-BASE', 'Canadian basic chart of accounts - English', 1);
  61. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 154, 'SAT/24-2019', 'Catalogo y codigo agrupador fiscal del 2019', 1);
  62. UPDATE llx_accounting_system SET fk_country = 1 WHERE fk_country IS NULL;
  63. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'auguria';
  64. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'bureau2crea';
  65. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'amarok';
  66. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'cameleo';
  67. DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', 'amarok', 'cameleo');
  68. ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging real DEFAULT NULL;
  69. -- VMYSQL4.3 ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL;
  70. -- VPGSQL8.2 ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL USING packaging::real;
  71. -- VPGSQL8.2 ALTER TABLE llx_product_fournisseur_price ALTER COLUMN packaging DROP DEFAULT;
  72. -- For v14
  73. --Fix bad sign on multicompany column for customer invoice lines
  74. UPDATE llx_facturedet SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and subprice > 0) OR (multicurrency_subprice > 0 and subprice < 0));
  75. UPDATE llx_facturedet SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
  76. UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
  77. UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
  78. --Fix bad sign on multicompany column for customer invoices
  79. UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
  80. UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
  81. UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
  82. --Fix bad sign on multicurrency column for supplier invoice lines
  83. UPDATE llx_facture_fourn_det SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and pu_ht > 0) OR (multicurrency_subprice > 0 and pu_ht < 0));
  84. UPDATE llx_facture_fourn_det SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
  85. UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0));
  86. UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
  87. --Fix bad sign on multicompany column for customer invoices
  88. UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0));
  89. UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0));
  90. UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0));
  91. UPDATE llx_c_ticket_type set label = 'Issue or bug' WHERE code = 'ISSUE';
  92. INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('PROBLEM', '22', 'Problem', 0, 0, NULL);
  93. ALTER TABLE llx_import_model MODIFY COLUMN type varchar(64);
  94. ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64);
  95. ALTER TABLE llx_import_model ADD COLUMN entity integer DEFAULT 0 NOT NULL;
  96. ALTER TABLE llx_export_model ADD COLUMN entity integer DEFAULT 0 NOT NULL;
  97. ALTER TABLE llx_product_lot ADD COLUMN eol_date datetime NULL;
  98. ALTER TABLE llx_product_lot ADD COLUMN manufacturing_date datetime NULL;
  99. ALTER TABLE llx_product_lot ADD COLUMN scrapping_date datetime NULL;
  100. create table llx_accounting_groups_account
  101. (
  102. rowid integer AUTO_INCREMENT PRIMARY KEY,
  103. fk_accounting_account INTEGER NOT NULL,
  104. fk_c_accounting_category INTEGER NOT NULL
  105. )ENGINE=innodb;
  106. ALTER TABLE llx_oauth_token ADD COLUMN restricted_ips varchar(200);
  107. ALTER TABLE llx_oauth_token ADD COLUMN datec datetime DEFAULT NULL;
  108. ALTER TABLE llx_oauth_token ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
  109. ALTER TABLE llx_events ADD COLUMN authentication_method varchar(64) NULL;
  110. ALTER TABLE llx_events ADD COLUMN fk_oauth_token integer NULL;
  111. ALTER TABLE llx_mailing_cibles MODIFY COLUMN tag varchar(64) NULL;
  112. ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_tag (tag);
  113. ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0;
  114. ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) AFTER rowid;
  115. UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL;
  116. ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL;
  117. ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity);
  118. ALTER TABLE llx_societe ADD COLUMN accountancy_code_sell varchar(32) AFTER webservices_key;
  119. ALTER TABLE llx_societe ADD COLUMN accountancy_code_buy varchar(32) AFTER accountancy_code_sell;
  120. ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL;
  121. ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL;
  122. ALTER TABLE llx_facture MODIFY COLUMN date_valid DATETIME NULL DEFAULT NULL;
  123. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_dolibarr_state_board.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_dolibarr_state_board.php' AND entity = 1);
  124. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_members_last_modified.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_members_last_modified.php' AND entity = 1);
  125. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_members_last_subscriptions.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_members_last_subscriptions.php' AND entity = 1);
  126. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_members_subscriptions_by_year.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_members_subscriptions_by_year.php' AND entity = 1);
  127. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_members_by_type.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_members_by_type.php' AND entity = 1);
  128. ALTER TABLE llx_website ADD COLUMN lastaccess datetime NULL;
  129. ALTER TABLE llx_website ADD COLUMN pageviews_month BIGINT UNSIGNED DEFAULT 0;
  130. ALTER TABLE llx_website ADD COLUMN pageviews_total BIGINT UNSIGNED DEFAULT 0;
  131. -- Drop foreign key with bad name or not required
  132. ALTER TABLE llx_workstation_workstation DROP FOREIGN KEY llx_workstation_workstation_fk_user_creat;
  133. ALTER TABLE llx_propal DROP FOREIGN KEY llx_propal_fk_warehouse;
  134. CREATE TABLE llx_workstation_workstation(
  135. -- BEGIN MODULEBUILDER FIELDS
  136. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  137. ref varchar(128) DEFAULT '(PROV)' NOT NULL,
  138. label varchar(255),
  139. type varchar(7),
  140. note_public text,
  141. entity int DEFAULT 1,
  142. note_private text,
  143. date_creation datetime NOT NULL,
  144. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  145. fk_user_creat integer NOT NULL,
  146. fk_user_modif integer,
  147. import_key varchar(14),
  148. status smallint NOT NULL,
  149. nb_operators_required integer,
  150. thm_operator_estimated double,
  151. thm_machine_estimated double
  152. -- END MODULEBUILDER FIELDS
  153. ) ENGINE=innodb;
  154. ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_rowid (rowid);
  155. ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_ref (ref);
  156. ALTER TABLE llx_workstation_workstation ADD CONSTRAINT fk_workstation_workstation_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
  157. ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_status (status);
  158. CREATE TABLE llx_workstation_workstation_resource(
  159. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  160. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  161. fk_resource integer,
  162. fk_workstation integer
  163. ) ENGINE=innodb;
  164. CREATE TABLE llx_workstation_workstation_usergroup(
  165. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  166. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  167. fk_usergroup integer,
  168. fk_workstation integer
  169. ) ENGINE=innodb;
  170. DROP TABLE llx_c_producbatch_qcstatus; -- delete table with bad name
  171. CREATE TABLE llx_c_productbatch_qcstatus(
  172. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  173. entity integer NOT NULL DEFAULT 1,
  174. code varchar(16) NOT NULL,
  175. label varchar(50) NOT NULL,
  176. active integer DEFAULT 1 NOT NULL
  177. ) ENGINE=innodb;
  178. ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code, entity);
  179. INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1);
  180. INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1);
  181. ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30);
  182. ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30);
  183. ALTER TABLE llx_propal ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_shipping_method;
  184. --ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
  185. ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse);
  186. ALTER TABLE llx_societe DROP INDEX idx_societe_entrepot;
  187. ALTER TABLE llx_societe CHANGE fk_entrepot fk_warehouse INTEGER DEFAULT NULL;
  188. --ALTER TABLE llx_societe ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
  189. ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse);
  190. -- VMYSQL4.3 ALTER TABLE llx_societe MODIFY COLUMN fk_typent integer NULL;
  191. -- VPGSQL8.2 ALTER TABLE llx_societe ALTER COLUMN fk_typent DROP NOT NULL;
  192. UPDATE llx_societe SET fk_typent=NULL, tms=tms WHERE fk_typent=0;
  193. DELETE FROM llx_c_typent WHERE code='TE_UNKNOWN';
  194. ALTER TABLE llx_socpeople MODIFY poste varchar(255);
  195. ALTER TABLE llx_menu ADD COLUMN prefix varchar(255) NULL AFTER titre;
  196. ALTER TABLE llx_chargesociales ADD COLUMN fk_user integer DEFAULT NULL;
  197. ALTER TABLE llx_mrp_production ADD COLUMN origin_id integer AFTER fk_mo;
  198. ALTER TABLE llx_mrp_production ADD COLUMN origin_type varchar(10) AFTER origin_id;
  199. ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
  200. ALTER TABLE llx_projet ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
  201. ALTER TABLE llx_expensereport ADD COLUMN last_main_doc varchar(255) DEFAULT NULL AFTER model_pdf;
  202. create table llx_payment_vat
  203. (
  204. rowid integer AUTO_INCREMENT PRIMARY KEY,
  205. fk_tva integer,
  206. datec datetime, -- date de creation
  207. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  208. datep datetime, -- payment date
  209. amount double(24,8) DEFAULT 0,
  210. fk_typepaiement integer NOT NULL,
  211. num_paiement varchar(50),
  212. note text,
  213. fk_bank integer NOT NULL,
  214. fk_user_creat integer, -- creation user
  215. fk_user_modif integer -- last modification user
  216. )ENGINE=innodb;
  217. ALTER TABLE llx_tva ADD COLUMN paye smallint default 1 NOT NULL;
  218. ALTER TABLE llx_tva ADD COLUMN fk_account integer;
  219. INSERT INTO llx_payment_vat (rowid, fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) SELECT rowid, rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, 'Created automatically by migration v13 to v14', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva WHERE fk_bank IS NOT NULL;
  220. --UPDATE llx_bank_url as url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET url.type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat';
  221. --INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_payment_vat ptva on (ptva.fk_bank = b.fk_bank) WHERE type = 'vat';
  222. --ALTER TABLE llx_tva DROP COLUMN fk_bank;
  223. ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0;
  224. -- Event organization
  225. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailAskConf)', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__,<br /><br />__(OrganizationEventConfRequestWasReceived)__<br /><br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  226. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailAskBooth)', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__,<br /><br />__(OrganizationEventBoothRequestWasReceived)__<br /><br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  227. -- TODO Add message for registration only to event __ONLINE_PAYMENT_TEXT_AND_URL__
  228. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailSubsBooth)', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailBoothPayment)__', '__(Hello)__,<br /><br />__(OrganizationEventPaymentOfBoothWasReceived)__<br /><br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  229. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationEmailSubsEvent)', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailRegistrationPayment)__', '__(Hello)__,<br /><br />__(OrganizationEventPaymentOfRegistrationWasReceived)__<br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  230. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationMassEmailAttendees)', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__,<br /><br />__(OrganizationEventBulkMailToAttendees)__<br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  231. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'conferenceorbooth', '', 0, null, null, '(EventOrganizationMassEmailSpeakers)', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__,<br /><br />__(OrganizationEventBulkMailToSpeakers)__<br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  232. ALTER TABLE llx_projet ADD COLUMN accept_conference_suggestions integer DEFAULT 0;
  233. ALTER TABLE llx_projet ADD COLUMN accept_booth_suggestions integer DEFAULT 0;
  234. ALTER TABLE llx_projet ADD COLUMN price_registration double(24,8);
  235. ALTER TABLE llx_projet ADD COLUMN price_booth double(24,8);
  236. ALTER TABLE llx_actioncomm ADD COLUMN num_vote integer DEFAULT NULL AFTER reply_to;
  237. ALTER TABLE llx_actioncomm ADD COLUMN event_paid smallint NOT NULL DEFAULT 0 AFTER num_vote;
  238. ALTER TABLE llx_actioncomm ADD COLUMN status smallint NOT NULL DEFAULT 0 AFTER event_paid;
  239. ALTER TABLE llx_actioncomm ADD COLUMN ref varchar(30) AFTER id;
  240. UPDATE llx_actioncomm SET ref = id WHERE ref = '' OR ref IS NULL;
  241. ALTER TABLE llx_actioncomm MODIFY COLUMN ref varchar(30) NOT NULL;
  242. ALTER TABLE llx_actioncomm ADD UNIQUE INDEX uk_actioncomm_ref (ref, entity);
  243. ALTER TABLE llx_c_actioncomm MODIFY code varchar(50) NOT NULL;
  244. ALTER TABLE llx_c_actioncomm MODIFY module varchar(50) DEFAULT NULL;
  245. INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 60,'AC_EO_ONLINECONF','module','Online/Virtual conference','conference@eventorganization', 1, 60);
  246. INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 61,'AC_EO_INDOORCONF','module','Indoor conference','conference@eventorganization', 1, 61);
  247. INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 62,'AC_EO_ONLINEBOOTH','module','Online/Virtual booth','booth@eventorganization', 1, 62);
  248. INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 63,'AC_EO_INDOORBOOTH','module','Indoor booth','booth@eventorganization', 1, 63);
  249. -- Code enhanced - Standardize field name
  250. ALTER TABLE llx_commande CHANGE COLUMN tva total_tva double(24,8) default 0;
  251. ALTER TABLE llx_supplier_proposal CHANGE COLUMN tva total_tva double(24,8) default 0;
  252. ALTER TABLE llx_supplier_proposal CHANGE COLUMN total total_ttc double(24,8) default 0;
  253. ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0;
  254. ALTER TABLE llx_propal CHANGE COLUMN total total_ttc double(24,8) default 0;
  255. ALTER TABLE llx_facture CHANGE COLUMN tva total_tva double(24,8) default 0;
  256. ALTER TABLE llx_facture CHANGE COLUMN total total_ht double(24,8) default 0;
  257. ALTER TABLE llx_facture_rec CHANGE COLUMN tva total_tva double(24,8) default 0;
  258. ALTER TABLE llx_facture_rec CHANGE COLUMN total total_ht double(24,8) default 0;
  259. ALTER TABLE llx_commande_fournisseur CHANGE COLUMN tva total_tva double(24,8) default 0;
  260. --VMYSQL4.3 ALTER TABLE llx_c_civility CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
  261. --VPGSQL8.2 CREATE SEQUENCE llx_c_civility_rowid_seq OWNED BY llx_c_civility.rowid;
  262. --VPGSQL8.2 ALTER TABLE llx_c_civility ALTER COLUMN rowid SET DEFAULT nextval('llx_c_civility_rowid_seq');
  263. --VPGSQL8.2 SELECT setval('llx_c_civility_rowid_seq', MAX(rowid)) FROM llx_c_civility;
  264. -- Change for salary intent table
  265. create table llx_salary
  266. (
  267. rowid integer AUTO_INCREMENT PRIMARY KEY,
  268. ref varchar(30) NULL, -- payment reference number (currently NULL because there is no numbering manager yet)
  269. label varchar(255),
  270. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  271. datec datetime, -- Create date
  272. fk_user integer NOT NULL,
  273. datep date, -- payment date
  274. datev date, -- value date (this field should not be here, only into bank tables)
  275. salary double(24,8), -- salary of user when payment was done
  276. amount double(24,8) NOT NULL DEFAULT 0,
  277. fk_projet integer DEFAULT NULL,
  278. datesp date, -- date start period
  279. dateep date, -- date end period
  280. entity integer DEFAULT 1 NOT NULL, -- multi company id
  281. note text,
  282. fk_bank integer,
  283. paye smallint default 1 NOT NULL,
  284. fk_typepayment integer NOT NULL, -- default payment mode for payment
  285. fk_account integer, -- default bank account for payment
  286. fk_user_author integer, -- user creating
  287. fk_user_modif integer -- user making last change
  288. ) ENGINE=innodb;
  289. -- VMYSQL4.1 ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user fk_user integer NULL;
  290. -- VPGSQL8.2 ALTER TABLE llx_payment_salary ALTER COLUMN fk_user DROP NOT NULL;
  291. ALTER TABLE llx_payment_salary ADD COLUMN fk_salary integer;
  292. INSERT INTO llx_salary (rowid, ref, fk_user, amount, fk_projet, fk_typepayment, label, datesp, dateep, entity, note, fk_bank, paye) SELECT ps.rowid, ps.rowid, ps.fk_user, ps.amount, ps.fk_projet, ps.fk_typepayment, ps.label, ps.datesp, ps.dateep, ps.entity, ps.note, ps.fk_bank, 1 FROM llx_payment_salary ps WHERE ps.fk_salary IS NULL;
  293. UPDATE llx_payment_salary SET fk_salary = rowid WHERE fk_salary IS NULL;
  294. UPDATE llx_payment_salary SET ref = rowid WHERE ref IS NULL;
  295. ALTER TABLE llx_salary ALTER COLUMN paye set default 0;
  296. UPDATE llx_extrafields SET elementtype = 'salary' WHERE elementtype = 'payment_salary';
  297. ALTER TABLE llx_payment_salary_extrafields RENAME TO llx_salary_extrafields;
  298. -- VMYSQL4.1 DROP INDEX idx_payment_salary_extrafields on llx_salary_extrafields;
  299. -- VPGSQL8.2 DROP INDEX idx_payment_salary_extrafields;
  300. ALTER TABLE llx_salary_extrafields ADD INDEX idx_salary_extrafields (fk_object);
  301. DELETE FROM llx_boxes WHERE box_id IN (SELECT rowid FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php'));
  302. DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ticket_by_severity.php', 'box_nb_ticket_last_x_days.php', 'box_nb_tickets_type.php', 'box_new_vs_close_ticket.php');
  303. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_ticket_by_severity.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_ticket_by_severity.php' AND entity = 1);
  304. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_nb_ticket_last_x_days.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_nb_ticket_last_x_days.php' AND entity = 1);
  305. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_nb_tickets_type.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_nb_tickets_type.php' AND entity = 1);
  306. -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_new_vs_close_ticket.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_new_vs_close_ticket.php' AND entity = 1);
  307. create table llx_product_perentity
  308. (
  309. rowid integer AUTO_INCREMENT PRIMARY KEY,
  310. fk_product integer,
  311. entity integer DEFAULT 1 NOT NULL, -- multi company id
  312. accountancy_code_sell varchar(32), -- Selling accountancy code
  313. accountancy_code_sell_intra varchar(32), -- Selling accountancy code for vat intracommunity
  314. accountancy_code_sell_export varchar(32), -- Selling accountancy code for vat export
  315. accountancy_code_buy varchar(32), -- Buying accountancy code
  316. accountancy_code_buy_intra varchar(32), -- Buying accountancy code for vat intracommunity
  317. accountancy_code_buy_export varchar(32), -- Buying accountancy code for vat import
  318. pmp double(24,8)
  319. )ENGINE=innodb;
  320. ALTER TABLE llx_product_perentity ADD INDEX idx_product_perentity_fk_product (fk_product);
  321. ALTER TABLE llx_product_perentity ADD UNIQUE INDEX uk_product_perentity (fk_product, entity);
  322. create table llx_societe_perentity
  323. (
  324. rowid integer AUTO_INCREMENT PRIMARY KEY,
  325. fk_soc integer,
  326. entity integer DEFAULT 1 NOT NULL, -- multi company id
  327. -- code_compta varchar(24), -- code compta client
  328. -- code_compta_fournisseur varchar(24), -- code compta founisseur
  329. accountancy_code_sell varchar(32), -- Selling accountancy code
  330. accountancy_code_buy varchar(32) -- Buying accountancy code
  331. )ENGINE=innodb;
  332. ALTER TABLE llx_societe_perentity ADD INDEX idx_societe_perentity_fk_soc (fk_soc);
  333. ALTER TABLE llx_societe_perentity ADD UNIQUE INDEX uk_societe_perentity (fk_soc, entity);
  334. CREATE TABLE llx_eventorganization_conferenceorboothattendee(
  335. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  336. ref varchar(128) NOT NULL,
  337. fk_soc integer,
  338. fk_actioncomm integer,
  339. fk_project integer NOT NULL,
  340. fk_invoice integer NULL,
  341. email varchar(100),
  342. date_subscription datetime,
  343. amount double DEFAULT NULL,
  344. note_public text,
  345. note_private text,
  346. date_creation datetime NOT NULL,
  347. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  348. fk_user_creat integer,
  349. fk_user_modif integer,
  350. last_main_doc varchar(255),
  351. import_key varchar(14),
  352. model_pdf varchar(255),
  353. status smallint NOT NULL
  354. ) ENGINE=innodb;
  355. -- VMYSQL4.3 ALTER TABLE llx_eventorganization_conferenceorboothattendee MODIFY COLUMN fk_actioncomm integer NULL;
  356. -- VPGSQL8.2 ALTER TABLE llx_eventorganization_conferenceorboothattendee ALTER COLUMN fk_actioncomm DROP NOT NULL;
  357. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_project integer NOT NULL;
  358. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_invoice integer NULL;
  359. ALTER TABLE llx_eventorganization_conferenceorboothattendee DROP FOREIGN KEY fx_eventorganization_conferenceorboothattendee_fk_soc;
  360. ALTER TABLE llx_eventorganization_conferenceorboothattendee DROP FOREIGN KEY fx_eventorganization_conferenceorboothattendee_fk_actioncomm;
  361. ALTER TABLE llx_eventorganization_conferenceorboothattendee DROP FOREIGN KEY fx_eventorganization_conferenceorboothattendee_fk_project;
  362. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid);
  363. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref);
  364. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc);
  365. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm);
  366. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email);
  367. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status);
  368. -- VMYSQL4.1 DROP INDEX uk_eventorganization_conferenceorboothattendee on llx_eventorganization_conferenceorboothattendee;
  369. -- VPGSQL8.2 DROP INDEX uk_eventorganization_conferenceorboothattendee;
  370. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_project, email, fk_actioncomm);
  371. create table llx_eventorganization_conferenceorboothattendee_extrafields
  372. (
  373. rowid integer AUTO_INCREMENT PRIMARY KEY,
  374. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  375. fk_object integer NOT NULL,
  376. import_key varchar(14) -- import key
  377. ) ENGINE=innodb;
  378. ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object);
  379. ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0;
  380. -- VPGSQL8.2 ALTER TABLE llx_c_ticket_category ALTER COLUMN pos TYPE INTEGER USING pos::INTEGER;
  381. -- VPGSQL8.2 ALTER TABLE llx_c_ticket_category ALTER COLUMN pos SET NOT NULL;
  382. -- VPGSQL8.2 ALTER TABLE llx_c_ticket_category ALTER COLUMN pos SET DEFAULT 0;
  383. ALTER TABLE llx_c_ticket_category MODIFY COLUMN pos integer DEFAULT 0 NOT NULL;
  384. ALTER TABLE llx_propal ADD COLUMN date_signature datetime AFTER date_valid;
  385. ALTER TABLE llx_propal ADD COLUMN fk_user_signature integer AFTER fk_user_valid;
  386. ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid);
  387. UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL;
  388. UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL;
  389. ALTER TABLE llx_product ADD COLUMN batch_mask VARCHAR(32) DEFAULT NULL;
  390. ALTER TABLE llx_product ADD COLUMN lifetime INTEGER NULL;
  391. ALTER TABLE llx_product ADD COLUMN qc_frequency INTEGER NULL;
  392. insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1);
  393. insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1);
  394. insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1);
  395. CREATE TABLE llx_partnership(
  396. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  397. ref varchar(128) DEFAULT '(PROV)' NOT NULL,
  398. status smallint NOT NULL DEFAULT '0',
  399. fk_soc integer,
  400. fk_member integer,
  401. date_partnership_start date NOT NULL,
  402. date_partnership_end date NULL,
  403. entity integer DEFAULT 1 NOT NULL, -- multi company id, 0 = all
  404. reason_decline_or_cancel text NULL,
  405. date_creation datetime NOT NULL,
  406. fk_user_creat integer NOT NULL,
  407. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  408. fk_user_modif integer,
  409. note_private text,
  410. note_public text,
  411. last_main_doc varchar(255),
  412. count_last_url_check_error integer DEFAULT '0',
  413. last_check_backlink datetime NULL,
  414. import_key varchar(14),
  415. model_pdf varchar(255)
  416. ) ENGINE=innodb;
  417. ALTER TABLE llx_partnership ADD COLUMN last_check_backlink datetime NULL;
  418. ALTER TABLE llx_partnership ADD INDEX idx_partnership_rowid (rowid);
  419. ALTER TABLE llx_partnership ADD INDEX idx_partnership_ref (ref);
  420. ALTER TABLE llx_partnership ADD INDEX idx_partnership_fk_soc (fk_soc);
  421. ALTER TABLE llx_partnership ADD CONSTRAINT llx_partnership_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
  422. ALTER TABLE llx_partnership ADD INDEX idx_partnership_status (status);
  423. ALTER TABLE llx_partnership ADD INDEX idx_partnership_fk_member (fk_member);
  424. create table llx_partnership_extrafields
  425. (
  426. rowid integer AUTO_INCREMENT PRIMARY KEY,
  427. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  428. fk_object integer NOT NULL,
  429. import_key varchar(14) -- import key
  430. ) ENGINE=innodb;
  431. ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object);
  432. INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillSoonBeCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonBeCanceledTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipWillSoonBeCanceledContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
  433. INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipCanceledContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
  434. INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipRefusedContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
  435. INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipAcceptedContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
  436. ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email;
  437. ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid;
  438. ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid;
  439. ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any
  440. -- Add external payment support for donation
  441. ALTER TABLE llx_payment_donation ADD COLUMN ext_payment_site varchar(128) AFTER note;
  442. ALTER TABLE llx_payment_donation ADD COLUMN ext_payment_id varchar(128) AFTER note;
  443. -- Rebuild sequence for postgres only after query INSERT INTO llx_salary(rowid, ...
  444. -- VPGSQL8.2 SELECT dol_util_rebuild_sequences();
  445. UPDATE llx_const SET type = 'chaine', value = __ENCRYPT('github')__ WHERE __DECRYPT('name')__ = 'MAIN_BUGTRACK_ENABLELINK' AND __DECRYPT('value')__ = '1';
  446. ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_remise_except integer DEFAULT NULL after remise_percent;
  447. ALTER TABLE llx_facture_fourn_det ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_except, fk_facture_fourn);
  448. CREATE TABLE llx_knowledgemanagement_knowledgerecord(
  449. -- BEGIN MODULEBUILDER FIELDS
  450. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  451. ref varchar(128) NOT NULL,
  452. date_creation datetime NOT NULL,
  453. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  454. last_main_doc varchar(255),
  455. fk_user_creat integer NOT NULL,
  456. fk_user_modif integer,
  457. fk_user_valid integer,
  458. import_key varchar(14),
  459. model_pdf varchar(255),
  460. question text NOT NULL,
  461. answer text,
  462. url varchar(255),
  463. fk_ticket integer,
  464. fk_c_ticket_category integer,
  465. status integer NOT NULL
  466. -- END MODULEBUILDER FIELDS
  467. ) ENGINE=innodb;
  468. ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN fk_ticket integer;
  469. ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN fk_c_ticket_category integer;
  470. ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN url varchar(255);
  471. create table llx_knowledgemanagement_knowledgerecord_extrafields
  472. (
  473. rowid integer AUTO_INCREMENT PRIMARY KEY,
  474. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  475. fk_object integer NOT NULL,
  476. import_key varchar(14) -- import key
  477. ) ENGINE=innodb;
  478. -- add default amount by member type
  479. ALTER TABLE llx_adherent_type ADD COLUMN amount DOUBLE(24,8) NULL DEFAULT NULL AFTER subscription;
  480. -- add action trigger
  481. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('COMPANY_MODIFY','Third party update','Executed when you update third party','societe',1);
  482. INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('CONTACT_MODIFY','Contact address update','Executed when a contact is updated','contact',51);
  483. create table llx_c_partnership_type
  484. (
  485. rowid integer AUTO_INCREMENT PRIMARY KEY,
  486. entity integer DEFAULT 1 NOT NULL,
  487. code varchar(32) NOT NULL,
  488. label varchar(64) NOT NULL,
  489. active tinyint DEFAULT 1 NOT NULL
  490. )ENGINE=innodb;
  491. DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee';
  492. CREATE TABLE llx_ecm_directories_extrafields
  493. (
  494. rowid integer AUTO_INCREMENT PRIMARY KEY,
  495. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  496. fk_object integer NOT NULL,
  497. import_key varchar(14) -- import key
  498. ) ENGINE=innodb;
  499. DROP TABLE llx_categorie_association;
  500. DROP TABLE llx_cond_reglement;
  501. DROP TABLE llx_zapier_hook_extrafields;
  502. CREATE TABLE llx_onlinesignature
  503. (
  504. rowid integer AUTO_INCREMENT PRIMARY KEY,
  505. entity integer DEFAULT 1 NOT NULL,
  506. object_type varchar(32) NOT NULL,
  507. object_id integer NOT NULL,
  508. datec datetime NOT NULL,
  509. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  510. name varchar(255) NOT NULL,
  511. ip varchar(128),
  512. pathoffile varchar(255)
  513. )ENGINE=innodb;
  514. -- VMYSQL4.3 ALTER TABLE llx_partnership MODIFY COLUMN date_partnership_end date NULL;
  515. -- VPGSQL8.2 ALTER TABLE llx_partnership ALTER COLUMN date_partnership_end DROP NOT NULL;
  516. ALTER TABLE llx_facture_fourn CHANGE COLUMN fk_mode_transport fk_transport_mode integer;
  517. ALTER TABLE llx_c_socialnetworks DROP INDEX idx_c_socialnetworks_code;
  518. ALTER TABLE llx_c_socialnetworks ADD UNIQUE INDEX idx_c_socialnetworks_code_entity (code, entity);
  519. ALTER TABLE llx_propaldet ADD COLUMN import_key varchar(14);