Fix creation of fields tms into sql scripts

This commit is contained in:
Laurent Destailleur 2022-01-11 00:55:54 +01:00
parent 564bae453e
commit 00108589fd
23 changed files with 44 additions and 38 deletions

View File

@ -305,6 +305,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$texttoinsert .= "\t".$key." ".$type;
if ($key == 'rowid') {
$texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
} elseif ($type == 'timestamp') {
$texttoinsert .= ' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP';
}
if ($key == 'entity') {
$texttoinsert .= ' DEFAULT 1';

View File

@ -183,7 +183,7 @@ CREATE TABLE llx_workstation_workstation(
entity int DEFAULT 1,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),
@ -201,14 +201,14 @@ ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_st
CREATE TABLE llx_workstation_workstation_resource(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_resource integer,
fk_workstation integer
) ENGINE=innodb;
CREATE TABLE llx_workstation_workstation_usergroup(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_usergroup integer,
fk_workstation integer
) ENGINE=innodb;
@ -264,7 +264,7 @@ create table llx_payment_vat
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_tva integer,
datec datetime, -- date de creation
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
datep datetime, -- payment date
amount double(24,8) DEFAULT 0,
fk_typepaiement integer NOT NULL,
@ -431,7 +431,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer,
fk_user_modif integer,
last_main_doc varchar(255),
@ -466,7 +466,7 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_
create table llx_eventorganization_conferenceorboothattendee_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
@ -510,7 +510,7 @@ CREATE TABLE llx_partnership(
reason_decline_or_cancel text NULL,
date_creation datetime NOT NULL,
fk_user_creat integer NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_modif integer,
note_private text,
note_public text,
@ -533,7 +533,7 @@ ALTER TABLE llx_partnership ADD INDEX idx_partnership_fk_member (fk_member);
create table llx_partnership_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
@ -568,7 +568,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
ref varchar(128) NOT NULL,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
last_main_doc varchar(255),
fk_user_creat integer NOT NULL,
fk_user_modif integer,
@ -592,7 +592,7 @@ ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN url varchar(255);
create table llx_knowledgemanagement_knowledgerecord_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -193,7 +193,7 @@ CREATE TABLE llx_hrm_evaluation
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),
@ -211,7 +211,7 @@ ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_status (status);
create table llx_hrm_evaluation_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
@ -224,7 +224,7 @@ CREATE TABLE llx_hrm_evaluationdet
-- BEGIN MODULEBUILDER FIELDS
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
fk_skill integer NOT NULL,
@ -243,7 +243,7 @@ ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_evaluation
create table llx_hrm_evaluationdet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
@ -258,7 +258,7 @@ CREATE TABLE llx_hrm_job
label varchar(255) NOT NULL,
description text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deplacement varchar(255),
note_public text,
note_private text,
@ -273,7 +273,7 @@ ALTER TABLE llx_hrm_job ADD INDEX idx_hrm_job_label (label);
create table llx_hrm_job_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
@ -287,7 +287,7 @@ CREATE TABLE llx_hrm_job_user(
-- ref varchar(128) NOT NULL,
description text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_contrat integer,
fk_user integer NOT NULL,
fk_job integer NOT NULL,
@ -313,7 +313,7 @@ CREATE TABLE llx_hrm_skill
label varchar(255),
description text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
required_level integer NOT NULL,
@ -331,7 +331,7 @@ ALTER TABLE llx_hrm_skill ADD INDEX idx_hrm_skill_skill_type (skill_type);
create table llx_hrm_skill_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -28,7 +28,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer,
fk_user_modif integer,
last_main_doc varchar(255),

View File

@ -16,7 +16,7 @@
create table llx_eventorganization_conferenceorboothattendee_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -25,7 +25,7 @@ CREATE TABLE llx_hrm_evaluation(
note_public text,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),

View File

@ -18,7 +18,7 @@
create table llx_hrm_evaluation_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -20,7 +20,7 @@ CREATE TABLE llx_hrm_evaluationdet
(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
fk_skill integer NOT NULL,

View File

@ -18,7 +18,7 @@
create table llx_hrm_evaluationdet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -22,7 +22,7 @@ CREATE TABLE llx_hrm_job(
label varchar(255) NOT NULL,
description text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deplacement varchar(255),
note_public text,
note_private text,

View File

@ -18,7 +18,7 @@
create table llx_hrm_job_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -21,7 +21,7 @@ CREATE TABLE llx_hrm_job_user(
-- ref varchar(128) NOT NULL,
description text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_contrat integer,
fk_user integer NOT NULL,
fk_job integer NOT NULL,

View File

@ -22,7 +22,7 @@ CREATE TABLE llx_hrm_skill(
label varchar(255),
description text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
required_level integer NOT NULL,

View File

@ -18,7 +18,7 @@
create table llx_hrm_skill_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -28,5 +28,5 @@ create table llx_intracommreport
content_xml text,
type_export varchar(10),
datec datetime,
tms timestamp
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)ENGINE=innodb;

View File

@ -20,7 +20,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord(
entity integer DEFAULT 1 NOT NULL, -- multi company id
ref varchar(128) NOT NULL,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
last_main_doc varchar(255),
lang varchar(6),
fk_user_creat integer NOT NULL,

View File

@ -16,7 +16,7 @@
create table llx_knowledgemanagement_knowledgerecord_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -29,7 +29,7 @@ CREATE TABLE llx_partnership(
reason_decline_or_cancel text NULL,
date_creation datetime NOT NULL,
fk_user_creat integer NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_modif integer,
note_private text,
note_public text,

View File

@ -22,7 +22,7 @@ create table llx_payment_vat
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_tva integer,
datec datetime, -- date de creation
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
datep datetime, -- payment date
amount double(24,8) DEFAULT 0,
fk_typepaiement integer NOT NULL,

View File

@ -24,7 +24,7 @@ CREATE TABLE llx_workstation_workstation(
entity int DEFAULT 1,
note_private text,
date_creation datetime NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14),

View File

@ -16,7 +16,7 @@
CREATE TABLE llx_workstation_workstation_resource(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_resource integer,
fk_workstation integer
) ENGINE=innodb;

View File

@ -16,7 +16,7 @@
CREATE TABLE llx_workstation_workstation_usergroup(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
tms timestamp,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_usergroup integer,
fk_workstation integer
) ENGINE=innodb;

View File

@ -218,6 +218,10 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase
//print __METHOD__." Result for checking we don't have 'integer(' = ".$result."\n";
$this->assertTrue($result===false, 'Found value in parenthesis after the integer. It must be integer not integer(x) into '.$file.'. Bad.');
$result=strpos($filecontent, 'timestamp,');
//print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n";
$this->assertTrue($result===false, 'Found type timestamp with option DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP after into '.$file.'. Bad.');
if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') {
// Test for migration files only
} elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data') {