Fix: Gestion des unsigned mysql et gestion des UNIQUE en fin de create.
This commit is contained in:
parent
7095f324ee
commit
45f05bac82
@ -114,7 +114,9 @@ foreach my $file (keys %filelist) {
|
|||||||
# Output for create table and create index
|
# Output for create table and create index
|
||||||
sub output_create {
|
sub output_create {
|
||||||
# If command ends with "xxx,);", we change to "xxx);"
|
# 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;
|
print OUT $create_sql;
|
||||||
if ($create_index) {
|
if ($create_index) {
|
||||||
@ -179,7 +181,6 @@ foreach my $file (keys %filelist) {
|
|||||||
} elsif (/^[\s\t]*(\w*)\s*.*int.*auto_increment/i) {
|
} elsif (/^[\s\t]*(\w*)\s*.*int.*auto_increment/i) {
|
||||||
$seq = qq~${table}_${1}_seq~;
|
$seq = qq~${table}_${1}_seq~;
|
||||||
s/[\s\t]*([a-zA-Z_0-9]*)\s*.*int.*auto_increment[^,]*/ $1 SERIAL PRIMARY KEY/ig;
|
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.=$_;
|
$create_sql.=$_;
|
||||||
next;
|
next;
|
||||||
# int type conversion
|
# int type conversion
|
||||||
@ -200,8 +201,8 @@ foreach my $file (keys %filelist) {
|
|||||||
s/tinyint/smallint/g;
|
s/tinyint/smallint/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
# nuke int unsigned
|
# nuke unsigned
|
||||||
s/(int\w+)\s+unsigned/$1/gi;
|
s/(int\w+|smallint)\s+unsigned/$1/gi;
|
||||||
|
|
||||||
|
|
||||||
# blob -> text
|
# blob -> text
|
||||||
@ -234,7 +235,8 @@ foreach my $file (keys %filelist) {
|
|||||||
s/(\s*)double/${1}real/i;
|
s/(\s*)double/${1}real/i;
|
||||||
|
|
||||||
# Ignore "unique key(xx, yy)" (key on double fields not supported by postgres)
|
# 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) {
|
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
|
s/KEY(\s+)[^(]*(\s+)/$1 UNIQUE $2/i; # hack off name of the non-primary key
|
||||||
|
|||||||
@ -25,14 +25,12 @@
|
|||||||
--
|
--
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
|
|
||||||
-- telfixe varchar(15),
|
|
||||||
-- teljob varchar(15)
|
|
||||||
|
|
||||||
create table llx_adherent_options
|
create table llx_adherent_options
|
||||||
(
|
(
|
||||||
optid SERIAL PRIMARY KEY,
|
optid SERIAL PRIMARY KEY,
|
||||||
"tms" timestamp,
|
"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);
|
CREATE INDEX idx_adhid ON llx_adherent_options (adhid);
|
||||||
|
|||||||
@ -30,7 +30,7 @@ create table llx_appro
|
|||||||
"datec" timestamp,
|
"datec" timestamp,
|
||||||
"tms" timestamp,
|
"tms" timestamp,
|
||||||
"fk_product" integer NOT NULL,
|
"fk_product" integer NOT NULL,
|
||||||
"quantity" smallint unsigned NOT NULL,
|
"quantity" smallint NOT NULL,
|
||||||
"price" real,
|
"price" real,
|
||||||
"fk_user_author" integer
|
"fk_user_author" integer
|
||||||
);
|
);
|
||||||
|
|||||||
@ -25,11 +25,14 @@
|
|||||||
--
|
--
|
||||||
-- ========================================================================
|
-- ========================================================================
|
||||||
|
|
||||||
|
|
||||||
create table llx_c_ape
|
create table llx_c_ape
|
||||||
(
|
(
|
||||||
rowid SERIAL PRIMARY KEY,
|
rowid SERIAL PRIMARY KEY,
|
||||||
code_ape varchar(5) PRIMARY KEY,
|
"code_ape" varchar(5) NOT NULL,
|
||||||
"libelle" varchar(255),
|
"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);
|
||||||
|
|
||||||
|
|||||||
@ -28,12 +28,8 @@
|
|||||||
--
|
--
|
||||||
--
|
--
|
||||||
ALTER TABLE llx_contrat ADD INDEX (fk_soc);
|
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 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_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);
|
ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ create table llx_expeditiondet
|
|||||||
rowid SERIAL PRIMARY KEY,
|
rowid SERIAL PRIMARY KEY,
|
||||||
"fk_expedition" integer NOT NULL,
|
"fk_expedition" integer NOT NULL,
|
||||||
"fk_commande_ligne" 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);
|
CREATE INDEX idx_fk_expedition ON llx_expeditiondet (fk_expedition);
|
||||||
|
|||||||
@ -47,6 +47,5 @@ create table llx_facture_fourn
|
|||||||
"fk_statut" smallint DEFAULT 0 NOT NULL,
|
"fk_statut" smallint DEFAULT 0 NOT NULL,
|
||||||
"fk_user_author" integer, -- createur de la facture
|
"fk_user_author" integer, -- createur de la facture
|
||||||
"fk_user_valid" integer, -- valideur de la facture
|
"fk_user_valid" integer, -- valideur de la facture
|
||||||
"note" text,
|
"note" text
|
||||||
"UNIQUE" INDEX (facnumber, fk_soc)
|
|
||||||
);
|
);
|
||||||
|
|||||||
@ -39,7 +39,8 @@ create table llx_livre
|
|||||||
"prix" decimal(15,4),
|
"prix" decimal(15,4),
|
||||||
"fk_editeur" integer,
|
"fk_editeur" integer,
|
||||||
"fk_user_author" integer,
|
"fk_user_author" integer,
|
||||||
"frais_de_port" smallint DEFAULT 1,
|
"frais_de_port" smallint DEFAULT 1
|
||||||
"UNIQUE"(ref)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_ref ON llx_livre (ref);
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,5 @@
|
|||||||
create table llx_livre_to_auteur
|
create table llx_livre_to_auteur
|
||||||
(
|
(
|
||||||
"fk_livre" integer NOT NULL,
|
"fk_livre" integer NOT NULL,
|
||||||
"fk_auteur" integer NOT NULL,
|
"fk_auteur" integer NOT NULL
|
||||||
"unique" index (fk_livre, fk_auteur)
|
|
||||||
);
|
);
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
-- N'est plus utilisé !!
|
||||||
|
--
|
||||||
|
|
||||||
create table llx_prelevement
|
create table llx_prelevement
|
||||||
(
|
(
|
||||||
|
|||||||
@ -31,7 +31,7 @@ create table llx_product_stock
|
|||||||
"tms" timestamp,
|
"tms" timestamp,
|
||||||
"fk_product" integer NOT NULL,
|
"fk_product" integer NOT NULL,
|
||||||
"fk_entrepot" 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);
|
CREATE INDEX idx_fk_product ON llx_product_stock (fk_product);
|
||||||
|
|||||||
@ -64,7 +64,7 @@ create table llx_societe
|
|||||||
"rubrique" varchar(255), -- champ rubrique libre
|
"rubrique" varchar(255), -- champ rubrique libre
|
||||||
"fk_user_creat" integer, -- utilisateur qui a créé l'info
|
"fk_user_creat" integer, -- utilisateur qui a créé l'info
|
||||||
"fk_user_modif" integer, -- utilisateur qui a modifié 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);
|
CREATE INDEX idx_prefix_comm ON llx_societe (prefix_comm);
|
||||||
|
|||||||
@ -29,7 +29,6 @@ create table llx_societe_commerciaux
|
|||||||
(
|
(
|
||||||
rowid SERIAL PRIMARY KEY,
|
rowid SERIAL PRIMARY KEY,
|
||||||
"fk_soc" integer,
|
"fk_soc" integer,
|
||||||
"fk_user" integer,
|
"fk_user" integer
|
||||||
"UNIQUE" INDEX(fk_soc, fk_user)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,6 @@ create table llx_user_rights
|
|||||||
(
|
(
|
||||||
rowid SERIAL PRIMARY KEY,
|
rowid SERIAL PRIMARY KEY,
|
||||||
"fk_user" integer NOT NULL,
|
"fk_user" integer NOT NULL,
|
||||||
"fk_id" integer NOT NULL,
|
"fk_id" integer NOT NULL
|
||||||
"UNIQUE"(fk_user,fk_id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,6 @@
|
|||||||
-- ===========================================================================
|
-- ===========================================================================
|
||||||
|
|
||||||
-- Supprimme orhpelins pour permettre montée de la clé
|
-- 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);
|
ALTER TABLE llx_usergroup_rights ADD FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user