diff --git a/dev/initdemo/initdemo.sql b/dev/initdemo/initdemo.sql index befa67aa826..98dc6cf1241 100644 --- a/dev/initdemo/initdemo.sql +++ b/dev/initdemo/initdemo.sql @@ -268,11 +268,10 @@ DROP TABLE IF EXISTS `llx_adherent_options`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `llx_adherent_options` ( - `optid` int(11) NOT NULL auto_increment, + `rowid` int(11) NOT NULL auto_increment, `tms` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `adhid` int(11) NOT NULL default '0', - PRIMARY KEY (`optid`), - UNIQUE KEY `adhid` (`adhid`) + `fk_member` int(11) NOT NULL default '0', + PRIMARY KEY (`rowid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; diff --git a/doc/dev/dbmodel/dolibarr_schema.xml b/doc/dev/dbmodel/dolibarr_schema.xml index 71c7f858563..ff69cedb90d 100644 --- a/doc/dev/dbmodel/dolibarr_schema.xml +++ b/doc/dev/dbmodel/dolibarr_schema.xml @@ -655,7 +655,7 @@ - + @@ -665,7 +665,7 @@ - + @@ -678,7 +678,7 @@ - + diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index ff831ea17e8..420cb9a7a33 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -422,11 +422,11 @@ class Adherent extends CommonObject if (sizeof($this->array_options) > 0) { - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = ".$this->id; + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE fk_member = ".$this->id; dol_syslog("Adherent::update sql=".$sql_del); $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_options (adhid"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_options (fk_member"; foreach($this->array_options as $key => $value) { // Add field of attribut @@ -637,7 +637,7 @@ class Adherent extends CommonObject $this->db->begin(); // Suppression options - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE fk_member = ".$rowid; dol_syslog("Adherent::delete sql=".$sql); $resql=$this->db->query($sql); @@ -1083,7 +1083,7 @@ class Adherent extends CommonObject $tab=array(); - $sql = "SELECT optid"; + $sql = "SELECT rowid"; foreach ($optionsArray as $name => $label) { @@ -1091,7 +1091,7 @@ class Adherent extends CommonObject } $sql.= " FROM ".MAIN_DB_PREFIX."adherent_options"; - $sql.= " WHERE adhid=".$rowid; + $sql.= " WHERE fk_member=".$rowid; dol_syslog("Adherent::fetch_optionals sql=".$sql, LOG_DEBUG); $result=$this->db->query( $sql); @@ -1103,7 +1103,7 @@ class Adherent extends CommonObject foreach ($tab as $key => $value) { - if ($key != 'optid' && $key != 'tms' && $key != 'adhid') + if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member') { // we can add this attribute to adherent object $this->array_options["options_$key"]=$value; diff --git a/htdocs/includes/modules/modAdherent.class.php b/htdocs/includes/modules/modAdherent.class.php index e61cce7f49f..b09b9453ea4 100644 --- a/htdocs/includes/modules/modAdherent.class.php +++ b/htdocs/includes/modules/modAdherent.class.php @@ -201,7 +201,7 @@ class modAdherent extends DolibarrModules // Fin complement $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent as a, '.MAIN_DB_PREFIX.'adherent_type as ta)'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_options as ao ON a.rowid = ao.adhid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_options as ao ON a.rowid = ao.fk_member'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'cotisation as c ON c.fk_adherent = a.rowid'; $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid'; } diff --git a/htdocs/install/mysql/migration/2.6.0-2.7.0.sql b/htdocs/install/mysql/migration/2.6.0-2.7.0.sql index 1ecd3585de2..1bd08918c50 100644 --- a/htdocs/install/mysql/migration/2.6.0-2.7.0.sql +++ b/htdocs/install/mysql/migration/2.6.0-2.7.0.sql @@ -479,8 +479,13 @@ ALTER TABLE llx_c_methode_commande_fournisseur ADD UNIQUE INDEX uk_c_methode_com ALTER TABLE llx_menu change user usertype integer NOT NULL default '0'; -- Rename index +ALTER TABLE llx_adherent_options MODIFY COLUMN optid integer; +ALTER TABLE llx_adherent_options DROP PRIMARY KEY; ALTER TABLE llx_adherent_options DROP INDEX uk_adherent_options; +ALTER TABLE llx_adherent_options DROP INDEX idx_adherent_options; ALTER TABLE llx_adherent_options DROP INDEX adhid; -ALTER TABLE llx_adherent_options ADD INDEX idx_adherent_options (adhid); +ALTER TABLE llx_adherent_options CHANGE optid rowid integer AUTO_INCREMENT PRIMARY KEY; +ALTER TABLE llx_adherent_options CHANGE adhid fk_member integer NOT NULL; +ALTER TABLE llx_adherent_options ADD INDEX idx_adherent_options (fk_member); ALTER TABLE llx_adherent DROP INDEX idx_adherent_fk_soc; diff --git a/htdocs/install/mysql/tables/llx_adherent_options.key.sql b/htdocs/install/mysql/tables/llx_adherent_options.key.sql index d299481a230..cc726558339 100644 --- a/htdocs/install/mysql/tables/llx_adherent_options.key.sql +++ b/htdocs/install/mysql/tables/llx_adherent_options.key.sql @@ -21,4 +21,4 @@ -- =================================================================== -ALTER TABLE llx_adherent_options ADD INDEX idx_adherent_options (adhid); +ALTER TABLE llx_adherent_options ADD INDEX idx_adherent_options (fk_member); diff --git a/htdocs/install/mysql/tables/llx_adherent_options.sql b/htdocs/install/mysql/tables/llx_adherent_options.sql index 9752cf5703f..a24047d3f6c 100644 --- a/htdocs/install/mysql/tables/llx_adherent_options.sql +++ b/htdocs/install/mysql/tables/llx_adherent_options.sql @@ -22,7 +22,7 @@ create table llx_adherent_options ( - optid integer AUTO_INCREMENT PRIMARY KEY, + rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, - adhid integer NOT NULL -- id de l'adherent auquel correspond ces attributs optionnel + fk_member integer NOT NULL -- member id )type=innodb;