Fix: Gestion des unsigned mysql et gestion des UNIQUE en fin de create.

This commit is contained in:
Laurent Destailleur 2005-03-03 22:15:03 +00:00
parent 7095f324ee
commit 45f05bac82
15 changed files with 27 additions and 29 deletions

View File

@ -114,7 +114,9 @@ foreach my $file (keys %filelist) {
# Output for create table and create index
sub output_create {
# If command ends with "xxx,);", we change to "xxx);"
$create_sql =~ s/,(\s*)\)/$1\)/m;
$create_sql =~ s/,(\s*)\);/$1\);/m;
# If command ends with "xxx, -- yyy );", we change to "xxx -- yyy);"
$create_sql =~ s/,(\s*\-\-[^\)\n]*)(\s*)\);/$1\n\);/m;
print OUT $create_sql;
if ($create_index) {
@ -179,7 +181,6 @@ foreach my $file (keys %filelist) {
} elsif (/^[\s\t]*(\w*)\s*.*int.*auto_increment/i) {
$seq = qq~${table}_${1}_seq~;
s/[\s\t]*([a-zA-Z_0-9]*)\s*.*int.*auto_increment[^,]*/ $1 SERIAL PRIMARY KEY/ig;
# MYSQL: data_id mediumint(8) unsigned NOT NULL auto_increment,
$create_sql.=$_;
next;
# int type conversion
@ -200,8 +201,8 @@ foreach my $file (keys %filelist) {
s/tinyint/smallint/g;
}
# nuke int unsigned
s/(int\w+)\s+unsigned/$1/gi;
# nuke unsigned
s/(int\w+|smallint)\s+unsigned/$1/gi;
# blob -> text
@ -234,7 +235,8 @@ foreach my $file (keys %filelist) {
s/(\s*)double/${1}real/i;
# Ignore "unique key(xx, yy)" (key on double fields not supported by postgres)
next if (/unique key\(\w+\s*,\s*\w+\)/i);
next if (/unique key\s*\(\w+\s*,\s*\w+\)/i);
next if (/unique index\s*\(\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

View File

@ -25,14 +25,12 @@
--
-- ===================================================================
-- telfixe varchar(15),
-- teljob varchar(15)
create table llx_adherent_options
(
optid SERIAL PRIMARY KEY,
"tms" timestamp,
"adhid" integer NOT NULL, -- id de l'adherent auquel correspond ces attributs optionnel
"adhid" integer NOT NULL -- id de l'adherent auquel correspond ces attributs optionnel
);
CREATE INDEX idx_adhid ON llx_adherent_options (adhid);

View File

@ -30,7 +30,7 @@ create table llx_appro
"datec" timestamp,
"tms" timestamp,
"fk_product" integer NOT NULL,
"quantity" smallint unsigned NOT NULL,
"quantity" smallint NOT NULL,
"price" real,
"fk_user_author" integer
);

View File

@ -25,11 +25,14 @@
--
-- ========================================================================
create table llx_c_ape
(
rowid SERIAL PRIMARY KEY,
code_ape varchar(5) PRIMARY KEY,
"code_ape" varchar(5) NOT NULL,
"libelle" varchar(255),
"active" smallint DEFAULT 1 NOT NULL
"active" smallint DEFAULT 1 NOT NULL
);
CREATE INDEX idx_code_ape ON llx_c_ape (code_ape);

View File

@ -28,12 +28,8 @@
--
--
ALTER TABLE llx_contrat ADD INDEX (fk_soc);
ALTER TABLE llx_contrat ADD INDEX (fk_commercial_signature);
ALTER TABLE llx_contrat ADD INDEX (fk_commercial_suivi);
ALTER TABLE llx_contrat ADD INDEX (fk_user_author);
--
--
ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_commercial_signature) REFERENCES llx_user (rowid);
ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_commercial_suivi) REFERENCES llx_user (rowid);
ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);

View File

@ -29,7 +29,7 @@ create table llx_expeditiondet
rowid SERIAL PRIMARY KEY,
"fk_expedition" integer NOT NULL,
"fk_commande_ligne" integer NOT NULL,
"qty" real, -- quantité
"qty" real -- quantité
);
CREATE INDEX idx_fk_expedition ON llx_expeditiondet (fk_expedition);

View File

@ -47,6 +47,5 @@ create table llx_facture_fourn
"fk_statut" smallint DEFAULT 0 NOT NULL,
"fk_user_author" integer, -- createur de la facture
"fk_user_valid" integer, -- valideur de la facture
"note" text,
"UNIQUE" INDEX (facnumber, fk_soc)
"note" text
);

View File

@ -39,7 +39,8 @@ create table llx_livre
"prix" decimal(15,4),
"fk_editeur" integer,
"fk_user_author" integer,
"frais_de_port" smallint DEFAULT 1,
"UNIQUE"(ref)
"frais_de_port" smallint DEFAULT 1
);
CREATE INDEX idx_ref ON llx_livre (ref);

View File

@ -28,6 +28,5 @@
create table llx_livre_to_auteur
(
"fk_livre" integer NOT NULL,
"fk_auteur" integer NOT NULL,
"unique" index (fk_livre, fk_auteur)
"fk_auteur" integer NOT NULL
);

View File

@ -24,6 +24,8 @@
-- ===================================================================
--
--
-- N'est plus utilisé !!
--
create table llx_prelevement
(

View File

@ -31,7 +31,7 @@ create table llx_product_stock
"tms" timestamp,
"fk_product" integer NOT NULL,
"fk_entrepot" integer NOT NULL,
"reel" integer, -- stock réel
"reel" integer -- stock réel
);
CREATE INDEX idx_fk_product ON llx_product_stock (fk_product);

View File

@ -64,7 +64,7 @@ create table llx_societe
"rubrique" varchar(255), -- champ rubrique libre
"fk_user_creat" integer, -- utilisateur qui a créé l'info
"fk_user_modif" integer, -- utilisateur qui a modifié l'info
"remise_client" real DEFAULT 0, -- remise systématique pour le client
"remise_client" real DEFAULT 0 -- remise systématique pour le client
);
CREATE INDEX idx_prefix_comm ON llx_societe (prefix_comm);

View File

@ -29,7 +29,6 @@ create table llx_societe_commerciaux
(
rowid SERIAL PRIMARY KEY,
"fk_soc" integer,
"fk_user" integer,
"UNIQUE" INDEX(fk_soc, fk_user)
"fk_user" integer
);

View File

@ -29,7 +29,6 @@ create table llx_user_rights
(
rowid SERIAL PRIMARY KEY,
"fk_user" integer NOT NULL,
"fk_id" integer NOT NULL,
"UNIQUE"(fk_user,fk_id)
"fk_id" integer NOT NULL
);

View File

@ -25,6 +25,6 @@
-- ===========================================================================
-- Supprimme orhpelins pour permettre montée de la clé
DELETE llx_usergroup_rights FROM llx_usergroup_rights LEFT JOIN llx_usergroup ON llx_usergroup_rights.fk_user = llx_usergroup.rowid WHERE llx_usergroup.rowid IS NULL;
DELETE llx_usergroup_rights FROM llx_usergroup_rights LEFT JOIN llx_usergroup ON llx_usergroup_rights.fk_usergroup = llx_usergroup.rowid WHERE llx_usergroup.rowid IS NULL;
ALTER TABLE llx_usergroup_rights ADD FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);