diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 3a51a366970..b275f38debe 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -215,6 +215,11 @@ class modAsset extends DolibarrModules */ public function init($options = '') { + $result = $this->_load_tables('/install/mysql/tables/', 'asset'); + if ($result < 0) { + return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + } + // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index dfd292aa847..1a31aad9c8b 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -159,6 +159,11 @@ class modMailing extends DolibarrModules */ public function init($options = '') { + $result = $this->_load_tables('/install/mysql/tables/', 'mailing'); + if ($result < 0) { + return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + } + // Permissions $this->remove($options); diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index c996b2c06e0..b78e53bd287 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -231,3 +231,10 @@ ALTER TABLE llx_product_attribute_value MODIFY COLUMN ref VARCHAR(180) NOT NULL; ALTER TABLE llx_product_attribute_value MODIFY COLUMN value VARCHAR(255) NOT NULL; ALTER TABLE llx_product_attribute_value ADD COLUMN position INTEGER NOT NULL DEFAULT 0; ALTER TABLE llx_product_attribute CHANGE rang position INTEGER DEFAULT 0 NOT NULL; + + +ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; + +ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); + + diff --git a/htdocs/install/mysql/tables/llx_asset.key.sql b/htdocs/install/mysql/tables/llx_asset-asset.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset.key.sql rename to htdocs/install/mysql/tables/llx_asset-asset.key.sql diff --git a/htdocs/install/mysql/tables/llx_asset.sql b/htdocs/install/mysql/tables/llx_asset-asset.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset.sql rename to htdocs/install/mysql/tables/llx_asset-asset.sql diff --git a/htdocs/install/mysql/tables/llx_asset_extrafields.key.sql b/htdocs/install/mysql/tables/llx_asset_extrafields-asset.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_asset_extrafields-asset.key.sql diff --git a/htdocs/install/mysql/tables/llx_asset_extrafields.sql b/htdocs/install/mysql/tables/llx_asset_extrafields-asset.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset_extrafields.sql rename to htdocs/install/mysql/tables/llx_asset_extrafields-asset.sql diff --git a/htdocs/install/mysql/tables/llx_asset_type.key.sql b/htdocs/install/mysql/tables/llx_asset_type-asset.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset_type.key.sql rename to htdocs/install/mysql/tables/llx_asset_type-asset.key.sql diff --git a/htdocs/install/mysql/tables/llx_asset_type.sql b/htdocs/install/mysql/tables/llx_asset_type-asset.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset_type.sql rename to htdocs/install/mysql/tables/llx_asset_type-asset.sql diff --git a/htdocs/install/mysql/tables/llx_asset_type_extrafields.key.sql b/htdocs/install/mysql/tables/llx_asset_type_extrafields-asset.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset_type_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_asset_type_extrafields-asset.key.sql diff --git a/htdocs/install/mysql/tables/llx_asset_type_extrafields.sql b/htdocs/install/mysql/tables/llx_asset_type_extrafields-asset.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_asset_type_extrafields.sql rename to htdocs/install/mysql/tables/llx_asset_type_extrafields-asset.sql diff --git a/htdocs/install/mysql/tables/llx_mailing-mailing.key.sql b/htdocs/install/mysql/tables/llx_mailing-mailing.key.sql new file mode 100644 index 00000000000..0791c1f2c27 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_mailing-mailing.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2018 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); diff --git a/htdocs/install/mysql/tables/llx_mailing.sql b/htdocs/install/mysql/tables/llx_mailing-mailing.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_mailing.sql rename to htdocs/install/mysql/tables/llx_mailing-mailing.sql diff --git a/htdocs/install/mysql/tables/llx_advtargetemailing.key.sql b/htdocs/install/mysql/tables/llx_mailing_advtarget-mailing.key.sql similarity index 92% rename from htdocs/install/mysql/tables/llx_advtargetemailing.key.sql rename to htdocs/install/mysql/tables/llx_mailing_advtarget-mailing.key.sql index 441dec301c2..12f9d4c6097 100644 --- a/htdocs/install/mysql/tables/llx_advtargetemailing.key.sql +++ b/htdocs/install/mysql/tables/llx_mailing_advtarget-mailing.key.sql @@ -14,4 +14,4 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -ALTER TABLE llx_advtargetemailing ADD UNIQUE INDEX uk_advtargetemailing_name (name); +ALTER TABLE llx_mailing_advtarget ADD UNIQUE INDEX uk_advtargetemailing_name (name); diff --git a/htdocs/install/mysql/tables/llx_advtargetemailing.sql b/htdocs/install/mysql/tables/llx_mailing_advtarget-mailing.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_advtargetemailing.sql rename to htdocs/install/mysql/tables/llx_mailing_advtarget-mailing.sql index 34bd7eb53bf..a22ce23a955 100644 --- a/htdocs/install/mysql/tables/llx_advtargetemailing.sql +++ b/htdocs/install/mysql/tables/llx_mailing_advtarget-mailing.sql @@ -17,7 +17,7 @@ -- Table to setup advanced targeting for emailing -- ============================================================================ -CREATE TABLE llx_advtargetemailing +CREATE TABLE llx_mailing_advtarget ( rowid integer NOT NULL auto_increment PRIMARY KEY, name varchar(180) NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql b/htdocs/install/mysql/tables/llx_mailing_cibles-mailing.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_mailing_cibles.key.sql rename to htdocs/install/mysql/tables/llx_mailing_cibles-mailing.key.sql diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.sql b/htdocs/install/mysql/tables/llx_mailing_cibles-mailing.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_mailing_cibles.sql rename to htdocs/install/mysql/tables/llx_mailing_cibles-mailing.sql