diff --git a/build/dolibarr_mysql2pgsql.pl b/build/dolibarr_mysql2pgsql.pl index 105d538292e..230281e278f 100644 --- a/build/dolibarr_mysql2pgsql.pl +++ b/build/dolibarr_mysql2pgsql.pl @@ -156,6 +156,7 @@ foreach my $file (keys %filelist) { &reset_vars(); next; } + if (/(\w*)\s+enum\(((?:['"]\w+['"]\s*,)+['"]\w+['"])\)(.*)$/i) { # enum handling $enum_column=$1; $enum_datafield{$enum_column} = $2; # 'abc','def', ... @@ -184,12 +185,17 @@ foreach my $file (keys %filelist) { } s/\w*int\(\d+\)/$out/g; } + elsif (/tinyint/i) { + s/tinyint/smallint/g; + } # nuke int unsigned s/(int\w+)\s+unsigned/$1/gi; + # blob -> text s/\w*blob/text/gi; + # tinytext/mediumtext -> text s/tinytext/text/gi; s/mediumtext/text/gi; @@ -207,6 +213,7 @@ foreach my $file (keys %filelist) { # change not null datetime field to null valid ones # (to support remapping of "zero time" to null s/datetime not null/datetime/i; + s/datetime/timestamp/i; # nuke size of timestamp s/timestamp\([^)]*\)/timestamp/i; @@ -215,12 +222,12 @@ foreach my $file (keys %filelist) { 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; - } +# 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); +# next if (/unique/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 diff --git a/pgsql/tables/llx_adherent.sql b/pgsql/tables/llx_adherent.sql index 69457de8cf9..9d2bff16062 100644 --- a/pgsql/tables/llx_adherent.sql +++ b/pgsql/tables/llx_adherent.sql @@ -37,8 +37,8 @@ create table llx_adherent "public" smallint NOT NULL DEFAULT 0, -- certain champ de la fiche sont ils public ou pas ? "fk_adherent_type" smallint, "morphy" varchar(3) CHECK (morphy IN ('mor','phy')) NOT NULL, -- personne morale / personne physique - "datevalid" datetime, -- date de validation - "datec" datetime, -- date de creation + "datevalid" timestamp, -- date de validation + "datec" timestamp, -- date de creation "prenom" varchar(50), "nom" varchar(50), "societe" varchar(50), @@ -54,7 +54,8 @@ create table llx_adherent "fk_user_author" integer NOT NULL, "fk_user_mod" integer NOT NULL, "fk_user_valid" integer NOT NULL, - "datefin" datetime, -- date de fin de validité de la cotisation + "datefin" timestamp, -- date de fin de validité de la cotisation "note" text, + "UNIQUE" INDEX(login) ); diff --git a/pgsql/tables/llx_adherent_options.sql b/pgsql/tables/llx_adherent_options.sql index cecee399716..7ca8f88eabf 100644 --- a/pgsql/tables/llx_adherent_options.sql +++ b/pgsql/tables/llx_adherent_options.sql @@ -33,4 +33,5 @@ create table llx_adherent_options optid SERIAL PRIMARY KEY, "tms" timestamp, "adhid" integer NOT NULL, -- id de l'adherent auquel correspond ces attributs optionnel + "UNIQUE" INDEX(adhid) ); diff --git a/pgsql/tables/llx_album.sql b/pgsql/tables/llx_album.sql index 0b17c1be225..504170c57b6 100644 --- a/pgsql/tables/llx_album.sql +++ b/pgsql/tables/llx_album.sql @@ -33,7 +33,7 @@ create table llx_album "title" varchar(64), "annee" int2, "description" text, - "collectif" tinyint, + "collectif" smallint, "fk_user_author" integer ); diff --git a/pgsql/tables/llx_album_to_groupart.sql b/pgsql/tables/llx_album_to_groupart.sql index 5a84ea6ca64..1335da8341c 100644 --- a/pgsql/tables/llx_album_to_groupart.sql +++ b/pgsql/tables/llx_album_to_groupart.sql @@ -28,6 +28,7 @@ create table llx_album_to_groupart ( "fk_album" integer NOT NULL, - "fk_groupart" integer NOT NULL + "fk_groupart" integer NOT NULL, + unique key(fk_album, fk_groupart) ); diff --git a/pgsql/tables/llx_appro.sql b/pgsql/tables/llx_appro.sql index 89b8229e2f3..cd51f1d60d9 100644 --- a/pgsql/tables/llx_appro.sql +++ b/pgsql/tables/llx_appro.sql @@ -27,7 +27,7 @@ create table llx_appro ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "fk_product" integer NOT NULL, "quantity" smallint unsigned NOT NULL, diff --git a/pgsql/tables/llx_bank.sql b/pgsql/tables/llx_bank.sql index e9d73062982..69a590a1244 100644 --- a/pgsql/tables/llx_bank.sql +++ b/pgsql/tables/llx_bank.sql @@ -29,7 +29,7 @@ create table llx_bank ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "datev" date, -- date de valeur "dateo" date, -- date operation "amount" real NOT NULL default 0, @@ -40,7 +40,7 @@ create table llx_bank "fk_type" varchar(4), -- CB, Virement, cheque "num_releve" varchar(50), "num_chq" int, - "rappro" tinyint default 0, + "rappro" smallint default 0, "note" text, "author" varchar(40) -- a supprimer apres migration ); diff --git a/pgsql/tables/llx_bank_account.sql b/pgsql/tables/llx_bank_account.sql index 7882259b551..c3ebca31bf7 100644 --- a/pgsql/tables/llx_bank_account.sql +++ b/pgsql/tables/llx_bank_account.sql @@ -32,7 +32,7 @@ create table llx_bank_account ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "label" varchar(30), "bank" varchar(60), diff --git a/pgsql/tables/llx_bookmark.sql b/pgsql/tables/llx_bookmark.sql index 74511273ac6..0e929897d85 100644 --- a/pgsql/tables/llx_bookmark.sql +++ b/pgsql/tables/llx_bookmark.sql @@ -27,5 +27,5 @@ create table llx_bookmark rowid SERIAL PRIMARY KEY, "fk_soc" integer, "fk_user" integer, - "dateb" datetime + "dateb" timestamp ); diff --git a/pgsql/tables/llx_bookmark4u_login.sql b/pgsql/tables/llx_bookmark4u_login.sql index ea14c8c6d9d..18edf9e6428 100644 --- a/pgsql/tables/llx_bookmark4u_login.sql +++ b/pgsql/tables/llx_bookmark4u_login.sql @@ -29,5 +29,6 @@ create table llx_bookmark4u_login ( rowid SERIAL PRIMARY KEY, "fk_user" integer, - "bk4u_uid" integer + "bk4u_uid" integer, + "UNIQUE" INDEX(fk_user) ); diff --git a/pgsql/tables/llx_c_actioncomm.sql b/pgsql/tables/llx_c_actioncomm.sql index 78f2ff31c9e..70375996285 100644 --- a/pgsql/tables/llx_c_actioncomm.sql +++ b/pgsql/tables/llx_c_actioncomm.sql @@ -28,8 +28,9 @@ create table llx_c_actioncomm ( id integer PRIMARY KEY, + "code" varchar(12) UNIQUE NOT NULL, "type" varchar(10) DEFAULT 'system' NOT NULL, "libelle" varchar(30) NOT NULL, - "active" tinyint DEFAULT 1 NOT NULL, - "todo" tinyint + "active" smallint DEFAULT 1 NOT NULL, + "todo" smallint ); diff --git a/pgsql/tables/llx_c_ape.sql b/pgsql/tables/llx_c_ape.sql index 1ee303b224f..11d9b4f4e9d 100644 --- a/pgsql/tables/llx_c_ape.sql +++ b/pgsql/tables/llx_c_ape.sql @@ -30,6 +30,6 @@ create table llx_c_ape rowid SERIAL PRIMARY KEY, code_ape varchar(5) PRIMARY KEY, "libelle" varchar(255), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_chargesociales.sql b/pgsql/tables/llx_c_chargesociales.sql index 2a201f3eda0..efce6e17f3a 100644 --- a/pgsql/tables/llx_c_chargesociales.sql +++ b/pgsql/tables/llx_c_chargesociales.sql @@ -30,7 +30,7 @@ create table llx_c_chargesociales id integer PRIMARY KEY, "libelle" varchar(80), "deductible" smallint DEFAULT 0 NOT NULL, - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_civilite.sql b/pgsql/tables/llx_c_civilite.sql index fdae84fbe0b..1d39bec2155 100644 --- a/pgsql/tables/llx_c_civilite.sql +++ b/pgsql/tables/llx_c_civilite.sql @@ -27,7 +27,8 @@ create table llx_c_civilite ( rowid integer PRIMARY KEY, + "code" varchar(6) UNIQUE NOT NULL, "civilite" varchar(50), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_currencies.sql b/pgsql/tables/llx_c_currencies.sql index d9ca9ca84a8..72ad3db869a 100644 --- a/pgsql/tables/llx_c_currencies.sql +++ b/pgsql/tables/llx_c_currencies.sql @@ -26,7 +26,9 @@ create table llx_c_currencies ( + code varchar(2) UNIQUE PRIMARY KEY, + "code_iso" varchar(3) UNIQUE NOT NULL, "label" varchar(64), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_departements.sql b/pgsql/tables/llx_c_departements.sql index 757a520c1b6..2d587be7536 100644 --- a/pgsql/tables/llx_c_departements.sql +++ b/pgsql/tables/llx_c_departements.sql @@ -35,7 +35,7 @@ create table llx_c_departements "tncc" integer, "ncc" varchar(50), "nom" varchar(50), - "active" tinyint DEFAULT 1 NOT NULL, + "active" smallint DEFAULT 1 NOT NULL, key (fk_region) ); diff --git a/pgsql/tables/llx_c_effectif.sql b/pgsql/tables/llx_c_effectif.sql index 3e23ae1dc65..ea84189e766 100644 --- a/pgsql/tables/llx_c_effectif.sql +++ b/pgsql/tables/llx_c_effectif.sql @@ -28,7 +28,8 @@ create table llx_c_effectif ( id integer PRIMARY KEY, + "code" varchar(12) UNIQUE NOT NULL, "libelle" varchar(30), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_forme_juridique.sql b/pgsql/tables/llx_c_forme_juridique.sql index a2c061bb52b..489240a6f22 100644 --- a/pgsql/tables/llx_c_forme_juridique.sql +++ b/pgsql/tables/llx_c_forme_juridique.sql @@ -29,8 +29,9 @@ create table llx_c_forme_juridique ( rowid SERIAL PRIMARY KEY, + "code" varchar(12) UNIQUE NOT NULL, "fk_pays" integer NOT NULL, "libelle" varchar(255), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_methode_commande_fournisseur.sql b/pgsql/tables/llx_c_methode_commande_fournisseur.sql index 636807660a2..1d4e4a0300b 100644 --- a/pgsql/tables/llx_c_methode_commande_fournisseur.sql +++ b/pgsql/tables/llx_c_methode_commande_fournisseur.sql @@ -30,6 +30,6 @@ create table llx_c_methode_commande_fournisseur rowid SERIAL PRIMARY KEY, "code" varchar(30), "libelle" varchar(30), - "active" tinyint default 1 NOT NULL + "active" smallint default 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_paiement.sql b/pgsql/tables/llx_c_paiement.sql index 610fbc6f0a0..31f7674d247 100644 --- a/pgsql/tables/llx_c_paiement.sql +++ b/pgsql/tables/llx_c_paiement.sql @@ -34,9 +34,10 @@ create table llx_c_paiement ( id integer PRIMARY KEY, + "code" varchar(6) UNIQUE NOT NULL, "libelle" varchar(30), "type" smallint, - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_pays.sql b/pgsql/tables/llx_c_pays.sql index 1a2d44821b2..949aa1ceb11 100644 --- a/pgsql/tables/llx_c_pays.sql +++ b/pgsql/tables/llx_c_pays.sql @@ -28,8 +28,9 @@ create table llx_c_pays ( rowid integer PRIMARY KEY, + "code" varchar(6) UNIQUE NOT NULL, "libelle" varchar(25) NOT NULL, - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_propalst.sql b/pgsql/tables/llx_c_propalst.sql index 362aaac2e1b..3a61a3d6024 100644 --- a/pgsql/tables/llx_c_propalst.sql +++ b/pgsql/tables/llx_c_propalst.sql @@ -28,7 +28,8 @@ create table llx_c_propalst ( id smallint PRIMARY KEY, + "code" varchar(12) UNIQUE NOT NULL, "label" varchar(30), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_regions.sql b/pgsql/tables/llx_c_regions.sql index 3483047ce42..d99dd3bb9dd 100644 --- a/pgsql/tables/llx_c_regions.sql +++ b/pgsql/tables/llx_c_regions.sql @@ -28,10 +28,11 @@ create table llx_c_regions ( rowid SERIAL PRIMARY KEY, + "code_region" integer UNIQUE NOT NULL, "fk_pays" integer NOT NULL, "cheflieu" varchar(7), "tncc" integer, "nom" varchar(50), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_stcomm.sql b/pgsql/tables/llx_c_stcomm.sql index 487c24be782..6148d9c9749 100644 --- a/pgsql/tables/llx_c_stcomm.sql +++ b/pgsql/tables/llx_c_stcomm.sql @@ -28,7 +28,8 @@ create table llx_c_stcomm ( id integer PRIMARY KEY, + "code" varchar(12) UNIQUE NOT NULL, "libelle" varchar(30), - "active" tinyint default 1 NOT NULL + "active" smallint default 1 NOT NULL ); diff --git a/pgsql/tables/llx_c_typent.sql b/pgsql/tables/llx_c_typent.sql index 27eb90992b6..ed7289cc20b 100644 --- a/pgsql/tables/llx_c_typent.sql +++ b/pgsql/tables/llx_c_typent.sql @@ -28,6 +28,7 @@ create table llx_c_typent ( id integer PRIMARY KEY, + "code" varchar(12) UNIQUE NOT NULL, "libelle" varchar(30), - "active" tinyint DEFAULT 1 NOT NULL + "active" smallint DEFAULT 1 NOT NULL ); diff --git a/pgsql/tables/llx_chargesociales.sql b/pgsql/tables/llx_chargesociales.sql index d92dc35c932..db0f52f8852 100644 --- a/pgsql/tables/llx_chargesociales.sql +++ b/pgsql/tables/llx_chargesociales.sql @@ -27,8 +27,8 @@ create table llx_chargesociales ( rowid SERIAL PRIMARY KEY, - "date_ech" datetime, -- date d'echeance - "date_pai" datetime, -- date de paiements + "date_ech" timestamp, -- date d'echeance + "date_pai" timestamp, -- date de paiements "libelle" varchar(80), "fk_type" integer, "amount" real default 0 NOT NULL, diff --git a/pgsql/tables/llx_commande.sql b/pgsql/tables/llx_commande.sql index 00bbd247cba..3487dc54412 100644 --- a/pgsql/tables/llx_commande.sql +++ b/pgsql/tables/llx_commande.sql @@ -32,9 +32,9 @@ create table llx_commande "fk_soc_contact" integer, "fk_projet" integer DEFAULT 0, -- projet auquel est rattache la commande "ref" varchar(30) NOT NULL, -- propal number - "date_creation" datetime, -- date de creation - "date_valid" datetime, -- date de validation - "date_cloture" datetime, -- date de cloture + "date_creation" timestamp, -- date de creation + "date_valid" timestamp, -- date de validation + "date_cloture" timestamp, -- date de cloture "date_commande" date, -- date de la commande "fk_user_author" integer, -- createur de la commande "fk_user_valid" integer, -- valideur de la commande @@ -49,5 +49,6 @@ create table llx_commande "total_ttc" real default 0, "note" text, "model_pdf" varchar(50), - "facture" tinyint default 0, -4294967294); + "facture" smallint default 0, + "UNIQUE" INDEX (ref) +); diff --git a/pgsql/tables/llx_commande_fournisseur.sql b/pgsql/tables/llx_commande_fournisseur.sql index 06f9e95773b..85d1cefc42f 100644 --- a/pgsql/tables/llx_commande_fournisseur.sql +++ b/pgsql/tables/llx_commande_fournisseur.sql @@ -33,9 +33,9 @@ create table llx_commande_fournisseur "fk_soc_contact" integer, "fk_projet" integer DEFAULT 0, -- projet auquel est rattache la commande "ref" varchar(30) NOT NULL, -- propal number - "date_creation" datetime, -- date de creation - "date_valid" datetime, -- date de validation - "date_cloture" datetime, -- date de cloture + "date_creation" timestamp, -- date de creation + "date_valid" timestamp, -- date de validation + "date_cloture" timestamp, -- date de cloture "date_commande" date, -- date de la commande "fk_methode_commande" integer default 0, "fk_user_author" integer, -- createur de la commande @@ -51,4 +51,5 @@ create table llx_commande_fournisseur "total_ttc" real default 0, "note" text, "model_pdf" varchar(50), -4294967294); + "UNIQUE" INDEX (ref) +); diff --git a/pgsql/tables/llx_commande_fournisseur_log.sql b/pgsql/tables/llx_commande_fournisseur_log.sql index 9c22682c86d..3dc1d06a5ab 100644 --- a/pgsql/tables/llx_commande_fournisseur_log.sql +++ b/pgsql/tables/llx_commande_fournisseur_log.sql @@ -28,7 +28,7 @@ create table llx_commande_fournisseur_log ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "datelog" datetime, + "datelog" timestamp, "fk_commande" integer NOT NULL, "fk_statut" smallint NOT NULL, "fk_user" integer NOT NULL diff --git a/pgsql/tables/llx_compta.sql b/pgsql/tables/llx_compta.sql index f9aefbda8c2..5e58525e061 100644 --- a/pgsql/tables/llx_compta.sql +++ b/pgsql/tables/llx_compta.sql @@ -28,13 +28,13 @@ create table llx_compta ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "datev" date, -- date de valeur "amount" real DEFAULT 0 NOT NULL , "label" varchar(255), "fk_compta_account" integer, "fk_user_author" integer, "fk_user_valid" integer, - "valid" tinyint DEFAULT 0, + "valid" smallint DEFAULT 0, "note" text ); diff --git a/pgsql/tables/llx_compta_account.sql b/pgsql/tables/llx_compta_account.sql index b20cb47bc01..4338b9ce630 100644 --- a/pgsql/tables/llx_compta_account.sql +++ b/pgsql/tables/llx_compta_account.sql @@ -28,7 +28,7 @@ create table llx_compta_account ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "number" varchar(12), "label" varchar(255), "fk_user_author" integer, diff --git a/pgsql/tables/llx_compta_compte_generaux.sql b/pgsql/tables/llx_compta_compte_generaux.sql index e20914bbf92..9fc2a14bbce 100644 --- a/pgsql/tables/llx_compta_compte_generaux.sql +++ b/pgsql/tables/llx_compta_compte_generaux.sql @@ -28,9 +28,10 @@ create table llx_compta_compte_generaux ( rowid SERIAL PRIMARY KEY, - "date_creation" datetime, + "date_creation" timestamp, "numero" varchar(50), "intitule" varchar(255), "fk_user_author" integer, - "note" text + "note" text, + "UNIQUE"(numero) ); diff --git a/pgsql/tables/llx_concert.sql b/pgsql/tables/llx_concert.sql index c77105b9d98..b73a3a8dc5b 100644 --- a/pgsql/tables/llx_concert.sql +++ b/pgsql/tables/llx_concert.sql @@ -28,9 +28,9 @@ create table llx_concert ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "date_concert" datetime, + "date_concert" timestamp, "description" text, - "collectif" tinyint DEFAULT 0 NOT NULL, + "collectif" smallint DEFAULT 0 NOT NULL, "fk_groupart" integer, "fk_lieu_concert" integer, "fk_user_author" integer diff --git a/pgsql/tables/llx_cond_reglement.sql b/pgsql/tables/llx_cond_reglement.sql index 69cf7a0e98b..0db3d8707ec 100644 --- a/pgsql/tables/llx_cond_reglement.sql +++ b/pgsql/tables/llx_cond_reglement.sql @@ -29,9 +29,9 @@ create table llx_cond_reglement rowid integer PRIMARY KEY, "code" varchar(16), "sortorder" smallint, - "actif" tinyint DEFAULT 1, + "actif" smallint DEFAULT 1, "libelle" varchar(255), "libelle_facture" text, - "fdm" tinyint, -- reglement fin de mois + "fdm" smallint, -- reglement fin de mois "nbjour" smallint ); diff --git a/pgsql/tables/llx_const.sql b/pgsql/tables/llx_const.sql index 3c44552ec8f..8418d3352e2 100644 --- a/pgsql/tables/llx_const.sql +++ b/pgsql/tables/llx_const.sql @@ -35,6 +35,7 @@ create table llx_const "name" varchar(255), "value" text, -- max 65535 caracteres "type" varchar(6) CHECK (type IN ('yesno','texte','chaine')) , - "visible" tinyint DEFAULT 1 NOT NULL, - "note" text + "visible" smallint DEFAULT 1 NOT NULL, + "note" text, + "UNIQUE" INDEX(name) ); diff --git a/pgsql/tables/llx_contact_facture.sql b/pgsql/tables/llx_contact_facture.sql index 33d370a0f0a..555415f59f6 100644 --- a/pgsql/tables/llx_contact_facture.sql +++ b/pgsql/tables/llx_contact_facture.sql @@ -32,4 +32,5 @@ create table llx_contact_facture idp SERIAL PRIMARY KEY, "fk_soc" integer NOT NULL, "fk_contact" integer NOT NULL, -- point sur llx_socpeople + "UNIQUE" (fk_soc, fk_contact) ); diff --git a/pgsql/tables/llx_contrat.sql b/pgsql/tables/llx_contrat.sql index a46fd148595..fa06bd68343 100644 --- a/pgsql/tables/llx_contrat.sql +++ b/pgsql/tables/llx_contrat.sql @@ -31,12 +31,12 @@ create table llx_contrat ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "datec" datetime, -- date de creation de l'enregistrement - "date_contrat" datetime, + "datec" timestamp, -- date de creation de l'enregistrement + "date_contrat" timestamp, "statut" smallint DEFAULT 0, - "mise_en_service" datetime, - "fin_validite" datetime, - "date_cloture" datetime, + "mise_en_service" timestamp, + "fin_validite" timestamp, + "date_cloture" timestamp, "fk_soc" integer NOT NULL, "fk_commercial_signature" integer NOT NULL, "fk_commercial_suivi" integer NOT NULL, diff --git a/pgsql/tables/llx_contratdet.sql b/pgsql/tables/llx_contratdet.sql index 6533589fc35..33ae84ec241 100644 --- a/pgsql/tables/llx_contratdet.sql +++ b/pgsql/tables/llx_contratdet.sql @@ -40,11 +40,11 @@ create table llx_contratdet "statut" smallint DEFAULT 0, "label" text, -- libellé du produit "description" text, - "date_commande" datetime, - "date_ouverture_prevue" datetime, - "date_ouverture" datetime, -- date d'ouverture du service chez le client - "date_fin_validite" datetime, - "date_cloture" datetime, + "date_commande" timestamp, + "date_ouverture_prevue" timestamp, + "date_ouverture" timestamp, -- date d'ouverture du service chez le client + "date_fin_validite" timestamp, + "date_cloture" timestamp, "tva_tx" real DEFAULT 19.6, -- taux tva "qty" real, -- quantité "remise_percent" real DEFAULT 0, -- pourcentage de remise diff --git a/pgsql/tables/llx_contratdet_log.sql b/pgsql/tables/llx_contratdet_log.sql index f0de7c4297a..cde52d818c9 100644 --- a/pgsql/tables/llx_contratdet_log.sql +++ b/pgsql/tables/llx_contratdet_log.sql @@ -30,7 +30,7 @@ create table llx_contratdet_log rowid SERIAL PRIMARY KEY, "tms" timestamp, "fk_contratdet" integer NOT NULL, - "date" datetime, + "date" timestamp, "statut" smallint NOT NULL, "fk_user_author" integer NOT NULL, "commentaire" text diff --git a/pgsql/tables/llx_cotisation.sql b/pgsql/tables/llx_cotisation.sql index 129f5737712..078429677d4 100644 --- a/pgsql/tables/llx_cotisation.sql +++ b/pgsql/tables/llx_cotisation.sql @@ -27,9 +27,9 @@ create table llx_cotisation ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "datec" datetime, + "datec" timestamp, "fk_adherent" integer, - "dateadh" datetime, + "dateadh" timestamp, "cotisation" real, "fk_bank" int4 DEFAULT NULL, "note" text diff --git a/pgsql/tables/llx_deplacement.sql b/pgsql/tables/llx_deplacement.sql index e5ded27313c..70b46cf410c 100644 --- a/pgsql/tables/llx_deplacement.sql +++ b/pgsql/tables/llx_deplacement.sql @@ -27,9 +27,9 @@ create table llx_deplacement ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, - "dated" datetime, + "dated" timestamp, "fk_user" integer NOT NULL, "fk_user_author" integer, "type" smallint NOT NULL, diff --git a/pgsql/tables/llx_domain.sql b/pgsql/tables/llx_domain.sql index 1d551c9f4ca..fe4f4a7fc09 100644 --- a/pgsql/tables/llx_domain.sql +++ b/pgsql/tables/llx_domain.sql @@ -27,7 +27,7 @@ create table llx_domain ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "label" varchar(255), "note" text ); diff --git a/pgsql/tables/llx_don.sql b/pgsql/tables/llx_don.sql index d69cac3585e..ce65e1b15ec 100644 --- a/pgsql/tables/llx_don.sql +++ b/pgsql/tables/llx_don.sql @@ -29,8 +29,8 @@ create table llx_don rowid SERIAL PRIMARY KEY, "tms" timestamp, "fk_statut" smallint NOT NULL DEFAULT 0,-- etat du don promesse/valid - "datec" datetime, -- date de création de l'enregistrement - "datedon" datetime, -- date du don/promesse + "datec" timestamp, -- date de création de l'enregistrement + "datedon" timestamp, -- date du don/promesse "amount" real DEFAULT 0, "fk_paiement" integer, "prenom" varchar(50), diff --git a/pgsql/tables/llx_don_projet.sql b/pgsql/tables/llx_don_projet.sql index db55bafbcee..8961f7a4112 100644 --- a/pgsql/tables/llx_don_projet.sql +++ b/pgsql/tables/llx_don_projet.sql @@ -28,7 +28,7 @@ create table llx_don_projet ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "datec" datetime, + "datec" timestamp, "libelle" varchar(255), "fk_user_author" integer NOT NULL, "note" text diff --git a/pgsql/tables/llx_entrepot.sql b/pgsql/tables/llx_entrepot.sql index 68d3a4e77c2..4a2610918ea 100644 --- a/pgsql/tables/llx_entrepot.sql +++ b/pgsql/tables/llx_entrepot.sql @@ -28,11 +28,11 @@ create table llx_entrepot ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "label" varchar(255) NOT NULL, "description" text, - "statut" tinyint DEFAULT 1, -- 1 ouvert, 0 fermé + "statut" smallint DEFAULT 1, -- 1 ouvert, 0 fermé "fk_user_author" integer ); diff --git a/pgsql/tables/llx_expedition.sql b/pgsql/tables/llx_expedition.sql index e893066a0c1..c83632fac2b 100644 --- a/pgsql/tables/llx_expedition.sql +++ b/pgsql/tables/llx_expedition.sql @@ -31,8 +31,8 @@ create table llx_expedition "tms" timestamp, "ref" varchar(30) NOT NULL, "fk_commande" integer, - "date_creation" datetime, -- date de creation - "date_valid" datetime, -- date de validation + "date_creation" timestamp, -- date de creation + "date_valid" timestamp, -- date de validation "date_expedition" date, -- date de l'expedition "fk_user_author" integer, -- createur "fk_user_valid" integer, -- valideur @@ -41,7 +41,8 @@ create table llx_expedition "fk_statut" smallint DEFAULT 0, "note" text, "model_pdf" varchar(50), -4294967294); + "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); diff --git a/pgsql/tables/llx_expedition_methode.sql b/pgsql/tables/llx_expedition_methode.sql index ad531c64717..b9bd102b265 100644 --- a/pgsql/tables/llx_expedition_methode.sql +++ b/pgsql/tables/llx_expedition_methode.sql @@ -31,5 +31,5 @@ create table llx_expedition_methode "code" varchar(30) NOT NULL, "libelle" varchar(50) NOT NULL, "description" text, - "statut" tinyint DEFAULT 0 + "statut" smallint DEFAULT 0 ); diff --git a/pgsql/tables/llx_export_compta.sql b/pgsql/tables/llx_export_compta.sql index f2d2c538b81..57f8532aea1 100644 --- a/pgsql/tables/llx_export_compta.sql +++ b/pgsql/tables/llx_export_compta.sql @@ -30,7 +30,7 @@ create table llx_export_compta ( rowid SERIAL PRIMARY KEY, "ref" varchar(12) NOT NULL, - "date_export" datetime, -- date de creation + "date_export" timestamp, -- date de creation "fk_user" integer NOT NULL, "note" text ); diff --git a/pgsql/tables/llx_facture.sql b/pgsql/tables/llx_facture.sql index 22b87273cfe..bae2f9aff07 100644 --- a/pgsql/tables/llx_facture.sql +++ b/pgsql/tables/llx_facture.sql @@ -30,7 +30,7 @@ create table llx_facture "facnumber" varchar(50) NOT NULL, "increment" varchar(10), "fk_soc" integer NOT NULL, - "datec" datetime, -- date de creation de la facture + "datec" timestamp, -- date de creation de la facture "datef" date, -- date de la facture "paye" smallint DEFAULT 0 NOT NULL, "amount" real DEFAULT 0 NOT NULL, @@ -49,5 +49,6 @@ create table llx_facture "fk_mode_reglement" integer, -- mode de reglement (Virement, Prélèvement) "date_lim_reglement" date, -- date limite de reglement "note" text, -4294967294 "INDEX" fksoc (fk_soc) + "UNIQUE" INDEX (facnumber), + "INDEX" fksoc (fk_soc) ); diff --git a/pgsql/tables/llx_facture_fourn.sql b/pgsql/tables/llx_facture_fourn.sql index 02329d30c34..3032210f290 100644 --- a/pgsql/tables/llx_facture_fourn.sql +++ b/pgsql/tables/llx_facture_fourn.sql @@ -33,7 +33,7 @@ create table llx_facture_fourn rowid SERIAL PRIMARY KEY, "facnumber" varchar(50) NOT NULL, "fk_soc" integer NOT NULL, - "datec" datetime, -- date de creation de la facture + "datec" timestamp, -- date de creation de la facture "datef" date, -- date de la facture "libelle" varchar(255), "paye" smallint DEFAULT 0 NOT NULL, @@ -47,5 +47,6 @@ 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 + "note" text, + "UNIQUE" INDEX (facnumber, fk_soc) ); diff --git a/pgsql/tables/llx_facture_rec.sql b/pgsql/tables/llx_facture_rec.sql index 35d29040cd6..7046795868e 100644 --- a/pgsql/tables/llx_facture_rec.sql +++ b/pgsql/tables/llx_facture_rec.sql @@ -32,7 +32,7 @@ create table llx_facture_rec rowid SERIAL PRIMARY KEY, "titre" varchar(50) NOT NULL, "fk_soc" integer NOT NULL, - "datec" datetime, -- date de creation + "datec" timestamp, -- date de creation "amount" real DEFAULT 0 NOT NULL, "remise" real DEFAULT 0, "remise_percent" real DEFAULT 0, diff --git a/pgsql/tables/llx_facturedet.sql b/pgsql/tables/llx_facturedet.sql index 190642374bb..5a8876da945 100644 --- a/pgsql/tables/llx_facturedet.sql +++ b/pgsql/tables/llx_facturedet.sql @@ -37,8 +37,8 @@ create table llx_facturedet "remise" real DEFAULT 0, -- montant de la remise "subprice" real, -- prix avant remise "price" real, -- prix final - "date_start" datetime, -- date debut si service - "date_end" datetime, -- date fin si service + "date_start" timestamp, -- date debut si service + "date_end" timestamp, -- date fin si service "fk_code_ventilation" integer DEFAULT 0 NOT NULL, "fk_export_compta" integer DEFAULT 0 NOT NULL ); diff --git a/pgsql/tables/llx_fichinter.sql b/pgsql/tables/llx_fichinter.sql index ae800062d9f..e6a57e9b940 100644 --- a/pgsql/tables/llx_fichinter.sql +++ b/pgsql/tables/llx_fichinter.sql @@ -31,12 +31,13 @@ create table llx_fichinter "fk_soc" integer NOT NULL, "fk_projet" integer DEFAULT 0, -- projet auquel est rattache la fiche "ref" varchar(30) NOT NULL, -- number - "datec" datetime, -- date de creation - "date_valid" datetime, -- date de validation + "datec" timestamp, -- date de creation + "date_valid" timestamp, -- date de validation "datei" date, -- date de l'intervention "fk_user_author" integer, -- createur de la fiche "fk_user_valid" integer, -- valideur de la fiche "fk_statut" smallint DEFAULT 0, "duree" real, "note" text, -4294967294); + "UNIQUE" INDEX (ref) +); diff --git a/pgsql/tables/llx_groupesociete.sql b/pgsql/tables/llx_groupesociete.sql index 4d740a4494d..e8a7a8ae520 100644 --- a/pgsql/tables/llx_groupesociete.sql +++ b/pgsql/tables/llx_groupesociete.sql @@ -28,8 +28,9 @@ create table llx_groupesociete ( rowid SERIAL PRIMARY KEY, + "parent" integer UNIQUE, "tms" timestamp, - "datec" datetime, -- creation date + "datec" timestamp, -- creation date "nom" varchar(60), -- company name "note" text, -- "remise" real DEFAULT 0, -- remise systématique pour le client diff --git a/pgsql/tables/llx_groupesociete_remise.sql b/pgsql/tables/llx_groupesociete_remise.sql index 8cc1dfacd87..9f043ec5a28 100644 --- a/pgsql/tables/llx_groupesociete_remise.sql +++ b/pgsql/tables/llx_groupesociete_remise.sql @@ -32,7 +32,7 @@ create table llx_groupesociete_remise rowid SERIAL PRIMARY KEY, "fk_groupe" integer NOT NULL, "tms" timestamp, - "datec" datetime, -- creation date + "datec" timestamp, -- creation date "fk_user_author" integer, -- utilisateur qui a créé l'info "remise" real DEFAULT 0, -- remise systématique pour le client "note" text diff --git a/pgsql/tables/llx_livre.sql b/pgsql/tables/llx_livre.sql index 0b03a86806e..dd33518ae15 100644 --- a/pgsql/tables/llx_livre.sql +++ b/pgsql/tables/llx_livre.sql @@ -30,8 +30,8 @@ create table llx_livre rowid SERIAL PRIMARY KEY, "oscid" integer NOT NULL, "tms" timestamp, - "status" tinyint, - "date_ajout" datetime, + "status" smallint, + "date_ajout" timestamp, "ref" varchar(12), "title" varchar(64), "annee" int2, @@ -39,6 +39,7 @@ create table llx_livre "prix" decimal(15,4), "fk_editeur" integer, "fk_user_author" integer, - "frais_de_port" tinyint DEFAULT 1 + "frais_de_port" smallint DEFAULT 1, + "UNIQUE"(ref) ); diff --git a/pgsql/tables/llx_livre_to_auteur.sql b/pgsql/tables/llx_livre_to_auteur.sql index 8c61d96b32b..eea9351c077 100644 --- a/pgsql/tables/llx_livre_to_auteur.sql +++ b/pgsql/tables/llx_livre_to_auteur.sql @@ -28,5 +28,6 @@ create table llx_livre_to_auteur ( "fk_livre" integer NOT NULL, - "fk_auteur" integer NOT NULL + "fk_auteur" integer NOT NULL, + "unique" index (fk_livre, fk_auteur) ); diff --git a/pgsql/tables/llx_mailing.sql b/pgsql/tables/llx_mailing.sql index 4137dec5caf..1d0ee8e538c 100644 --- a/pgsql/tables/llx_mailing.sql +++ b/pgsql/tables/llx_mailing.sql @@ -40,7 +40,7 @@ create table llx_mailing ( rowid SERIAL PRIMARY KEY, "statut" smallint DEFAULT 0, -- - "date_envoi" datetime, -- date d'envoi + "date_envoi" timestamp, -- date d'envoi "titre" varchar(60), -- company name "sujet" varchar(60), -- company name "body" text, @@ -49,9 +49,9 @@ create table llx_mailing "email_from" varchar(160), -- company name "email_replyto" varchar(160), -- company name "email_errorsto" varchar(160), -- company name - "date_creat" datetime, -- creation date - "date_valid" datetime, -- creation date - "date_appro" datetime, -- creation date + "date_creat" timestamp, -- creation date + "date_valid" timestamp, -- creation date + "date_appro" timestamp, -- creation date "fk_user_creat" integer, -- utilisateur qui a créé l'info "fk_user_valid" integer, -- utilisateur qui a créé l'info "fk_user_appro" integer -- utilisateur qui a créé l'info diff --git a/pgsql/tables/llx_newsletter.sql b/pgsql/tables/llx_newsletter.sql index 4b0ced2e831..596e5d80c1a 100644 --- a/pgsql/tables/llx_newsletter.sql +++ b/pgsql/tables/llx_newsletter.sql @@ -27,7 +27,7 @@ create table llx_newsletter ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "email_subject" varchar(32) NOT NULL, "email_from_name" varchar(255) NOT NULL, @@ -37,9 +37,9 @@ create table llx_newsletter "target" smallint, "sql_target" text, "status" smallint DEFAULT 0 NOT NULL, - "date_send_request" datetime, -- debut de l'envoi demandé - "date_send_begin" datetime, -- debut de l'envoi - "date_send_end" datetime, -- fin de l'envoi + "date_send_request" timestamp, -- debut de l'envoi demandé + "date_send_begin" timestamp, -- debut de l'envoi + "date_send_end" timestamp, -- fin de l'envoi "nbsent" integer, -- nombre de mails envoyés "nberror" integer, -- nombre de mails envoyés "fk_user_author" integer, diff --git a/pgsql/tables/llx_notify.sql b/pgsql/tables/llx_notify.sql index f391c438082..41c6032b493 100644 --- a/pgsql/tables/llx_notify.sql +++ b/pgsql/tables/llx_notify.sql @@ -28,7 +28,7 @@ create table llx_notify ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "daten" datetime, -- date de la notification + "daten" timestamp, -- date de la notification "fk_action" integer NOT NULL, "fk_contact" integer NOT NULL, "objet_type" varchar(10) CHECK (objet_type IN ('ficheinter','facture','propale')) , diff --git a/pgsql/tables/llx_paiement.sql b/pgsql/tables/llx_paiement.sql index ad9b863ba61..1b5f207faf4 100644 --- a/pgsql/tables/llx_paiement.sql +++ b/pgsql/tables/llx_paiement.sql @@ -33,9 +33,9 @@ create table llx_paiement ( rowid SERIAL PRIMARY KEY, "fk_facture" integer, - "datec" datetime, -- date de creation + "datec" timestamp, -- date de creation "tms" timestamp, - "datep" datetime, -- payment date + "datep" timestamp, -- payment date "amount" real DEFAULT 0, "author" varchar(50), "fk_paiement" integer NOT NULL, diff --git a/pgsql/tables/llx_paiementcharge.sql b/pgsql/tables/llx_paiementcharge.sql index b27b179b54b..80a2383046f 100644 --- a/pgsql/tables/llx_paiementcharge.sql +++ b/pgsql/tables/llx_paiementcharge.sql @@ -28,9 +28,9 @@ create table llx_paiementcharge ( rowid SERIAL PRIMARY KEY, "fk_charge" integer, - "datec" datetime, -- date de creation + "datec" timestamp, -- date de creation "tms" timestamp, - "datep" datetime, -- payment date + "datep" timestamp, -- payment date "amount" real DEFAULT 0, "fk_typepaiement" integer NOT NULL, "num_paiement" varchar(50), diff --git a/pgsql/tables/llx_paiementfourn.sql b/pgsql/tables/llx_paiementfourn.sql index 078ed824333..890f9518bda 100644 --- a/pgsql/tables/llx_paiementfourn.sql +++ b/pgsql/tables/llx_paiementfourn.sql @@ -28,9 +28,9 @@ create table llx_paiementfourn ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "datec" datetime, -- date de creation de l'enregistrement + "datec" timestamp, -- date de creation de l'enregistrement "fk_facture_fourn" integer, -- facture - "datep" datetime, -- date de paiement + "datep" timestamp, -- date de paiement "amount" real DEFAULT 0, -- montant "fk_user_author" integer, -- auteur "fk_paiement" integer NOT NULL, -- moyen de paiement diff --git a/pgsql/tables/llx_pointmort.sql b/pgsql/tables/llx_pointmort.sql index 6ff343d1347..a925b6a78fb 100644 --- a/pgsql/tables/llx_pointmort.sql +++ b/pgsql/tables/llx_pointmort.sql @@ -25,7 +25,7 @@ create table llx_pointmort ( - "month" datetime, + "month" timestamp, "amount" real ); diff --git a/pgsql/tables/llx_prelevement.sql b/pgsql/tables/llx_prelevement.sql index 4c23efc197c..06292a08b01 100644 --- a/pgsql/tables/llx_prelevement.sql +++ b/pgsql/tables/llx_prelevement.sql @@ -29,14 +29,15 @@ create table llx_prelevement ( rowid SERIAL PRIMARY KEY, "ref" varchar(12), -- reference - "datec" datetime, -- date de creation + "datec" timestamp, -- date de creation "amount" real DEFAULT 0, -- montant total du prelevement "credite" smallint DEFAULT 0, -- indique si le prelevement a été credité "note" text, - "date_trans" datetime, + "date_trans" timestamp, "method_trans" smallint, "fk_user_trans" integer, - "date_credit" datetime, + "date_credit" timestamp, "fk_user_credit" integer, + "UNIQUE"(ref) ); diff --git a/pgsql/tables/llx_prelevement_bons.sql b/pgsql/tables/llx_prelevement_bons.sql index 976f84602fd..0d0f000a227 100644 --- a/pgsql/tables/llx_prelevement_bons.sql +++ b/pgsql/tables/llx_prelevement_bons.sql @@ -32,15 +32,16 @@ create table llx_prelevement_bons ( rowid SERIAL PRIMARY KEY, "ref" varchar(12), -- reference - "datec" datetime, -- date de creation + "datec" timestamp, -- date de creation "amount" real DEFAULT 0, -- montant total du prélèvement "statut" smallint DEFAULT 0, -- statut "credite" smallint DEFAULT 0, -- indique si le prelevement a été credité "note" text, - "date_trans" datetime, -- date de transmission à la banque + "date_trans" timestamp, -- date de transmission à la banque "method_trans" smallint, -- méthode de transmission "fk_user_trans" integer, -- user qui a effectué la transmission - "date_credit" datetime, -- date de crédit sur le compte + "date_credit" timestamp, -- date de crédit sur le compte "fk_user_credit" integer, -- user qui a remonté l'info de crédit + "UNIQUE"(ref) ); diff --git a/pgsql/tables/llx_prelevement_facture.sql b/pgsql/tables/llx_prelevement_facture.sql index 6e2ddbd64d5..9041c23a122 100644 --- a/pgsql/tables/llx_prelevement_facture.sql +++ b/pgsql/tables/llx_prelevement_facture.sql @@ -25,10 +25,10 @@ -- -- + create table llx_prelevement_facture ( rowid SERIAL PRIMARY KEY, - "fk_facture" integer NOT NULL, - "fk_prelevement" integer NOT NULL, - "statut" smallint DEFAULT 0 + "fk_facture" integer NOT NULL, + "fk_prelevement_lignes" integer NOT NULL ); diff --git a/pgsql/tables/llx_prelevement_facture_demande.sql b/pgsql/tables/llx_prelevement_facture_demande.sql index 59bbbef0d88..a9a7ddcb800 100644 --- a/pgsql/tables/llx_prelevement_facture_demande.sql +++ b/pgsql/tables/llx_prelevement_facture_demande.sql @@ -30,15 +30,15 @@ create table llx_prelevement_facture_demande ( rowid SERIAL PRIMARY KEY, - "fk_facture" integer NOT NULL, - "amount" real NOT NULL, - "date_demande" datetime, - "traite" smallint DEFAULT 0, - "date_traite" datetime, - "fk_prelevement" integer, - "fk_user_demande" integer NOT NULL, - "code_banque" varchar(7), - "code_guichet" varchar(6), - "number" varchar(255), - "cle_rib" varchar(5) + "fk_facture" integer NOT NULL, + "amount" real NOT NULL, + "date_demande" timestamp, + "traite" smallint DEFAULT 0, + "date_traite" timestamp, + "fk_prelevement_bons" integer, + "fk_user_demande" integer NOT NULL, + "code_banque" varchar(7), + "code_guichet" varchar(6), + "number" varchar(255), + "cle_rib" varchar(5) ); diff --git a/pgsql/tables/llx_prelevement_rejet.sql b/pgsql/tables/llx_prelevement_rejet.sql index d488d46ecd7..d3134d13c84 100644 --- a/pgsql/tables/llx_prelevement_rejet.sql +++ b/pgsql/tables/llx_prelevement_rejet.sql @@ -29,11 +29,9 @@ create table llx_prelevement_rejet ( rowid SERIAL PRIMARY KEY, - "fk_soc" integer NOT NULL, - "fk_prelevement" integer, - "amount" real DEFAULT 0, -- montant total du prelevement - "motif" integer, - "note" text, - "date_creation" datetime, - "fk_user_creation" integer + "fk_prelevement_lignes" integer, + "motif" integer, + "date_creation" timestamp, + "fk_user_creation" integer, + "note" text ); diff --git a/pgsql/tables/llx_product.sql b/pgsql/tables/llx_product.sql index 31a25894877..2799763513f 100644 --- a/pgsql/tables/llx_product.sql +++ b/pgsql/tables/llx_product.sql @@ -28,14 +28,15 @@ create table llx_product ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, + "ref" varchar(15) UNIQUE, "label" varchar(255), "description" text, "price" double, "tva_tx" double DEFAULT 19.6, "fk_user_author" integer, - "envente" tinyint DEFAULT 1, + "envente" smallint DEFAULT 1, "nbvente" integer DEFAULT 0, "fk_product_type" integer DEFAULT 0, "duration" varchar(6), diff --git a/pgsql/tables/llx_product_fournisseur.sql b/pgsql/tables/llx_product_fournisseur.sql index 4137a830343..b90469b7c9f 100644 --- a/pgsql/tables/llx_product_fournisseur.sql +++ b/pgsql/tables/llx_product_fournisseur.sql @@ -28,7 +28,7 @@ create table llx_product_fournisseur ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "fk_product" integer, "fk_soc" integer, diff --git a/pgsql/tables/llx_product_fournisseur_price.sql b/pgsql/tables/llx_product_fournisseur_price.sql index 5eccffa199d..915ecf9e8f9 100644 --- a/pgsql/tables/llx_product_fournisseur_price.sql +++ b/pgsql/tables/llx_product_fournisseur_price.sql @@ -28,7 +28,7 @@ create table llx_product_fournisseur_price ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "fk_product" integer, "fk_soc" integer, -- lien sur llx_societe diff --git a/pgsql/tables/llx_product_price.sql b/pgsql/tables/llx_product_price.sql index 76649b0f4cc..8696878d371 100644 --- a/pgsql/tables/llx_product_price.sql +++ b/pgsql/tables/llx_product_price.sql @@ -29,10 +29,10 @@ create table llx_product_price rowid SERIAL PRIMARY KEY, "tms" timestamp, "fk_product" integer NOT NULL, - "date_price" datetime, + "date_price" timestamp, "price" double, "tva_tx" double DEFAULT 19.6, "fk_user_author" integer, - "envente" tinyint DEFAULT 1 + "envente" smallint DEFAULT 1 ); diff --git a/pgsql/tables/llx_projet.sql b/pgsql/tables/llx_projet.sql index c0086e2c61c..f049d99c131 100644 --- a/pgsql/tables/llx_projet.sql +++ b/pgsql/tables/llx_projet.sql @@ -37,5 +37,6 @@ create table llx_projet "title" varchar(255), "fk_user_resp" integer, -- responsable du projet "fk_user_creat" integer, -- createur du projet - "note" text + "note" text, + "UNIQUE" INDEX(ref) ); diff --git a/pgsql/tables/llx_propal.sql b/pgsql/tables/llx_propal.sql index d5c83d49ae8..06907653c21 100644 --- a/pgsql/tables/llx_propal.sql +++ b/pgsql/tables/llx_propal.sql @@ -31,10 +31,10 @@ create table llx_propal "fk_soc_contact" integer, "fk_projet" integer DEFAULT 0, -- projet auquel est rattache la propale "ref" varchar(30) NOT NULL, -- propal number - "datec" datetime, -- date de creation - "fin_validite" datetime, -- date de fin de validite - "date_valid" datetime, -- date de validation - "date_cloture" datetime, -- date de cloture + "datec" timestamp, -- date de creation + "fin_validite" timestamp, -- date de fin de validite + "date_valid" timestamp, -- date de validation + "date_cloture" timestamp, -- date de cloture "datep" date, -- date de la propal "fk_user_author" integer, -- createur de la propale "fk_user_valid" integer, -- valideur de la propale @@ -47,4 +47,5 @@ create table llx_propal "total" real DEFAULT 0, "note" text, "model_pdf" varchar(50), -4294967294); + "UNIQUE" INDEX (ref) +); diff --git a/pgsql/tables/llx_rights_def.sql b/pgsql/tables/llx_rights_def.sql index 1756f50b686..c5b5c1258ca 100644 --- a/pgsql/tables/llx_rights_def.sql +++ b/pgsql/tables/llx_rights_def.sql @@ -32,6 +32,6 @@ create table llx_rights_def "perms" varchar(50), "subperms" varchar(50), "type" varchar(1) CHECK (type IN ('r','w','m','d','a')) , - "bydefault" tinyint DEFAULT 0 + "bydefault" smallint DEFAULT 0 ); diff --git a/pgsql/tables/llx_so_gr.sql b/pgsql/tables/llx_so_gr.sql index 71b680deb61..46d4a8d80c0 100644 --- a/pgsql/tables/llx_so_gr.sql +++ b/pgsql/tables/llx_so_gr.sql @@ -31,5 +31,6 @@ create table llx_so_gr ( rowid SERIAL PRIMARY KEY, "fk_soc" integer, - "fk_groupe" integer + "fk_groupe" integer, + "UNIQUE"(fk_soc, fk_groupe) ); diff --git a/pgsql/tables/llx_soc_events.sql b/pgsql/tables/llx_soc_events.sql index d654836d33a..337efe12b06 100644 --- a/pgsql/tables/llx_soc_events.sql +++ b/pgsql/tables/llx_soc_events.sql @@ -28,8 +28,8 @@ create table llx_soc_events ( rowid SERIAL PRIMARY KEY, -- public id "fk_soc" int NOT NULL, -- - "dateb" datetime NOT NULL, -- begin date - "datee" datetime NOT NULL, -- end date + "dateb" timestamp NOT NULL, -- begin date + "datee" timestamp NOT NULL, -- end date "title" varchar(100) NOT NULL, "url" varchar(255), "description" text diff --git a/pgsql/tables/llx_soc_recontact.sql b/pgsql/tables/llx_soc_recontact.sql index b518d128890..cc27b42faca 100644 --- a/pgsql/tables/llx_soc_recontact.sql +++ b/pgsql/tables/llx_soc_recontact.sql @@ -30,6 +30,6 @@ create table llx_soc_recontact ( rowid SERIAL PRIMARY KEY, "fk_soc" integer, - "datere" datetime, + "datere" timestamp, "author" varchar(15) ); diff --git a/pgsql/tables/llx_societe.sql b/pgsql/tables/llx_societe.sql index b6d93633045..8e996072b0d 100644 --- a/pgsql/tables/llx_societe.sql +++ b/pgsql/tables/llx_societe.sql @@ -32,8 +32,8 @@ create table llx_societe "active" smallint DEFAULT 0, -- "parent" integer DEFAULT 0, -- "tms" timestamp, - "datec" datetime, -- creation date - "datea" datetime, -- activation date + "datec" timestamp, -- creation date + "datea" timestamp, -- activation date "nom" varchar(60), -- company name "code_client" varchar(15), -- code client "code_compta" varchar(15), -- code compta @@ -65,5 +65,6 @@ create table llx_societe "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 + "UNIQUE" INDEX(prefix_comm) ); diff --git a/pgsql/tables/llx_societe_commerciaux.sql b/pgsql/tables/llx_societe_commerciaux.sql index 34395529776..992ea5bf32f 100644 --- a/pgsql/tables/llx_societe_commerciaux.sql +++ b/pgsql/tables/llx_societe_commerciaux.sql @@ -29,6 +29,7 @@ create table llx_societe_commerciaux ( rowid SERIAL PRIMARY KEY, "fk_soc" integer, - "fk_user" integer + "fk_user" integer, + "UNIQUE" INDEX(fk_soc, fk_user) ); diff --git a/pgsql/tables/llx_societe_remise.sql b/pgsql/tables/llx_societe_remise.sql index e86569f02f8..1585cb1ecc9 100644 --- a/pgsql/tables/llx_societe_remise.sql +++ b/pgsql/tables/llx_societe_remise.sql @@ -32,7 +32,7 @@ create table llx_societe_remise rowid SERIAL PRIMARY KEY, "fk_soc" integer NOT NULL, "tms" timestamp, - "datec" datetime, -- creation date + "datec" timestamp, -- creation date "fk_user_author" integer, -- utilisateur qui a créé l'info "remise_client" real DEFAULT 0, -- remise systématique pour le client "note" text diff --git a/pgsql/tables/llx_societe_remise_except.sql b/pgsql/tables/llx_societe_remise_except.sql index ae6d10f3131..ede497e4e49 100644 --- a/pgsql/tables/llx_societe_remise_except.sql +++ b/pgsql/tables/llx_societe_remise_except.sql @@ -32,7 +32,7 @@ create table llx_societe_remise_except ( rowid SERIAL PRIMARY KEY, "fk_soc" integer NOT NULL, -- client - "datec" datetime, + "datec" timestamp, "amount_ht" real NOT NULL, "fk_user" integer NOT NULL, "fk_facture" integer, diff --git a/pgsql/tables/llx_societe_rib.sql b/pgsql/tables/llx_societe_rib.sql index 2be2e4cdc83..76f243032c1 100644 --- a/pgsql/tables/llx_societe_rib.sql +++ b/pgsql/tables/llx_societe_rib.sql @@ -32,7 +32,7 @@ create table llx_societe_rib ( rowid SERIAL PRIMARY KEY, "fk_soc" integer NOT NULL, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "label" varchar(30), "bank" varchar(255), diff --git a/pgsql/tables/llx_socpeople.sql b/pgsql/tables/llx_socpeople.sql index bd854e50023..8a9b0474758 100644 --- a/pgsql/tables/llx_socpeople.sql +++ b/pgsql/tables/llx_socpeople.sql @@ -27,7 +27,7 @@ create table llx_socpeople ( idp SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "fk_soc" integer, -- lien vers la societe "civilite" varchar(6), diff --git a/pgsql/tables/llx_socstatutlog.sql b/pgsql/tables/llx_socstatutlog.sql index f16c77682d3..1a1f4f0a271 100644 --- a/pgsql/tables/llx_socstatutlog.sql +++ b/pgsql/tables/llx_socstatutlog.sql @@ -27,7 +27,7 @@ create table llx_socstatutlog ( id SERIAL PRIMARY KEY, - "datel" datetime, + "datel" timestamp, "fk_soc" integer, "fk_statut" integer, "author" varchar(30) diff --git a/pgsql/tables/llx_stock_mouvement.sql b/pgsql/tables/llx_stock_mouvement.sql index 04287952cbf..fb3aeae360b 100644 --- a/pgsql/tables/llx_stock_mouvement.sql +++ b/pgsql/tables/llx_stock_mouvement.sql @@ -29,7 +29,7 @@ create table llx_stock_mouvement ( rowid SERIAL PRIMARY KEY, "tms" timestamp, - "datem" datetime, + "datem" timestamp, "fk_product" integer NOT NULL, "fk_entrepot" integer NOT NULL, "value" integer, diff --git a/pgsql/tables/llx_todocomm.sql b/pgsql/tables/llx_todocomm.sql index 6ef18c3f745..81095846edb 100644 --- a/pgsql/tables/llx_todocomm.sql +++ b/pgsql/tables/llx_todocomm.sql @@ -30,7 +30,7 @@ create table llx_todocomm ( id SERIAL PRIMARY KEY, - "datea" datetime, -- date de l'action + "datea" timestamp, -- date de l'action "label" varchar(50), -- libelle de l'action "fk_user_action" integer, -- id de la personne qui doit effectuer l'action "fk_user_author" integer, -- id auteur de l'action diff --git a/pgsql/tables/llx_user.sql b/pgsql/tables/llx_user.sql index 720f9231e54..11fe57ed41e 100644 --- a/pgsql/tables/llx_user.sql +++ b/pgsql/tables/llx_user.sql @@ -28,7 +28,7 @@ create table llx_user ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, "login" varchar(8), "pass" varchar(32), @@ -42,5 +42,6 @@ create table llx_user "module_compta" smallint DEFAULT 1, "fk_societe" integer DEFAULT 0, "fk_socpeople" integer DEFAULT 0, - "note" text + "note" text, + "UNIQUE" INDEX(login) ); diff --git a/pgsql/tables/llx_user_param.sql b/pgsql/tables/llx_user_param.sql index 21914df0965..d1019930332 100644 --- a/pgsql/tables/llx_user_param.sql +++ b/pgsql/tables/llx_user_param.sql @@ -31,5 +31,6 @@ create table llx_user_param "fk_user" integer, "page" varchar(255), "param" varchar(64), - "value" varchar(255) + "value" varchar(255), + "UNIQUE" (fk_user,page,param) ); diff --git a/pgsql/tables/llx_user_rights.sql b/pgsql/tables/llx_user_rights.sql index 883714ad29a..a4b44cb7f0b 100644 --- a/pgsql/tables/llx_user_rights.sql +++ b/pgsql/tables/llx_user_rights.sql @@ -29,6 +29,7 @@ create table llx_user_rights ( rowid SERIAL PRIMARY KEY, "fk_user" integer NOT NULL, - "fk_id" integer NOT NULL + "fk_id" integer NOT NULL, + "UNIQUE"(fk_user,fk_id) ); diff --git a/pgsql/tables/llx_usergroup.sql b/pgsql/tables/llx_usergroup.sql index 6d6e82cec84..87973375ac4 100644 --- a/pgsql/tables/llx_usergroup.sql +++ b/pgsql/tables/llx_usergroup.sql @@ -29,7 +29,8 @@ create table llx_usergroup ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "tms" timestamp, + "nom" varchar(255) NOT NULL UNIQUE, "note" text ); diff --git a/pgsql/tables/llx_usergroup_rights.sql b/pgsql/tables/llx_usergroup_rights.sql index 983be83aaf2..5c47b3cdb97 100644 --- a/pgsql/tables/llx_usergroup_rights.sql +++ b/pgsql/tables/llx_usergroup_rights.sql @@ -29,6 +29,7 @@ create table llx_usergroup_rights ( rowid SERIAL PRIMARY KEY, "fk_usergroup" integer NOT NULL, - "fk_id" integer NOT NULL + "fk_id" integer NOT NULL, + "UNIQUE"(fk_usergroup,fk_id) ); diff --git a/pgsql/tables/llx_usergroup_user.sql b/pgsql/tables/llx_usergroup_user.sql index dd8b94faf82..c3775fe87a3 100644 --- a/pgsql/tables/llx_usergroup_user.sql +++ b/pgsql/tables/llx_usergroup_user.sql @@ -29,5 +29,6 @@ create table llx_usergroup_user ( rowid SERIAL PRIMARY KEY, "fk_user" integer NOT NULL, - "fk_usergroup" integer NOT NULL + "fk_usergroup" integer NOT NULL, + "UNIQUE"(fk_user,fk_usergroup) ); diff --git a/pgsql/tables/llx_ventes.sql b/pgsql/tables/llx_ventes.sql index 553f67b8f40..3d7f4210fee 100644 --- a/pgsql/tables/llx_ventes.sql +++ b/pgsql/tables/llx_ventes.sql @@ -29,8 +29,8 @@ create table llx_ventes rowid SERIAL PRIMARY KEY, "fk_soc" integer NOT NULL, "fk_product" integer NOT NULL, - "dated" datetime, -- date debut - "datef" datetime, -- date fin + "dated" timestamp, -- date debut + "datef" timestamp, -- date fin "price" real, "author" varchar(30), "active" smallint DEFAULT 0 NOT NULL, diff --git a/pgsql/tables/llx_voyage.sql b/pgsql/tables/llx_voyage.sql index e6446cd6fc6..053aac1a363 100644 --- a/pgsql/tables/llx_voyage.sql +++ b/pgsql/tables/llx_voyage.sql @@ -33,10 +33,10 @@ create table llx_voyage ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "dateo" date, -- date operation - "date_depart" datetime, -- date du voyage - "date_arrivee" datetime, -- date du voyage + "date_depart" timestamp, -- date du voyage + "date_arrivee" timestamp, -- date du voyage "amount" real NOT NULL DEFAULT 0, -- prix du billet "reduction" real NOT NULL DEFAULT 0, -- montant de la reduction obtenue "depart" varchar(255), diff --git a/pgsql/tables/llx_voyage_reduc.sql b/pgsql/tables/llx_voyage_reduc.sql index ae23b340640..c5a3f55e3cf 100644 --- a/pgsql/tables/llx_voyage_reduc.sql +++ b/pgsql/tables/llx_voyage_reduc.sql @@ -27,7 +27,7 @@ create table llx_voyage_reduc ( rowid SERIAL PRIMARY KEY, - "datec" datetime, + "datec" timestamp, "datev" date, -- date de valeur "date_debut" date, -- date operation "date_fin" date,