Fix: Les lignes key(champ) de mysql sont traduites par un create index pgsql.

This commit is contained in:
Laurent Destailleur 2005-03-02 20:14:28 +00:00
parent f22c4a47d8
commit ce49e8c654
9 changed files with 65 additions and 25 deletions

View File

@ -221,28 +221,25 @@ foreach my $file (keys %filelist) {
# double -> float8
s/double\([^)]*\)/float8/i;
# add unique to definition of type (MySQL separates this)
# if (/unique \w+ \((\w+)\)/i) {
# $create_sql.=~s/($1)([^,]+)/$1$2 unique/i;
# next;
# }
# FIX: unique for multipe columns (col1,col2) are unsupported!
# next if (/unique/i);
# Ignore "unique key(xx, yy)"
next if (/unique key\(\w+\s*,\s*\w+\)/i);
if (/\bkey\b/i && !/^\s+primary key\s+/i) {
s/KEY(\s+)[^(]*(\s+)/$1 UNIQUE $2/i; # hack off name of the non-primary key
}
# if key(xxx),
if (/key\((\w+)\)/) {
$create_index .= "CREATE INDEX ${table}_$1 ON $table ($1);\n";
# if key(xxx)
if (/key\((\w+)\)/i) {
#$create_index .= "CREATE INDEX ${table}_$1 ON $table ($1);\n";
$create_index .= "CREATE INDEX idx_$1 ON $table ($1);\n";
next;
}
# quote column names
# Quote column names
s/(^\s*)([^\s\-\(]+)(\s*)/$1"$2"$3/gi if (!/\bkey\b/i);
# remap colums with names of existing system attribute
# Remap colums with names of existing system attribute
if (/"oid"/i) {
s/"oid"/"_oid"/g;
print STDERR "WARNING: table $table uses column \"oid\" which is renamed to \"_oid\"\nYou should fix application manually! Press return to continue.";

View File

@ -28,7 +28,6 @@
create table llx_album_to_groupart
(
"fk_album" integer NOT NULL,
"fk_groupart" integer NOT NULL,
unique key(fk_album, fk_groupart)
"fk_groupart" integer NOT NULL
);

View File

@ -31,5 +31,5 @@ create table llx_co_fa
"fk_facture" integer NOT NULL
);
CREATE INDEX llx_co_fa_fk_commande ON llx_co_fa (fk_commande);
CREATE INDEX llx_co_fa_fk_facture ON llx_co_fa (fk_facture);
CREATE INDEX idx_fk_commande ON llx_co_fa (fk_commande);
CREATE INDEX idx_fk_facture ON llx_co_fa (fk_facture);

View File

@ -44,5 +44,5 @@ create table llx_expedition
"UNIQUE" INDEX (ref)
);
CREATE INDEX llx_expedition_fk_expedition_methode ON llx_expedition (fk_expedition_methode);
CREATE INDEX llx_expedition_fk_commande ON llx_expedition (fk_commande);
CREATE INDEX idx_fk_expedition_methode ON llx_expedition (fk_expedition_methode);
CREATE INDEX idx_fk_commande ON llx_expedition (fk_commande);

View File

@ -32,5 +32,5 @@ create table llx_expeditiondet
"qty" real, -- quantité
);
CREATE INDEX llx_expeditiondet_fk_expedition ON llx_expeditiondet (fk_expedition);
CREATE INDEX llx_expeditiondet_fk_commande_ligne ON llx_expeditiondet (fk_commande_ligne);
CREATE INDEX idx_fk_expedition ON llx_expeditiondet (fk_expedition);
CREATE INDEX idx_fk_commande_ligne ON llx_expeditiondet (fk_commande_ligne);

View File

@ -0,0 +1,44 @@
-- Generated from dolibarr_mysql2pgsql
-- (c) 2004, PostgreSQL Inc.
-- (c) 2005, Laurent Destailleur.
-- ===================================================================
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
--
-- 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$
-- ===================================================================
--
--
create table llx_prelevement_lignes
(
rowid SERIAL PRIMARY KEY,
"fk_prelevement_bons" integer,
"fk_soc" integer NOT NULL,
"statut" smallint DEFAULT 0,
"client_nom" varchar(255),
"amount" real DEFAULT 0,
"code_banque" varchar(7),
"code_guichet" varchar(6),
"number" varchar(255),
"cle_rib" varchar(5),
"note" text
);

View File

@ -36,6 +36,6 @@ create table llx_product_fournisseur
"fk_user_author" integer
);
CREATE INDEX llx_product_fournisseur_fk_product ON llx_product_fournisseur (fk_product);
CREATE INDEX llx_product_fournisseur_fk_soc ON llx_product_fournisseur (fk_soc);
CREATE INDEX idx_fk_product ON llx_product_fournisseur (fk_product);
CREATE INDEX idx_fk_soc ON llx_product_fournisseur (fk_soc);

View File

@ -34,6 +34,6 @@ create table llx_product_stock
"reel" integer, -- stock réel
);
CREATE INDEX llx_product_stock_fk_product ON llx_product_stock (fk_product);
CREATE INDEX llx_product_stock_fk_entrepot ON llx_product_stock (fk_entrepot);
CREATE INDEX idx_fk_product ON llx_product_stock (fk_product);
CREATE INDEX idx_fk_entrepot ON llx_product_stock (fk_entrepot);

View File

@ -37,6 +37,6 @@ create table llx_stock_mouvement
"fk_user_author" integer
);
CREATE INDEX llx_stock_mouvement_fk_product ON llx_stock_mouvement (fk_product);
CREATE INDEX llx_stock_mouvement_fk_entrepot ON llx_stock_mouvement (fk_entrepot);
CREATE INDEX idx_fk_product ON llx_stock_mouvement (fk_product);
CREATE INDEX idx_fk_entrepot ON llx_stock_mouvement (fk_entrepot);