From e1207edb951a544589c01d030cef47a8ad59aa4b Mon Sep 17 00:00:00 2001 From: Bernat Date: Mon, 4 Feb 2019 07:42:12 +0100 Subject: [PATCH] #9699 update structure and create new model --- back/model-config.json | 3 ++ back/models/user-table-configuration.json | 30 +++++++++++++++++++ .../1.2-CHECK/23-userTableConfiguration.sql | 18 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 back/models/user-table-configuration.json create mode 100644 services/db/install/changes/1.2-CHECK/23-userTableConfiguration.sql diff --git a/back/model-config.json b/back/model-config.json index c66cdb421f..7a7b7af56c 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -37,6 +37,9 @@ }, "Vehicle": { "dataSource": "vn" + }, + "UserTableConfiguration": { + "dataSource": "vn" } } diff --git a/back/models/user-table-configuration.json b/back/models/user-table-configuration.json new file mode 100644 index 0000000000..084d64e271 --- /dev/null +++ b/back/models/user-table-configuration.json @@ -0,0 +1,30 @@ +{ + "name": "UserTableConfiguration", + "base": "VnModel", + "options": { + "mysql": { + "table": "salix.userTableConfiguration" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "required": true + }, + "tableCode": { + "type": "String", + "required": true + }, + "configuration": { + "type": "String" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } +} diff --git a/services/db/install/changes/1.2-CHECK/23-userTableConfiguration.sql b/services/db/install/changes/1.2-CHECK/23-userTableConfiguration.sql new file mode 100644 index 0000000000..089b38a36e --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/23-userTableConfiguration.sql @@ -0,0 +1,18 @@ +CREATE TABLE `salix`.`userTableConfiguration` ( + `id` INT NOT NULL AUTO_INCREMENT, + `workerFk` INT(11) NOT NULL, + `tableCode` VARCHAR(255) NOT NULL, + `configuration` TEXT NULL, + PRIMARY KEY (`id`)); + + + + +ALTER TABLE `salix`.`userTableConfiguration` +ADD INDEX `fgn_worker_idx` (`workerFk` ASC); +ALTER TABLE `salix`.`userTableConfiguration` +ADD CONSTRAINT `fgn_worker` + FOREIGN KEY (`workerFk`) + REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) + ON DELETE CASCADE + ON UPDATE CASCADE;