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`