diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql
index aa3dc917f6e6712dbb2c245488c1c2a391b03545..89759309ba7697599c2407b49c6fe4403a429f22 100644
--- a/mysql/migration/2.5.0-2.6.0.sql
+++ b/mysql/migration/2.5.0-2.6.0.sql
@@ -3,7 +3,7 @@
 --
 -- Be carefull to requests order.
 -- This file must be loaded by calling /install/index.php page
--- when current version is 2.4.0 or higher. 
+-- when current version is 2.5.0 or higher. 
 --
 
 insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (140,'order_supplier','internal', 'SALESREPFOLL',  'Responsable suivi de la commande', 1);
diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql
index 19f246d8ee92fdadc1d97454a72f4d177cc81e1e..7a15cdf391a7890daa2bb69e9bfc4243a81caba0 100644
--- a/mysql/migration/2.6.0-2.7.0.sql
+++ b/mysql/migration/2.6.0-2.7.0.sql
@@ -3,7 +3,7 @@
 --
 -- Be carefull to requests order.
 -- This file must be loaded by calling /install/index.php page
--- when current version is 2.5.0 or higher. 
+-- when current version is 2.6.0 or higher. 
 --
 
 -- Multi company
@@ -24,6 +24,7 @@ ALTER TABLE llx_ecm_directories ADD COLUMN entity integer DEFAULT 1 NOT NULL AFT
 ALTER TABLE llx_mailing ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER titre;
 ALTER TABLE llx_categorie ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER label;
 ALTER TABLE llx_propal ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
+ALTER TABLE llx_commande ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
 
 ALTER TABLE llx_rights_def DROP PRIMARY KEY;
 ALTER TABLE llx_user_param DROP INDEX fk_user;
@@ -36,6 +37,7 @@ ALTER TABLE llx_document_model DROP INDEX uk_document_model;
 ALTER TABLE llx_menu DROP INDEX idx_menu_uk_menu;
 ALTER TABLE llx_categorie DROP INDEX uk_categorie_ref;
 ALTER TABLE llx_propal DROP INDEX ref;
+ALTER TABLE llx_commande DROP INDEX ref;
 
 ALTER TABLE llx_rights_def ADD PRIMARY KEY (id, entity);
 ALTER TABLE llx_user_param ADD UNIQUE INDEX uk_user_param (fk_user,param,entity);
@@ -47,4 +49,5 @@ ALTER TABLE llx_bank_account ADD UNIQUE INDEX uk_bank_account_label (label, enti
 ALTER TABLE llx_document_model ADD UNIQUE INDEX uk_document_model (nom, type, entity);
 ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, url, entity);
 ALTER TABLE llx_categorie ADD UNIQUE INDEX uk_categorie_ref (label, type, entity);
-ALTER TABLE llx_propal ADD UNIQUE INDEX uk_propal_ref (ref, entity);
\ No newline at end of file
+ALTER TABLE llx_propal ADD UNIQUE INDEX uk_propal_ref (ref, entity);
+ALTER TABLE llx_commande ADD UNIQUE INDEX uk_commande_ref (ref, entity);
\ No newline at end of file
diff --git a/mysql/tables/llx_commande.key.sql b/mysql/tables/llx_commande.key.sql
index 9a2421a0c433e71c3343a976a009da0055dbdb34..84513ecd046472ed109b058124f1f22b0771c88b 100644
--- a/mysql/tables/llx_commande.key.sql
+++ b/mysql/tables/llx_commande.key.sql
@@ -1,5 +1,6 @@
 -- ============================================================================
 -- Copyright (C) 2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+-- Copyright (C) 2009 Regis Houssin        <regis@dolibarr.fr>
 --
 -- 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
@@ -22,5 +23,7 @@
 -- 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.rowid WHERE llx_societe.rowid IS NULL; 
 
+ALTER TABLE llx_commande ADD UNIQUE INDEX uk_commande_ref (ref, entity);
+
 ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc);
 ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
diff --git a/mysql/tables/llx_commande.sql b/mysql/tables/llx_commande.sql
index 2071abc4340ae405481360d8400c58dabbc691d5..f29e8ea16bcb90c883d0af39cccf954a8a44ce86 100644
--- a/mysql/tables/llx_commande.sql
+++ b/mysql/tables/llx_commande.sql
@@ -1,5 +1,6 @@
 -- ===================================================================
--- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+-- Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+-- Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
 --
 -- 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,6 +26,7 @@ create table llx_commande
   fk_soc                integer NOT NULL,
   fk_projet             integer DEFAULT 0,             -- projet auquel est rattache la commande
   ref                   varchar(30) NOT NULL,          -- order number
+  entity                integer DEFAULT 1 NOT NULL,	   -- multi company id
   ref_client            varchar(30),                   -- customer order number
 
   date_creation         datetime,                      -- date de creation 
@@ -54,3 +56,11 @@ create table llx_commande
   fk_adresse_livraison  integer,                       -- adresse de livraison
   import_key            varchar(14)
 )type=innodb;
+
+-- 
+-- List of codes for the field entity
+--
+-- 1 : first company order
+-- 2 : second company order
+-- 3 : etc...
+--
\ No newline at end of file
diff --git a/mysql/tables/llx_propal.key.sql b/mysql/tables/llx_propal.key.sql
index fbcff7a504d1d875341d5cce578906783b36d842..c92472f7af5971ba1dc46536eb1f15401d021ada 100644
--- a/mysql/tables/llx_propal.key.sql
+++ b/mysql/tables/llx_propal.key.sql
@@ -24,5 +24,4 @@
 ALTER TABLE llx_propal ADD UNIQUE INDEX uk_propal_ref (ref, entity);
 
 ALTER TABLE llx_propal ADD INDEX idx_propal_fk_soc (fk_soc);
-
 ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
\ No newline at end of file