From 5e80045105ca7b5cd162c3e893df63f67e6c2ab7 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Tue, 12 Oct 2010 14:37:32 +0000
Subject: [PATCH] Add llx_c_ziptown for zip code and town

---
 .../install/mysql/migration/2.9.0-3.0.0.sql   | 18 ++++++++++-
 .../mysql/tables/llx_c_ziptown.key.sql        | 26 ++++++++++++++++
 htdocs/install/mysql/tables/llx_c_ziptown.sql | 30 +++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 htdocs/install/mysql/tables/llx_c_ziptown.key.sql
 create mode 100644 htdocs/install/mysql/tables/llx_c_ziptown.sql

diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql
index e46147b1879..5f5708cc9ff 100644
--- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql
+++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql
@@ -79,4 +79,20 @@ ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX idx_ecm_directories (label, fk_
 ALTER TABLE llx_ecm_documents ADD UNIQUE INDEX idx_ecm_documents (fullpath_dol);
 
 --Add modules facture fournisseur
-insert into llx_const (name, value, type, note, visible) values ('INVOICE_SUPPLIER_ADDON_PDF', 'canelle','chaine','',0);
\ No newline at end of file
+insert into llx_const (name, value, type, note, visible) values ('INVOICE_SUPPLIER_ADDON_PDF', 'canelle','chaine','',0);
+
+create table llx_c_ziptown
+(
+  rowid				integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
+  code				varchar(5) DEFAULT NULL,
+  fk_country		integer NOT NULL,
+  fk_county			integer NOT NULL,
+  zip	 			varchar(10) NOT NULL,
+  town				varchar(255) NOT NULL,
+  active 			tinyint NOT NULL DEFAULT 1
+)type=innodb;
+
+ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_country (fk_country);
+ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_county (fk_county);
+ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_country	FOREIGN KEY (fk_country)  REFERENCES llx_c_pays (rowid);
+ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county		FOREIGN KEY (fk_county)   REFERENCES llx_c_departements (rowid);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_c_ziptown.key.sql b/htdocs/install/mysql/tables/llx_c_ziptown.key.sql
new file mode 100644
index 00000000000..df424327478
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_ziptown.key.sql
@@ -0,0 +1,26 @@
+-- ========================================================================
+-- Copyright (C) 2010 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
+-- 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$
+-- ========================================================================
+
+
+ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_country (fk_country);
+ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_county (fk_county);
+
+ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_country	FOREIGN KEY (fk_country)  REFERENCES llx_c_pays (rowid);
+ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county		FOREIGN KEY (fk_county)   REFERENCES llx_c_departements (rowid);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_c_ziptown.sql b/htdocs/install/mysql/tables/llx_c_ziptown.sql
new file mode 100644
index 00000000000..afe82644fb3
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_ziptown.sql
@@ -0,0 +1,30 @@
+-- ========================================================================
+-- Copyright (C) 2010 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
+-- 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$
+-- ========================================================================
+
+create table llx_c_ziptown
+(
+  rowid				integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
+  code				varchar(5) DEFAULT NULL, 		-- ex: code insee pour la France 
+  fk_country		integer NOT NULL,				-- Country id in llx_c_pays
+  fk_county			integer NOT NULL,				-- County id in llx_c_departements
+  zip	 			varchar(10) NOT NULL,			-- Zip code
+  town				varchar(255) NOT NULL,			-- Town name
+  active 			tinyint NOT NULL DEFAULT 1
+)type=innodb;
-- 
GitLab