diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 97f3eea9802..f135749c1cd 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -84,9 +84,17 @@ ALTER TABLE `llx_commande` ADD `date_livraison` DATE; ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk_facture_fourn); ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid); + +ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc); +ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); + +ALTER TABLE llx_commande_fournisseur ADD INDEX idx_commande_fournisseur_fk_soc (fk_soc); +ALTER TABLE llx_commande_fournisseur ADD CONSTRAINT fk_commande_fournisseur_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); + + create table llx_avoir_model_pdf ( nom varchar(50) PRIMARY KEY, libelle varchar(255), description text -)type=innodb; \ No newline at end of file +)type=innodb; diff --git a/mysql/tables/llx_commande.key.sql b/mysql/tables/llx_commande.key.sql new file mode 100644 index 00000000000..088ca768907 --- /dev/null +++ b/mysql/tables/llx_commande.key.sql @@ -0,0 +1,28 @@ +-- ============================================================================ +-- 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$ +-- +-- ============================================================================ + + +-- Supprimme orphelins pour permettre montée de la clé +-- V4 DELETE llx_commande FROM llx_commande LEFT JOIN llx_societe ON llx_commande.fk_soc = llx_societe.idp WHERE llx_societe.idp IS NULL; + +ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc); +ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); diff --git a/mysql/tables/llx_commande.sql b/mysql/tables/llx_commande.sql index 8f1f9b2d885..2970b11f9da 100644 --- a/mysql/tables/llx_commande.sql +++ b/mysql/tables/llx_commande.sql @@ -24,7 +24,7 @@ create table llx_commande ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, - fk_soc integer, + fk_soc integer NOT NULL, fk_soc_contact integer, fk_projet integer DEFAULT 0, -- projet auquel est rattache la commande ref varchar(30) NOT NULL, -- order number @@ -35,7 +35,7 @@ create table llx_commande date_commande date, -- date de la commande fk_user_author integer, -- createur de la commande fk_user_valid integer, -- valideur de la commande - fk_user_cloture integer, -- cloture de la propale signee ou non signee + fk_user_cloture integer, -- auteur cloture source smallint NOT NULL, fk_statut smallint default 0, amount_ht real default 0, @@ -47,9 +47,11 @@ create table llx_commande note text, note_public text, model_pdf varchar(50), + facture tinyint default 0, fk_cond_reglement integer, -- condition de réglement fk_mode_reglement integer, -- mode de réglement - date_livraison date default NULL, + date_livraison date default NULL, + UNIQUE INDEX (ref) )type=innodb; diff --git a/mysql/tables/llx_commande_fournisseur.key.sql b/mysql/tables/llx_commande_fournisseur.key.sql new file mode 100644 index 00000000000..ca614c9bfb0 --- /dev/null +++ b/mysql/tables/llx_commande_fournisseur.key.sql @@ -0,0 +1,28 @@ +-- ============================================================================ +-- 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$ +-- +-- ============================================================================ + + +-- Supprimme orphelins pour permettre montée de la clé +-- V4 DELETE llx_commande_fournisseur FROM llx_commande_fournisseur LEFT JOIN llx_societe ON llx_commande_fournisseur.fk_soc = llx_societe.idp WHERE llx_societe.idp IS NULL; + +ALTER TABLE llx_commande_fournisseur ADD INDEX idx_commande_fournisseur_fk_soc (fk_soc); +ALTER TABLE llx_commande_fournisseur ADD CONSTRAINT fk_commande_fournisseur_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); diff --git a/mysql/tables/llx_commande_fournisseur.sql b/mysql/tables/llx_commande_fournisseur.sql index f55c7f9a8b7..5d920753b33 100644 --- a/mysql/tables/llx_commande_fournisseur.sql +++ b/mysql/tables/llx_commande_fournisseur.sql @@ -24,18 +24,18 @@ create table llx_commande_fournisseur ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, - fk_soc integer, + fk_soc integer NOT NULL, fk_soc_contact integer, fk_projet integer DEFAULT 0, -- projet auquel est rattache la commande - ref varchar(30) NOT NULL, -- propal number + ref varchar(30) NOT NULL, -- order number + date_creation datetime, -- date de creation date_valid datetime, -- date de validation date_cloture datetime, -- date de cloture date_commande date, -- date de la commande - fk_methode_commande integer default 0, fk_user_author integer, -- createur de la commande fk_user_valid integer, -- valideur de la commande - fk_user_cloture integer, -- cloture de la propale signee ou non signee + fk_user_cloture integer, -- auteur cloture source smallint NOT NULL, fk_statut smallint default 0, amount_ht real default 0, @@ -45,7 +45,10 @@ create table llx_commande_fournisseur total_ht real default 0, total_ttc real default 0, note text, + note_public text, model_pdf varchar(50), + fk_methode_commande integer default 0, + UNIQUE INDEX (ref) )type=innodb;