From d0c9050e3d347cccc98fba96e4d3436194e09fb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Aug 2006 00:25:17 +0000 Subject: [PATCH] Ajout contrainte unique sur champs unique de users --- mysql/migration/2.0.0-2.1.0.sql | 6 ++++++ mysql/tables/llx_facture.key.sql | 4 ++-- mysql/tables/llx_user.key.sql | 27 +++++++++++++++++++++++++++ mysql/tables/llx_user.sql | 11 +++++------ mysql/tables/llx_user_rights.key.sql | 2 +- 5 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 mysql/tables/llx_user.key.sql diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 294ba7ce803..af7011da903 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -372,6 +372,12 @@ alter table llx_user add column datepreviouslogin datetime after datelastlogin; alter table llx_user add column ldap_sid varchar(255) DEFAULT NULL; alter table llx_user add column statut tinyint DEFAULT 1; alter table llx_user add column lang varchar(6); +alter table llx_user modify login varchar(24) NOT NULL; +alter table llx_user modify code varchar(4) NOT NULL; + +ALTER TABLE llx_user ADD UNIQUE uk_user_login (login); +ALTER TABLE llx_user ADD UNIQUE uk_user_code (code); + alter table llx_boxes add column fk_user integer; diff --git a/mysql/tables/llx_facture.key.sql b/mysql/tables/llx_facture.key.sql index b99e7996cf4..2337c01618a 100644 --- a/mysql/tables/llx_facture.key.sql +++ b/mysql/tables/llx_facture.key.sql @@ -25,13 +25,13 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_soc (fk_soc); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_author (fk_user_author); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_valid (fk_user_valid); -ALTER TABLE llx_facture ADD INDEX idx_facture_fk_facture (fk_facture); +ALTER TABLE llx_facture ADD INDEX idx_facture_fk_facture_source (fk_facture_source); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_projet (fk_projet); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); -ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facture (rowid); +ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_facture_source FOREIGN KEY (fk_facture_source) REFERENCES llx_facture (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber); diff --git a/mysql/tables/llx_user.key.sql b/mysql/tables/llx_user.key.sql new file mode 100644 index 00000000000..b38e9efeef0 --- /dev/null +++ b/mysql/tables/llx_user.key.sql @@ -0,0 +1,27 @@ +-- ============================================================================ +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2006 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 2 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, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- $Source$ +-- +-- =========================================================================== + + +ALTER TABLE llx_user ADD UNIQUE uk_user_login (login); +ALTER TABLE llx_user ADD UNIQUE uk_user_code (code); + diff --git a/mysql/tables/llx_user.sql b/mysql/tables/llx_user.sql index ed5bd9c553c..d5434d6fe1d 100644 --- a/mysql/tables/llx_user.sql +++ b/mysql/tables/llx_user.sql @@ -1,5 +1,6 @@ -- ============================================================================ -- Copyright (C) 2001-2003 Rodolphe Quiedeville +-- Copyright (C) 2006 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 @@ -25,11 +26,11 @@ create table llx_user rowid integer AUTO_INCREMENT PRIMARY KEY, datec datetime, tms timestamp, - login varchar(24), + login varchar(24) NOT NULL, pass varchar(32), name varchar(50), firstname varchar(50), - code varchar(4), + code varchar(4) NOT NULL, office_phone varchar(20), office_fax varchar(20), user_mobile varchar(20), @@ -40,13 +41,11 @@ create table llx_user module_compta smallint DEFAULT 1, fk_societe integer DEFAULT 0, fk_socpeople integer DEFAULT 0, - note text, + note text DEFAULT NULL, datelastlogin datetime, datepreviouslogin datetime, egroupware_id integer, ldap_sid varchar(255) DEFAULT NULL, statut tinyint DEFAULT 1, - lang varchar(6), - - UNIQUE INDEX(login) + lang varchar(6) )type=innodb; diff --git a/mysql/tables/llx_user_rights.key.sql b/mysql/tables/llx_user_rights.key.sql index 1b74d325630..23fb05f44c3 100644 --- a/mysql/tables/llx_user_rights.key.sql +++ b/mysql/tables/llx_user_rights.key.sql @@ -23,7 +23,7 @@ -- Supprimme orhpelins pour permettre montée de la clé ---DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL; +-- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL; ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);