@itleanchatbot/shared-models-js-postgres 2.8.7 → 2.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itleanchatbot/shared-models-js-postgres",
3
- "version": "2.8.7",
3
+ "version": "2.8.8",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -0,0 +1,98 @@
1
+
2
+
3
+ module.exports = {
4
+ up: async (queryInterface) => {
5
+ const departmentPermissionId = await queryInterface.rawSelect(
6
+ 'Permissions',
7
+ { where: { permissionCode: 'crud_departments' } },
8
+ ['id']
9
+ )
10
+
11
+ const subDepartmentPermissionId = await queryInterface.rawSelect(
12
+ 'Permissions',
13
+ { where: { permissionCode: 'crud_subDepartments' } },
14
+ ['id']
15
+ )
16
+
17
+ const linePermissionId = await queryInterface.rawSelect(
18
+ 'Permissions',
19
+ { where: { permissionCode: 'crud_lines' } },
20
+ ['id']
21
+ )
22
+
23
+ const branchPermissionId = await queryInterface.rawSelect(
24
+ 'Permissions',
25
+ { where: { permissionCode: 'crud_branches' } },
26
+ ['id']
27
+ )
28
+
29
+ const adminProfileId = await queryInterface.rawSelect(
30
+ 'Profiles',
31
+ { where: { name: 'Administrador' } },
32
+ ['id']
33
+ )
34
+
35
+
36
+ return queryInterface.bulkInsert('Profiles_Permissions', [
37
+ {
38
+ ProfileId: adminProfileId,
39
+ PermissionId: departmentPermissionId,
40
+ createdAt: new Date(),
41
+ updatedAt: new Date(),
42
+ },
43
+ {
44
+ ProfileId: adminProfileId,
45
+ PermissionId: subDepartmentPermissionId,
46
+ createdAt: new Date(),
47
+ updatedAt: new Date(),
48
+ },
49
+ {
50
+ ProfileId: adminProfileId,
51
+ PermissionId: linePermissionId,
52
+ createdAt: new Date(),
53
+ updatedAt: new Date(),
54
+ },
55
+ {
56
+ ProfileId: adminProfileId,
57
+ PermissionId: branchPermissionId,
58
+ createdAt: new Date(),
59
+ updatedAt: new Date(),
60
+ },
61
+ ])
62
+ },
63
+ down: async (queryInterface) => {
64
+ const departmentPermissionId = await queryInterface.rawSelect(
65
+ 'Permissions',
66
+ { where: { permissionCode: 'crud_departments' } },
67
+ ['id']
68
+ )
69
+
70
+ const subDepartmentPermissionId = await queryInterface.rawSelect(
71
+ 'Permissions',
72
+ { where: { permissionCode: 'crud_subDepartments' } },
73
+ ['id']
74
+ )
75
+
76
+ const linePermissionId = await queryInterface.rawSelect(
77
+ 'Permissions',
78
+ { where: { permissionCode: 'crud_lines' } },
79
+ ['id']
80
+ )
81
+
82
+ const branchPermissionId = await queryInterface.rawSelect(
83
+ 'Permissions',
84
+ { where: { permissionCode: 'crud_branches' } },
85
+ ['id']
86
+ )
87
+
88
+ const adminProfileId = await queryInterface.rawSelect(
89
+ 'Profiles',
90
+ { where: { name: 'Administrador' } },
91
+ ['id']
92
+ )
93
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: departmentPermissionId }, {})
94
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: subDepartmentPermissionId }, {})
95
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: linePermissionId }, {})
96
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: branchPermissionId }, {})
97
+ },
98
+ }