7.0.0-8.0.0.sql 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. --
  2. -- Be carefull to requests order.
  3. -- This file must be loaded by calling /install/index.php page
  4. -- when current version is 8.0.0 or higher.
  5. --
  6. -- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
  7. -- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
  8. -- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
  9. -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
  10. -- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
  11. -- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
  12. -- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table
  13. -- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex
  14. -- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
  15. -- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
  16. -- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
  17. -- To make pk to be auto increment (postgres):
  18. -- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid;
  19. -- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid);
  20. -- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq');
  21. -- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table;
  22. -- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL;
  23. -- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
  24. -- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL;
  25. -- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL;
  26. -- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
  27. -- Note: fields with type BLOB/TEXT can't have default value.
  28. -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
  29. -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
  30. -- Forgot in 7.0
  31. -- VMYSQL4.1 ALTER TABLE llx_product_association ADD COLUMN rowid integer AUTO_INCREMENT PRIMARY KEY;
  32. ALTER TABLE llx_website_page ADD COLUMN fk_user_create integer;
  33. ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
  34. ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFAULT 'page';
  35. -- drop very old table (bad name)
  36. DROP TABLE llx_c_accountancy_category;
  37. DROP TABLE llx_c_accountingaccount;
  38. update llx_propal set fk_statut = 1 where fk_statut = -1;
  39. ALTER TABLE llx_inventory ADD COLUMN fk_user_creat integer;
  40. ALTER TABLE llx_inventory ADD COLUMN fk_user_modif integer;
  41. ALTER TABLE llx_inventory ADD COLUMN fk_user_valid integer;
  42. ALTER TABLE llx_inventory ADD COLUMN import_key varchar(14);
  43. -- Missing Chart of accounts in migration 7.0.0
  44. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG14-DEV', 'The developed accountancy french plan 2014', 1);
  45. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 6, 'PCG_SUISSE', 'Switzerland plan', 1);
  46. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (140, 'PCN-LUXEMBURG', 'Plan comptable normalisé Luxembourgeois', 1);
  47. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 80, 'DK-STD', 'Standardkontoplan fra SKAT', 1);
  48. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 10, 'PCT', 'The Tunisia plan', 1);
  49. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 12, 'PCG', 'The Moroccan chart of accounts', 1);
  50. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 67,'PC-MIPYME', 'The PYME accountancy Chile plan', 1);
  51. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 7,'ENG-BASE', 'England plan', 1);
  52. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA-BJ', 'Plan comptable Ouest-Africain', 1);
  53. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA-BF', 'Plan comptable Ouest-Africain', 1);
  54. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA-CM', 'Plan comptable Ouest-Africain', 1);
  55. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA-CF', 'Plan comptable Ouest-Africain', 1);
  56. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA-KM', 'Plan comptable Ouest-Africain', 1);
  57. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA-CG', 'Plan comptable Ouest-Africain', 1);
  58. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA-CI', 'Plan comptable Ouest-Africain', 1);
  59. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA-GA', 'Plan comptable Ouest-Africain', 1);
  60. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA-GQ', 'Plan comptable Ouest-Africain', 1);
  61. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA-ML', 'Plan comptable Ouest-Africain', 1);
  62. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA-NE', 'Plan comptable Ouest-Africain', 1);
  63. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA-CD', 'Plan comptable Ouest-Africain', 1);
  64. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA-SN', 'Plan comptable Ouest-Africain', 1);
  65. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA-TD', 'Plan comptable Ouest-Africain', 1);
  66. INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA-TG', 'Plan comptable Ouest-Africain', 1);
  67. -- For 8.0
  68. -- delete old permission no more used
  69. DELETE FROM llx_rights_def WHERE perms = 'main' and module = 'commercial';
  70. delete from llx_rights_def where perms IS NULL;
  71. delete from llx_user_rights where fk_user not IN (select rowid from llx_user);
  72. delete from llx_usergroup_rights where fk_usergroup not in (select rowid from llx_usergroup);
  73. delete from llx_usergroup_rights where fk_id not in (select id from llx_rights_def);
  74. ALTER TABLE llx_inventory ADD COLUMN fk_product integer DEFAULT NULL;
  75. ALTER TABLE llx_inventory MODIFY COLUMN fk_warehouse integer DEFAULT NULL;
  76. ALTER TABLE llx_c_type_fees ADD COLUMN llx_c_type_fees integer DEFAULT 0;
  77. ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges;
  78. ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0;
  79. ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0;
  80. ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit;
  81. ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount;
  82. create table llx_c_type_container
  83. (
  84. rowid integer AUTO_INCREMENT PRIMARY KEY,
  85. code varchar(32) NOT NULL,
  86. entity integer DEFAULT 1 NOT NULL, -- multi company id
  87. label varchar(64) NOT NULL,
  88. module varchar(32) NULL,
  89. active tinyint DEFAULT 1 NOT NULL
  90. )ENGINE=innodb;
  91. ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity);
  92. ALTER TABLE llx_societe_remise_except ADD COLUMN discount_type integer DEFAULT 0 NOT NULL AFTER fk_soc;
  93. ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_discount_type (discount_type);
  94. ALTER TABLE llx_societe ADD COLUMN remise_supplier real DEFAULT 0 AFTER remise_client;
  95. CREATE TABLE llx_societe_remise_supplier
  96. (
  97. rowid integer AUTO_INCREMENT PRIMARY KEY,
  98. entity integer DEFAULT 1 NOT NULL, -- multi company id
  99. fk_soc integer NOT NULL,
  100. tms timestamp,
  101. datec datetime, -- creation date
  102. fk_user_author integer, -- creation user
  103. remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount
  104. note text
  105. )ENGINE=innodb;
  106. insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1);
  107. insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1);
  108. insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1);
  109. insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1);
  110. -- For supplier product buy price in multicurency
  111. ALTER TABLE llx_product_fournisseur_price CHANGE COLUMN multicurrency_price_ttc multicurrency_unitprice DOUBLE(24,8) NULL DEFAULT NULL;
  112. ALTER TABLE llx_product_fournisseur_price_log CHANGE COLUMN multicurrency_price_ttc multicurrency_unitprice DOUBLE(24,8) NULL DEFAULT NULL;
  113. ALTER TABLE llx_expensereport_det ADD COLUMN docnumber varchar(128) after fk_expensereport;
  114. ALTER TABLE llx_website_page ADD COLUMN aliasalt varchar(255) after pageurl;
  115. -- Add missing keys and primary key
  116. DELETE FROM llx_c_paiement WHERE code = '' or code = '-' or id = 0;
  117. ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement;
  118. ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement_code(entity, code);
  119. -- VMYSQL4.3 ALTER TABLE llx_c_paiement CHANGE COLUMN id id INTEGER AUTO_INCREMENT PRIMARY KEY;
  120. -- VPGSQL8.2 CREATE SEQUENCE llx_c_paiement_id_seq OWNED BY llx_c_paiement.id;
  121. -- VPGSQL8.2 ALTER TABLE llx_c_paiement ADD PRIMARY KEY (id);
  122. -- VPGSQL8.2 ALTER TABLE llx_c_paiement ALTER COLUMN id SET DEFAULT nextval('llx_c_paiement_id_seq');
  123. -- VPGSQL8.2 SELECT setval('llx_c_paiement_id_seq', MAX(id)) FROM llx_c_paiement;
  124. -- Add missing keys and primary key
  125. ALTER TABLE llx_c_payment_term DROP INDEX uk_c_payment_term;
  126. ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term_code(entity, code);
  127. -- VMYSQL4.3 ALTER TABLE llx_c_payment_term CHANGE COLUMN rowid rowid INTEGER AUTO_INCREMENT PRIMARY KEY;
  128. -- VPGSQL8.2 CREATE SEQUENCE llx_c_payment_term_rowid_seq OWNED BY llx_c_payment_term.rowid;
  129. -- VPGSQL8.2 ALTER TABLE llx_c_payment_term ADD PRIMARY KEY (rowid);
  130. -- VPGSQL8.2 ALTER TABLE llx_c_payment_term ALTER COLUMN rowid SET DEFAULT nextval('llx_c_payment_term_rowid_seq');
  131. -- VPGSQL8.2 SELECT setval('llx_c_payment_term_rowid_seq', MAX(rowid)) FROM llx_c_payment_term;
  132. ALTER TABLE llx_oauth_token ADD COLUMN tokenstring text;
  133. -- Add field for payment modes
  134. ALTER TABLE llx_societe_rib ADD COLUMN type varchar(32) DEFAULT 'ban' after rowid;
  135. ALTER TABLE llx_societe_rib ADD COLUMN last_four varchar(4);
  136. ALTER TABLE llx_societe_rib ADD COLUMN card_type varchar(255);
  137. ALTER TABLE llx_societe_rib ADD COLUMN cvn varchar(255);
  138. ALTER TABLE llx_societe_rib ADD COLUMN exp_date_month INTEGER;
  139. ALTER TABLE llx_societe_rib ADD COLUMN exp_date_year INTEGER;
  140. ALTER TABLE llx_societe_rib ADD COLUMN country_code varchar(10);
  141. ALTER TABLE llx_societe_rib ADD COLUMN approved integer DEFAULT 0;
  142. ALTER TABLE llx_societe_rib ADD COLUMN email varchar(255);
  143. ALTER TABLE llx_societe_rib ADD COLUMN ending_date date;
  144. ALTER TABLE llx_societe_rib ADD COLUMN max_total_amount_of_all_payments double(24,8);
  145. ALTER TABLE llx_societe_rib ADD COLUMN preapproval_key varchar(255);
  146. ALTER TABLE llx_societe_rib ADD COLUMN starting_date date;
  147. ALTER TABLE llx_societe_rib ADD COLUMN total_amount_of_all_payments double(24,8);
  148. ALTER TABLE llx_societe_rib ADD COLUMN stripe_card_ref varchar(128);
  149. ALTER TABLE llx_societe_rib ADD COLUMN status integer NOT NULL DEFAULT 1;
  150. UPDATE llx_societe_rib set type = 'ban' where type = '' OR type IS NULL;
  151. -- VMYSQL4.3 ALTER TABLE llx_societe_rib MODIFY COLUMN type varchar(32) NOT NULL;
  152. -- VPGSQL8.2 ALTER TABLE llx_societe_rib ALTER COLUMN type SET NOT NULL;
  153. CREATE TABLE llx_ticketsup
  154. (
  155. rowid integer AUTO_INCREMENT PRIMARY KEY,
  156. entity integer DEFAULT 1,
  157. ref varchar(128) NOT NULL,
  158. track_id varchar(128) NOT NULL,
  159. fk_soc integer DEFAULT 0,
  160. fk_project integer DEFAULT 0,
  161. origin_email varchar(128),
  162. fk_user_create integer,
  163. fk_user_assign integer,
  164. subject varchar(255),
  165. message text,
  166. fk_statut integer,
  167. resolution integer,
  168. progress varchar(100),
  169. timing varchar(20),
  170. type_code varchar(32),
  171. category_code varchar(32),
  172. severity_code varchar(32),
  173. datec datetime,
  174. date_read datetime,
  175. date_close datetime,
  176. notify_tiers_at_create tinyint,
  177. tms timestamp
  178. )ENGINE=innodb;
  179. ALTER TABLE llx_ticketsup ADD COLUMN notify_tiers_at_create integer;
  180. ALTER TABLE llx_ticketsup DROP INDEX uk_ticketsup_rowid_track_id;
  181. ALTER TABLE llx_ticketsup ADD UNIQUE uk_ticketsup_track_id (track_id);
  182. CREATE TABLE llx_ticketsup_msg
  183. (
  184. rowid integer AUTO_INCREMENT PRIMARY KEY,
  185. entity integer DEFAULT 1,
  186. fk_track_id varchar(128),
  187. fk_user_action integer,
  188. datec datetime,
  189. message text,
  190. private integer DEFAULT 0
  191. )ENGINE=innodb;
  192. ALTER TABLE llx_ticketsup_msg ADD CONSTRAINT fk_ticketsup_msg_fk_track_id FOREIGN KEY (fk_track_id) REFERENCES llx_ticketsup (track_id);
  193. CREATE TABLE llx_ticketsup_logs
  194. (
  195. rowid integer AUTO_INCREMENT PRIMARY KEY,
  196. entity integer DEFAULT 1,
  197. fk_track_id varchar(128),
  198. fk_user_create integer,
  199. datec datetime,
  200. message text
  201. )ENGINE=innodb;
  202. ALTER TABLE llx_ticketsup_logs ADD CONSTRAINT fk_ticketsup_logs_fk_track_id FOREIGN KEY (fk_track_id) REFERENCES llx_ticketsup (track_id);
  203. CREATE TABLE llx_ticketsup_extrafields
  204. (
  205. rowid integer AUTO_INCREMENT PRIMARY KEY,
  206. tms timestamp,
  207. fk_object integer NOT NULL,
  208. import_key varchar(14)
  209. )ENGINE=innodb;
  210. -- Create dictionaries tables for ticket
  211. create table llx_c_ticketsup_severity
  212. (
  213. rowid integer AUTO_INCREMENT PRIMARY KEY,
  214. entity integer DEFAULT 1,
  215. code varchar(32) NOT NULL,
  216. pos varchar(32) NOT NULL,
  217. label varchar(128) NOT NULL,
  218. color varchar(10) NOT NULL,
  219. active integer DEFAULT 1,
  220. use_default integer DEFAULT 1,
  221. description varchar(255)
  222. )ENGINE=innodb;
  223. create table llx_c_ticketsup_type
  224. (
  225. rowid integer AUTO_INCREMENT PRIMARY KEY,
  226. entity integer DEFAULT 1,
  227. code varchar(32) NOT NULL,
  228. pos varchar(32) NOT NULL,
  229. label varchar(128) NOT NULL,
  230. active integer DEFAULT 1,
  231. use_default integer DEFAULT 1,
  232. description varchar(255)
  233. )ENGINE=innodb;
  234. create table llx_c_ticketsup_category
  235. (
  236. rowid integer AUTO_INCREMENT PRIMARY KEY,
  237. entity integer DEFAULT 1,
  238. code varchar(32) NOT NULL,
  239. pos varchar(32) NOT NULL,
  240. label varchar(128) NOT NULL,
  241. active integer DEFAULT 1,
  242. use_default integer DEFAULT 1,
  243. description varchar(255)
  244. )ENGINE=innodb;
  245. ALTER TABLE llx_c_ticketsup_category ADD UNIQUE INDEX uk_code (code, entity);
  246. ALTER TABLE llx_c_ticketsup_severity ADD UNIQUE INDEX uk_code (code, entity);
  247. ALTER TABLE llx_c_ticketsup_type ADD UNIQUE INDEX uk_code (code, entity);
  248. -- Load data
  249. INSERT INTO llx_c_ticketsup_severity (code, pos, label, color, active, use_default, description) VALUES('LOW', '10', 'Low', '', 1, 0, NULL);
  250. INSERT INTO llx_c_ticketsup_severity (code, pos, label, color, active, use_default, description) VALUES('NORMAL', '20', 'Normal', '', 1, 1, NULL);
  251. INSERT INTO llx_c_ticketsup_severity (code, pos, label, color, active, use_default, description) VALUES('HIGH', '30', 'High', '', 1, 0, NULL);
  252. INSERT INTO llx_c_ticketsup_severity (code, pos, label, color, active, use_default, description) VALUES('BLOCKING', '40', 'Critical / blocking', '', 1, 0, NULL);
  253. INSERT INTO llx_c_ticketsup_type (code, pos, label, active, use_default, description) VALUES('COM', '10', 'Commercial question', 1, 1, NULL);
  254. INSERT INTO llx_c_ticketsup_type (code, pos, label, active, use_default, description) VALUES('ISSUE', '20', 'Issue or problem' , 1, 0, NULL);
  255. INSERT INTO llx_c_ticketsup_type (code, pos, label, active, use_default, description) VALUES('REQUEST', '25', 'Change or enhancement request', 1, 0, NULL);
  256. INSERT INTO llx_c_ticketsup_type (code, pos, label, active, use_default, description) VALUES('PROJECT', '30', 'Project', 0, 0, NULL);
  257. INSERT INTO llx_c_ticketsup_type (code, pos, label, active, use_default, description) VALUES('OTHER', '40', 'Other', 1, 0, NULL);
  258. INSERT INTO llx_c_ticketsup_category (code, pos, label, active, use_default, description) VALUES('OTHER', '10', 'Other', 1, 1, NULL);
  259. ALTER TABLE llx_facturedet_rec ADD COLUMN date_start_fill integer DEFAULT 0;
  260. ALTER TABLE llx_facturedet_rec ADD COLUMN date_end_fill integer DEFAULT 0;
  261. CREATE TABLE llx_societe_account(
  262. -- BEGIN MODULEBUILDER FIELDS
  263. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  264. entity integer DEFAULT 1,
  265. key_account varchar(128),
  266. login varchar(128) NOT NULL,
  267. pass_encoding varchar(24),
  268. pass_crypted varchar(128),
  269. pass_temp varchar(128), -- temporary password when asked for forget password
  270. fk_soc integer,
  271. site varchar(128),
  272. fk_website integer,
  273. note_private text,
  274. date_last_login datetime,
  275. date_previous_login datetime,
  276. date_creation datetime NOT NULL,
  277. tms timestamp NOT NULL,
  278. fk_user_creat integer NOT NULL,
  279. fk_user_modif integer,
  280. import_key varchar(14),
  281. status integer
  282. -- END MODULEBUILDER FIELDS
  283. ) ENGINE=innodb;
  284. -- VMYSQL4.3 ALTER TABLE llx_societe_account MODIFY COLUMN pass_encoding varchar(24) NULL;
  285. ALTER TABLE llx_const MODIFY type varchar(64) DEFAULT 'string';
  286. UPDATE llx_const set type = 'text' where type = 'texte';
  287. UPDATE llx_const set type = 'html' where name in (__ENCRYPT('ADHERENT_AUTOREGISTER_NOTIF_MAIL')__,__ENCRYPT('ADHERENT_AUTOREGISTER_MAIL')__,__ENCRYPT('ADHERENT_MAIL_VALID')__,__ENCRYPT('ADHERENT_MAIL_COTIS')__,__ENCRYPT('ADHERENT_MAIL_RESIL')__);
  288. --UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_AUTOREGISTER_MAIL')__ AND type != 'emailtemplate:member';
  289. --UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_MAIL_VALID')__ AND type != 'emailtemplate:member';
  290. --UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_MAIL_COTIS')__ AND type != 'emailtemplate:member';
  291. --UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_MAIL_RESIL')__ AND type != 'emailtemplate:member';
  292. ALTER TABLE llx_societe_account ADD COLUMN key_account varchar(128);
  293. ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_rowid (rowid);
  294. ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_login (login);
  295. ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_status (status);
  296. ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_website (fk_website);
  297. ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_soc (fk_soc);
  298. ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website_soc(entity, fk_soc, login, site, fk_website);
  299. ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_key_account_soc(entity, fk_soc, key_account, site, fk_website);
  300. ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid);
  301. ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
  302. ALTER TABLE llx_societe_rib MODIFY COLUMN max_total_amount_of_all_payments double(24,8);
  303. ALTER TABLE llx_societe_rib MODIFY COLUMN total_amount_of_all_payments double(24,8);
  304. INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnAutoSubscription)' ,10,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipRequestWasReceived)__','__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(ThisIsContentOfYourMembershipRequestWasReceived)__<br>\n<br>__ONLINE_PAYMENT_TEXT_AND_URL__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
  305. INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnMemberValidation)' ,20,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasValidated)__', '__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(ThisIsContentOfYourMembershipWasValidated)__<br>\n<br>__ONLINE_PAYMENT_TEXT_AND_URL__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
  306. INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnNewSubscription)' ,30,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourSubscriptionWasRecorded)__', '__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(ThisIsContentOfYourSubscriptionWasRecorded)__<br>\n\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
  307. INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(ThisIsContentOfSubscriptionReminderEmail)__<br>\n<br>__ONLINE_PAYMENT_TEXT_AND_URL__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
  308. INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(YourMembershipWasCanceled)__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
  309. INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,<br><br>\n\n__(ThisIsContentOfYourCard)__<br>\n__(ID)__ : __ID__<br>\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br>\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br>\n__(Lastname)__ : __MEMBER_LASTNAME__<br>\n__(Fullname)__ : __MEMBER_FULLNAME__<br>\n__(Company)__ : __MEMBER_COMPANY__<br>\n__(Address)__ : __MEMBER_ADDRESS__<br>\n__(Zip)__ : __MEMBER_ZIP__<br>\n__(Town)__ : __MEMBER_TOWN__<br>\n__(Country)__ : __MEMBER_COUNTRY__<br>\n__(Email)__ : __MEMBER_EMAIL__<br>\n__(Birthday)__ : __MEMBER_BIRTH__<br>\n__(Photo)__ : __MEMBER_PHOTO__<br>\n__(Login)__ : __MEMBER_LOGIN__<br>\n__(Password)__ : __MEMBER_PASSWORD__<br>\n__(Phone)__ : __MEMBER_PHONE__<br>\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br>\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
  310. ALTER TABLE llx_product ADD COLUMN fk_default_warehouse integer DEFAULT NULL;
  311. ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid);
  312. -- Assets
  313. CREATE TABLE llx_asset(
  314. rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
  315. ref varchar(128) NOT NULL,
  316. entity integer DEFAULT 1 NOT NULL,
  317. label varchar(255),
  318. amount_ht double(24,8) DEFAULT NULL,
  319. amount_vat double(24,8) DEFAULT NULL,
  320. fk_asset_type integer NOT NULL,
  321. description text,
  322. note_public text,
  323. note_private text,
  324. date_creation datetime NOT NULL,
  325. tms timestamp NOT NULL,
  326. fk_user_creat integer NOT NULL,
  327. fk_user_modif integer,
  328. import_key varchar(14),
  329. status integer NOT NULL
  330. ) ENGINE=innodb;
  331. ALTER TABLE llx_asset ADD INDEX idx_asset_rowid (rowid);
  332. ALTER TABLE llx_asset ADD INDEX idx_asset_ref (ref);
  333. ALTER TABLE llx_asset ADD INDEX idx_asset_entity (entity);
  334. ALTER TABLE llx_asset ADD INDEX idx_asset_fk_asset_type (fk_asset_type);
  335. create table llx_asset_extrafields
  336. (
  337. rowid integer AUTO_INCREMENT PRIMARY KEY,
  338. tms timestamp,
  339. fk_object integer NOT NULL,
  340. import_key varchar(14)
  341. ) ENGINE=innodb;
  342. create table llx_asset_type
  343. (
  344. rowid integer AUTO_INCREMENT PRIMARY KEY,
  345. entity integer DEFAULT 1 NOT NULL, -- multi company id
  346. tms timestamp,
  347. label varchar(50) NOT NULL,
  348. accountancy_code_asset varchar(32),
  349. accountancy_code_depreciation_asset varchar(32),
  350. accountancy_code_depreciation_expense varchar(32),
  351. note text
  352. )ENGINE=innodb;
  353. ALTER TABLE llx_asset_type ADD UNIQUE INDEX uk_asset_type_label (label, entity);
  354. ALTER TABLE llx_asset ADD CONSTRAINT fk_asset_asset_type FOREIGN KEY (fk_asset_type) REFERENCES llx_asset_type (rowid);
  355. create table llx_asset_type_extrafields
  356. (
  357. rowid integer AUTO_INCREMENT PRIMARY KEY,
  358. tms timestamp,
  359. fk_object integer NOT NULL,
  360. import_key varchar(14) -- import key
  361. ) ENGINE=innodb;
  362. ALTER TABLE llx_asset_type_extrafields ADD INDEX idx_asset_type_extrafields (fk_object);
  363. INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1);
  364. UPDATE llx_accounting_account set account_parent = 0 WHERE account_parent = '' OR account_parent IS NULL;
  365. -- VMYSQL4.1 ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0;
  366. -- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_parent DROP DEFAULT;
  367. -- VPGSQL8.2 ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer USING account_parent::integer;
  368. -- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_parent SET DEFAULT 0;
  369. ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent);
  370. UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS NULL;
  371. ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128);
  372. UPDATE llx_rights_def set module = 'asset' where module = 'assets';
  373. ALTER TABLE llx_c_accounting_category ADD COLUMN entity integer NOT NULL DEFAULT 1 AFTER rowid;
  374. -- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category;
  375. -- VPGSQL8.2 DROP INDEX uk_c_accounting_category;
  376. ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity);
  377. -- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal;
  378. -- VPGSQL8.2 DROP INDEX uk_accounting_journal_code;
  379. ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity);
  380. UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL;
  381. -- Warehouse
  382. ALTER TABLE llx_entrepot ADD COLUMN model_pdf VARCHAR(255) AFTER fk_user_author;
  383. ALTER TABLE llx_stock_mouvement ADD COLUMN model_pdf VARCHAR(255) AFTER origintype;