From 7a879f5431eaeeac38ce3a7eb0a7e3943b1f37bf Mon Sep 17 00:00:00 2001 From: Bernat Date: Mon, 28 Jan 2019 09:52:53 +0100 Subject: [PATCH] #996, new model personDepartment --- back/model-config.json | 10 ++++-- back/models/person-department.json | 31 +++++++++++++++++++ .../changes/1.2-CHECK/19-personDepartment.sql | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 back/models/person-department.json diff --git a/back/model-config.json b/back/model-config.json index 15725b9aa..fa412618d 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -43,5 +43,11 @@ }, "PersonMedia": { "dataSource": "vn" - } -} \ No newline at end of file + }, + "PersonDepartment": { + "dataSource": "vn" + } +} + + + diff --git a/back/models/person-department.json b/back/models/person-department.json new file mode 100644 index 000000000..246fa4f5d --- /dev/null +++ b/back/models/person-department.json @@ -0,0 +1,31 @@ +{ + "name": "PersonDepartment", + "base": "VnModel", + "options": { + "mysql": { + "table": "personDepartment" + } + }, + "properties": { + "name": { + "type": "String" + }, + "firstName": { + "type": "String" + }, + "workerFk": { + "id": true, + "type": "Number" + }, + "department": { + "type": "Number" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } +} diff --git a/services/db/install/changes/1.2-CHECK/19-personDepartment.sql b/services/db/install/changes/1.2-CHECK/19-personDepartment.sql index 0f98bc539..523743326 100644 --- a/services/db/install/changes/1.2-CHECK/19-personDepartment.sql +++ b/services/db/install/changes/1.2-CHECK/19-personDepartment.sql @@ -5,7 +5,7 @@ CREATE SQL SECURITY DEFINER VIEW `vn`.`personDepartment` AS SELECT - `p`.`id_trabajador` AS `id_trabajador`, + `p`.`id_trabajador` AS `workerFk`, `p`.`name` AS `name`, `p`.`firstname` AS `firstname`, `d`.`name` AS `department`