13.0.0-14.0.0.sql 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. ALTER TABLE llx_accounting_bookkeeping DROP INDEX idx_accounting_bookkeeping_numero_compte;
  33. ALTER TABLE llx_accounting_bookkeeping DROP INDEX idx_accounting_bookkeeping_code_journal;
  34. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
  35. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date);
  36. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte, entity);
  37. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal, entity);
  38. ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_piece_num (piece_num, entity);
  39. ALTER TABLE llx_recruitment_recruitmentcandidature MODIFY COLUMN email_msgid VARCHAR(175);
  40. ALTER TABLE llx_asset CHANGE COLUMN amount amount_ht double(24,8) DEFAULT NULL;
  41. ALTER TABLE llx_asset ADD COLUMN amount_vat double(24,8) DEFAULT NULL;
  42. ALTER TABLE llx_supplier_proposal_extrafields ADD INDEX idx_supplier_proposal_extrafields (fk_object);
  43. ALTER TABLE llx_supplier_proposaldet_extrafields ADD INDEX idx_supplier_proposaldet_extrafields (fk_object);
  44. ALTER TABLE llx_asset_extrafields ADD INDEX idx_asset_extrafields (fk_object);
  45. insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4);
  46. -- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL;
  47. -- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL;
  48. 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');
  49. ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64);
  50. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 11, 'US-BASE', 'USA basic chart of accounts', 1);
  51. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 14, 'CA-ENG-BASE', 'Canadian basic chart of accounts - English', 1);
  52. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 154, 'SAT/24-2019', 'Catalogo y codigo agrupador fiscal del 2019', 1);
  53. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'auguria';
  54. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'bureau2crea';
  55. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'amarok';
  56. UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'cameleo';
  57. DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', 'amarok', 'cameleo');
  58. -- For v14
  59. ALTER TABLE llx_product_lot ADD COLUMN eol_date datetime NULL;
  60. ALTER TABLE llx_product_lot ADD COLUMN manufacturing_date datetime NULL;
  61. ALTER TABLE llx_product_lot ADD COLUMN scrapping_date datetime NULL;
  62. create table llx_accounting_groups_account
  63. (
  64. rowid integer AUTO_INCREMENT PRIMARY KEY,
  65. fk_accounting_account INTEGER NOT NULL,
  66. fk_c_accounting_category INTEGER NOT NULL
  67. )ENGINE=innodb;
  68. ALTER TABLE llx_oauth_token ADD COLUMN restricted_ips varchar(200);
  69. ALTER TABLE llx_oauth_token ADD COLUMN datec datetime DEFAULT NULL;
  70. ALTER TABLE llx_oauth_token ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
  71. ALTER TABLE llx_events ADD COLUMN authentication_method varchar(64) NULL;
  72. ALTER TABLE llx_events ADD COLUMN fk_oauth_token integer NULL;
  73. ALTER TABLE llx_mailing_cibles MODIFY COLUMN tag varchar(64) NULL;
  74. ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_tag (tag);
  75. ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0;
  76. ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) AFTER rowid;
  77. UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL;
  78. ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL;
  79. ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity);
  80. ALTER TABLE llx_societe ADD COLUMN accountancy_code_sell varchar(32) AFTER webservices_key;
  81. ALTER TABLE llx_societe ADD COLUMN accountancy_code_buy varchar(32) AFTER accountancy_code_sell;
  82. ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL;
  83. ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL;
  84. ALTER TABLE llx_facture MODIFY COLUMN date_valid DATETIME NULL DEFAULT NULL;
  85. -- 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);
  86. -- 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);
  87. -- 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);
  88. -- 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);
  89. -- 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);
  90. ALTER TABLE llx_website ADD COLUMN lastaccess datetime NULL;
  91. ALTER TABLE llx_website ADD COLUMN pageviews_month BIGINT UNSIGNED DEFAULT 0;
  92. ALTER TABLE llx_website ADD COLUMN pageviews_total BIGINT UNSIGNED DEFAULT 0;
  93. -- Drop foreign key with bad name or not required
  94. ALTER TABLE llx_workstation_workstation DROP FOREIGN KEY llx_workstation_workstation_fk_user_creat;
  95. ALTER TABLE llx_propal DROP FOREIGN KEY llx_propal_fk_warehouse;
  96. CREATE TABLE llx_workstation_workstation(
  97. -- BEGIN MODULEBUILDER FIELDS
  98. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  99. ref varchar(128) DEFAULT '(PROV)' NOT NULL,
  100. label varchar(255),
  101. type varchar(7),
  102. note_public text,
  103. entity int DEFAULT 1,
  104. note_private text,
  105. date_creation datetime NOT NULL,
  106. tms timestamp,
  107. fk_user_creat integer NOT NULL,
  108. fk_user_modif integer,
  109. import_key varchar(14),
  110. status smallint NOT NULL,
  111. nb_operators_required integer,
  112. thm_operator_estimated double,
  113. thm_machine_estimated double
  114. -- END MODULEBUILDER FIELDS
  115. ) ENGINE=innodb;
  116. ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_rowid (rowid);
  117. ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_ref (ref);
  118. ALTER TABLE llx_workstation_workstation ADD CONSTRAINT fk_workstation_workstation_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
  119. ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_status (status);
  120. CREATE TABLE llx_workstation_workstation_resource(
  121. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  122. tms timestamp,
  123. fk_resource integer,
  124. fk_workstation integer
  125. ) ENGINE=innodb;
  126. CREATE TABLE llx_workstation_workstation_usergroup(
  127. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  128. tms timestamp,
  129. fk_usergroup integer,
  130. fk_workstation integer
  131. ) ENGINE=innodb;
  132. DROP TABLE llx_c_producbatch_qcstatus; -- delete table with bad name
  133. CREATE TABLE llx_c_productbatch_qcstatus(
  134. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  135. entity integer NOT NULL DEFAULT 1,
  136. code varchar(16) NOT NULL,
  137. label varchar(50) NOT NULL,
  138. active integer DEFAULT 1 NOT NULL
  139. ) ENGINE=innodb;
  140. ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code, entity);
  141. INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1);
  142. INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1);
  143. ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30);
  144. ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30);
  145. ALTER TABLE llx_propal ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_shipping_method;
  146. --ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
  147. ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse);
  148. ALTER TABLE llx_societe DROP INDEX idx_societe_entrepot;
  149. ALTER TABLE llx_societe CHANGE fk_entrepot fk_warehouse INTEGER DEFAULT NULL;
  150. --ALTER TABLE llx_societe ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
  151. ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse);
  152. -- VMYSQL4.3 ALTER TABLE llx_societe MODIFY COLUMN fk_typent integer NULL;
  153. -- VPGSQL8.2 ALTER TABLE llx_societe ALTER COLUMN fk_typent DROP NOT NULL;
  154. UPDATE llx_societe SET fk_typent=NULL, tms=tms WHERE fk_typent=0;
  155. DELETE FROM llx_c_typent WHERE code='TE_UNKNOWN';
  156. ALTER TABLE llx_socpeople MODIFY poste varchar(255);
  157. ALTER TABLE llx_menu ADD COLUMN prefix varchar(255) NULL AFTER titre;
  158. ALTER TABLE llx_chargesociales ADD COLUMN fk_user integer DEFAULT NULL;
  159. ALTER TABLE llx_mrp_production ADD COLUMN origin_id integer AFTER fk_mo;
  160. ALTER TABLE llx_mrp_production ADD COLUMN origin_type varchar(10) AFTER origin_id;
  161. ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
  162. ALTER TABLE llx_projet ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
  163. ALTER TABLE llx_expensereport ADD COLUMN last_main_doc varchar(255) DEFAULT NULL AFTER model_pdf;
  164. create table llx_payment_vat
  165. (
  166. rowid integer AUTO_INCREMENT PRIMARY KEY,
  167. fk_tva integer,
  168. datec datetime, -- date de creation
  169. tms timestamp,
  170. datep datetime, -- payment date
  171. amount double(24,8) DEFAULT 0,
  172. fk_typepaiement integer NOT NULL,
  173. num_paiement varchar(50),
  174. note text,
  175. fk_bank integer NOT NULL,
  176. fk_user_creat integer, -- creation user
  177. fk_user_modif integer -- last modification user
  178. )ENGINE=innodb;
  179. ALTER TABLE llx_tva ADD COLUMN paye smallint default 1 NOT NULL;
  180. ALTER TABLE llx_tva ADD COLUMN fk_account integer;
  181. 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;
  182. --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';
  183. --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';
  184. --ALTER TABLE llx_tva DROP COLUMN fk_bank;
  185. ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0;
  186. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,<br /><br />__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__<br /><br />__ONLINE_PAYMENT_TEXT_AND_URL__<br /><br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  187. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,<br /><br />__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__<br /><br />__ONLINE_PAYMENT_TEXT_AND_URL__<br /><br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  188. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,<br /><br />__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__<br /><br />__ONLINE_PAYMENT_TEXT_AND_URL__<br /><br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  189. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,<br /><br />__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__<br /><br />__(Sincerely)__<br /><br />__MYCOMPANY_NAME__<br />__USER_SIGNATURE__', null, '1', null);
  190. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,<br /><br />__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__<br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  191. INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,<br /><br />__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__<br /><br />__(Sincerely)__<br />__USER_SIGNATURE__', null, '1', null);
  192. ALTER TABLE llx_projet ADD COLUMN accept_conference_suggestions integer DEFAULT 0;
  193. ALTER TABLE llx_projet ADD COLUMN accept_booth_suggestions integer DEFAULT 0;
  194. ALTER TABLE llx_projet ADD COLUMN price_registration double(24,8);
  195. ALTER TABLE llx_projet ADD COLUMN price_booth double(24,8);
  196. ALTER TABLE llx_actioncomm ADD COLUMN num_vote integer DEFAULT NULL AFTER reply_to;
  197. ALTER TABLE llx_actioncomm ADD COLUMN event_paid smallint NOT NULL DEFAULT 0 AFTER num_vote;
  198. ALTER TABLE llx_actioncomm ADD COLUMN status smallint NOT NULL DEFAULT 0 AFTER event_paid;
  199. ALTER TABLE llx_actioncomm ADD COLUMN ref varchar(30) AFTER id;
  200. UPDATE llx_actioncomm SET ref = id WHERE ref = '' OR ref IS NULL;
  201. ALTER TABLE llx_actioncomm MODIFY COLUMN ref varchar(30) NOT NULL;
  202. ALTER TABLE llx_actioncomm ADD UNIQUE INDEX uk_actioncomm_ref (ref, entity);
  203. ALTER TABLE llx_c_actioncomm MODIFY code varchar(50) NOT NULL;
  204. ALTER TABLE llx_c_actioncomm MODIFY module varchar(50) DEFAULT NULL;
  205. 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);
  206. INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 61,'AC_EO_INDOORCONF','module','Indoor conference','conference@eventorganization', 1, 61);
  207. 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);
  208. INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) VALUES ( 63,'AC_EO_INDOORBOOTH','module','Indoor booth','booth@eventorganization', 1, 63);
  209. -- Code enhanced - Standardize field name
  210. ALTER TABLE llx_commande CHANGE COLUMN tva total_tva double(24,8) default 0;
  211. ALTER TABLE llx_supplier_proposal CHANGE COLUMN tva total_tva double(24,8) default 0;
  212. ALTER TABLE llx_supplier_proposal CHANGE COLUMN total total_ttc double(24,8) default 0;
  213. ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0;
  214. ALTER TABLE llx_propal CHANGE COLUMN total total_ttc double(24,8) default 0;
  215. ALTER TABLE llx_facture CHANGE COLUMN tva total_tva double(24,8) default 0;
  216. ALTER TABLE llx_facture CHANGE COLUMN total total_ht double(24,8) default 0;
  217. ALTER TABLE llx_facture_rec CHANGE COLUMN tva total_tva double(24,8) default 0;
  218. ALTER TABLE llx_facture_rec CHANGE COLUMN total total_ht double(24,8) default 0;
  219. ALTER TABLE llx_commande_fournisseur CHANGE COLUMN tva total_tva double(24,8) default 0;
  220. --VMYSQL4.3 ALTER TABLE llx_c_civility CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
  221. --VPGSQL8.2 CREATE SEQUENCE llx_c_civility_rowid_seq OWNED BY llx_c_civility.rowid;
  222. --VPGSQL8.2 ALTER TABLE llx_c_civility ALTER COLUMN rowid SET DEFAULT nextval('llx_c_civility_rowid_seq');
  223. --VPGSQL8.2 SELECT setval('llx_c_civility_rowid_seq', MAX(rowid)) FROM llx_c_civility;
  224. -- Change for salary intent table
  225. create table llx_salary
  226. (
  227. rowid integer AUTO_INCREMENT PRIMARY KEY,
  228. ref varchar(30) NULL, -- payment reference number (currently NULL because there is no numbering manager yet)
  229. label varchar(255),
  230. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  231. datec datetime, -- Create date
  232. fk_user integer NOT NULL,
  233. datep date, -- payment date
  234. datev date, -- value date (this field should not be here, only into bank tables)
  235. salary double(24,8), -- salary of user when payment was done
  236. amount double(24,8) NOT NULL DEFAULT 0,
  237. fk_projet integer DEFAULT NULL,
  238. datesp date, -- date start period
  239. dateep date, -- date end period
  240. entity integer DEFAULT 1 NOT NULL, -- multi company id
  241. note text,
  242. fk_bank integer,
  243. paye smallint default 1 NOT NULL,
  244. fk_typepayment integer NOT NULL, -- default payment mode for payment
  245. fk_account integer, -- default bank account for payment
  246. fk_user_author integer, -- user creating
  247. fk_user_modif integer -- user making last change
  248. ) ENGINE=innodb;
  249. -- VMYSQL4.1 ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user fk_user integer NULL;
  250. -- VPGSQL8.2 ALTER TABLE llx_payment_salary ALTER COLUMN fk_user DROP NOT NULL;
  251. ALTER TABLE llx_payment_salary ADD COLUMN fk_salary integer;
  252. 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;
  253. UPDATE llx_payment_salary SET fk_salary = rowid WHERE fk_salary IS NULL;
  254. UPDATE llx_payment_salary SET ref = rowid WHERE ref IS NULL;
  255. ALTER TABLE llx_salary ALTER COLUMN paye set default 0;
  256. 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'));
  257. 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');
  258. -- 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);
  259. -- 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);
  260. -- 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);
  261. -- 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);
  262. create table llx_product_perentity
  263. (
  264. rowid integer AUTO_INCREMENT PRIMARY KEY,
  265. fk_product integer,
  266. entity integer DEFAULT 1 NOT NULL, -- multi company id
  267. accountancy_code_sell varchar(32), -- Selling accountancy code
  268. accountancy_code_sell_intra varchar(32), -- Selling accountancy code for vat intracommunity
  269. accountancy_code_sell_export varchar(32), -- Selling accountancy code for vat export
  270. accountancy_code_buy varchar(32), -- Buying accountancy code
  271. accountancy_code_buy_intra varchar(32), -- Buying accountancy code for vat intracommunity
  272. accountancy_code_buy_export varchar(32), -- Buying accountancy code for vat import
  273. pmp double(24,8)
  274. )ENGINE=innodb;
  275. ALTER TABLE llx_product_perentity ADD INDEX idx_product_perentity_fk_product (fk_product);
  276. ALTER TABLE llx_product_perentity ADD UNIQUE INDEX uk_product_perentity (fk_product, entity);
  277. create table llx_societe_perentity
  278. (
  279. rowid integer AUTO_INCREMENT PRIMARY KEY,
  280. fk_soc integer,
  281. entity integer DEFAULT 1 NOT NULL, -- multi company id
  282. -- code_compta varchar(24), -- code compta client
  283. -- code_compta_fournisseur varchar(24), -- code compta founisseur
  284. accountancy_code_sell varchar(32), -- Selling accountancy code
  285. accountancy_code_buy varchar(32) -- Buying accountancy code
  286. )ENGINE=innodb;
  287. ALTER TABLE llx_societe_perentity ADD INDEX idx_societe_perentity_fk_soc (fk_soc);
  288. ALTER TABLE llx_societe_perentity ADD UNIQUE INDEX uk_societe_perentity (fk_soc, entity);
  289. CREATE TABLE llx_eventorganization_conferenceorboothattendee(
  290. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  291. ref varchar(128) NOT NULL,
  292. fk_soc integer,
  293. fk_actioncomm integer NOT NULL,
  294. email varchar(100),
  295. date_subscription datetime,
  296. amount double DEFAULT NULL,
  297. note_public text,
  298. note_private text,
  299. date_creation datetime NOT NULL,
  300. tms timestamp,
  301. fk_user_creat integer,
  302. fk_user_modif integer,
  303. last_main_doc varchar(255),
  304. import_key varchar(14),
  305. model_pdf varchar(255),
  306. status smallint NOT NULL
  307. ) ENGINE=innodb;
  308. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid);
  309. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref);
  310. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc);
  311. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm);
  312. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id);
  313. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email);
  314. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status);
  315. ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email);
  316. create table llx_eventorganization_conferenceorboothattendee_extrafields
  317. (
  318. rowid integer AUTO_INCREMENT PRIMARY KEY,
  319. tms timestamp,
  320. fk_object integer NOT NULL,
  321. import_key varchar(14) -- import key
  322. ) ENGINE=innodb;
  323. ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object);
  324. ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0;
  325. ALTER TABLE llx_c_ticket_category MODIFY COLUMN pos integer DEFAULT 0 NOT NULL;
  326. ALTER TABLE llx_propal ADD COLUMN date_signature datetime AFTER date_valid;
  327. ALTER TABLE llx_propal ADD COLUMN fk_user_signature integer AFTER fk_user_valid;
  328. ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid);
  329. UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL;
  330. UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL;
  331. ALTER TABLE llx_product ADD COLUMN batch_mask VARCHAR(32) DEFAULT NULL;
  332. ALTER TABLE llx_product ADD COLUMN lifetime INTEGER NULL;
  333. ALTER TABLE llx_product ADD COLUMN qc_frequency INTEGER NULL;
  334. insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1);
  335. insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1);
  336. insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1);
  337. CREATE TABLE llx_partnership(
  338. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  339. ref varchar(128) DEFAULT '(PROV)' NOT NULL,
  340. status smallint NOT NULL DEFAULT '0',
  341. fk_soc integer,
  342. fk_member integer,
  343. date_partnership_start date NOT NULL,
  344. date_partnership_end date NOT NULL,
  345. entity integer DEFAULT 1 NOT NULL, -- multi company id, 0 = all
  346. reason_decline_or_cancel text NULL,
  347. date_creation datetime NOT NULL,
  348. fk_user_creat integer NOT NULL,
  349. tms timestamp,
  350. fk_user_modif integer,
  351. note_private text,
  352. note_public text,
  353. last_main_doc varchar(255),
  354. count_last_url_check_error integer DEFAULT '0',
  355. last_check_backlink datetime NULL,
  356. import_key varchar(14),
  357. model_pdf varchar(255)
  358. ) ENGINE=innodb;
  359. ALTER TABLE llx_partnership ADD COLUMN last_check_backlink datetime NULL;
  360. ALTER TABLE llx_partnership ADD INDEX idx_partnership_rowid (rowid);
  361. ALTER TABLE llx_partnership ADD INDEX idx_partnership_ref (ref);
  362. ALTER TABLE llx_partnership ADD INDEX idx_partnership_fk_soc (fk_soc);
  363. ALTER TABLE llx_partnership ADD CONSTRAINT llx_partnership_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
  364. ALTER TABLE llx_partnership ADD INDEX idx_partnership_status (status);
  365. ALTER TABLE llx_partnership ADD INDEX idx_partnership_fk_member (fk_member);
  366. create table llx_partnership_extrafields
  367. (
  368. rowid integer AUTO_INCREMENT PRIMARY KEY,
  369. tms timestamp,
  370. fk_object integer NOT NULL,
  371. import_key varchar(14) -- import key
  372. ) ENGINE=innodb;
  373. ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object);
  374. 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');
  375. 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');
  376. 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');
  377. 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');
  378. ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email;
  379. ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid;
  380. ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid;
  381. ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any
  382. -- Add external payment support for donation
  383. ALTER TABLE llx_payment_donation ADD COLUMN ext_payment_site varchar(128) AFTER note;
  384. ALTER TABLE llx_payment_donation ADD COLUMN ext_payment_id varchar(128) AFTER note;
  385. -- Rebuild sequence for postgres only after query INSERT INTO llx_salary(rowid, ...
  386. -- VPGSQL8.2 SELECT dol_util_rebuild_sequences();
  387. UPDATE llx_const SET type = 'chaine', value = __ENCRYPT('github')__ WHERE __DECRYPT('name')__ = 'MAIN_BUGTRACK_ENABLELINK' AND __DECRYPT('value')__ = 1;
  388. ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_remise_except integer DEFAULT NULL after remise_percent;
  389. ALTER TABLE llx_facture_fourn_det ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_except, fk_facture_fourn);
  390. CREATE TABLE llx_knowledgemanagement_knowledgerecord(
  391. -- BEGIN MODULEBUILDER FIELDS
  392. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  393. ref varchar(128) NOT NULL,
  394. date_creation datetime NOT NULL,
  395. tms timestamp,
  396. last_main_doc varchar(255),
  397. fk_user_creat integer NOT NULL,
  398. fk_user_modif integer,
  399. fk_user_valid integer,
  400. import_key varchar(14),
  401. model_pdf varchar(255),
  402. question text NOT NULL,
  403. answer text,
  404. url varchar(255),
  405. fk_ticket integer,
  406. status integer NOT NULL
  407. -- END MODULEBUILDER FIELDS
  408. ) ENGINE=innodb;
  409. ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN fk_ticket integer;
  410. ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN url varchar(255);
  411. create table llx_knowledgemanagement_knowledgerecord_extrafields
  412. (
  413. rowid integer AUTO_INCREMENT PRIMARY KEY,
  414. tms timestamp,
  415. fk_object integer NOT NULL,
  416. import_key varchar(14) -- import key
  417. ) ENGINE=innodb;
  418. -- add default amount by member type
  419. ALTER TABLE llx_adherent_type ADD COLUMN amount DOUBLE(24,8) NULL DEFAULT NULL AFTER subscription;
  420. -- add action trigger
  421. 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);
  422. 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);
  423. create table llx_c_partnership_type
  424. (
  425. rowid integer AUTO_INCREMENT PRIMARY KEY,
  426. entity integer DEFAULT 1 NOT NULL,
  427. code varchar(32) NOT NULL,
  428. label varchar(64) NOT NULL,
  429. active tinyint DEFAULT 1 NOT NULL
  430. )ENGINE=innodb;