vr-migrations 1.0.27 → 1.0.28
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.
|
@@ -11,7 +11,75 @@ module.exports = {
|
|
|
11
11
|
const nid_3 = await bcrypt.hash("1199900000000003", 10);
|
|
12
12
|
const nid_4 = await bcrypt.hash("1199900000000004", 10);
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// STEP 1: Create users FIRST (without primaryPhoneId initially)
|
|
15
|
+
await queryInterface.bulkInsert("users", [
|
|
16
|
+
{
|
|
17
|
+
id: "aaaaaaa1-aaaa-aaaa-aaaa-aaaaaaaaaaa1",
|
|
18
|
+
firstName: "Jean",
|
|
19
|
+
lastName: "Rider",
|
|
20
|
+
nationalId: nid_1,
|
|
21
|
+
jacketId: "JACKET-R-001",
|
|
22
|
+
plateNumber: "RAD101A",
|
|
23
|
+
securityClearanceId: "11111111-1111-1111-1111-111111111111", // RIDER
|
|
24
|
+
primaryPhoneId: null, // Will update after phone_contacts are created
|
|
25
|
+
isActive: true,
|
|
26
|
+
lastLoginAt: null,
|
|
27
|
+
createdAt: now,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "aaaaaaa1-aaaa-aaaa-aaaa-aaaaaaaaaaa2",
|
|
31
|
+
firstName: "Jane",
|
|
32
|
+
lastName: "Passenger",
|
|
33
|
+
email: "jane@passenger.com",
|
|
34
|
+
password: passwordHash,
|
|
35
|
+
securityClearanceId: "22222222-2222-2222-2222-222222222222", // PASSENGER
|
|
36
|
+
primaryPhoneId: null,
|
|
37
|
+
isActive: true,
|
|
38
|
+
lastLoginAt: null,
|
|
39
|
+
createdAt: now,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "aaaaaaa2-aaaa-aaaa-aaaa-aaaaaaaaaaa3",
|
|
43
|
+
firstName: "Alice",
|
|
44
|
+
lastName: "Agent",
|
|
45
|
+
nationalId: nid_2,
|
|
46
|
+
email: "alice@agent.com",
|
|
47
|
+
password: passwordHash,
|
|
48
|
+
securityClearanceId: "33333333-3333-3333-3333-333333333333", // AGENT
|
|
49
|
+
primaryPhoneId: null,
|
|
50
|
+
isActive: true,
|
|
51
|
+
lastLoginAt: null,
|
|
52
|
+
createdAt: now,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "aaaaaaa3-aaaa-aaaa-aaaa-aaaaaaaaaaa4",
|
|
56
|
+
firstName: "Eric",
|
|
57
|
+
lastName: "Admin",
|
|
58
|
+
nationalId: nid_3,
|
|
59
|
+
email: "eric@admin.com",
|
|
60
|
+
password: passwordHash,
|
|
61
|
+
securityClearanceId: "44444444-4444-4444-4444-444444444444", // ADMIN
|
|
62
|
+
primaryPhoneId: null,
|
|
63
|
+
isActive: true,
|
|
64
|
+
lastLoginAt: null,
|
|
65
|
+
createdAt: now,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "aaaaaaa4-aaaa-aaaa-aaaa-aaaaaaaaaaa5",
|
|
69
|
+
firstName: "Super",
|
|
70
|
+
lastName: "Admin",
|
|
71
|
+
email: "super@admin.com",
|
|
72
|
+
password: passwordHash,
|
|
73
|
+
nationalId: nid_4,
|
|
74
|
+
securityClearanceId: "55555555-5555-5555-5555-555555555555", // SUPER_ADMIN
|
|
75
|
+
primaryPhoneId: null,
|
|
76
|
+
isActive: true,
|
|
77
|
+
lastLoginAt: null,
|
|
78
|
+
createdAt: now,
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
// STEP 2: Create phone contacts (now users exist)
|
|
15
83
|
await queryInterface.bulkInsert("phone_contacts", [
|
|
16
84
|
{
|
|
17
85
|
id: "11111111-1111-1111-1111-111111111111",
|
|
@@ -21,7 +89,7 @@ module.exports = {
|
|
|
21
89
|
verifiedAt: now,
|
|
22
90
|
isPrimary: true,
|
|
23
91
|
isActive: true,
|
|
24
|
-
metadata: Sequelize.literal("'{}'::jsonb"),
|
|
92
|
+
metadata: Sequelize.literal("'{}'::jsonb"),
|
|
25
93
|
createdAt: now,
|
|
26
94
|
updatedAt: now,
|
|
27
95
|
},
|
|
@@ -75,73 +143,32 @@ module.exports = {
|
|
|
75
143
|
},
|
|
76
144
|
]);
|
|
77
145
|
|
|
78
|
-
//
|
|
79
|
-
await queryInterface.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: "aaaaaaa2-aaaa-aaaa-aaaa-aaaaaaaaaaa3",
|
|
107
|
-
firstName: "Alice",
|
|
108
|
-
lastName: "Agent",
|
|
109
|
-
nationalId: nid_2,
|
|
110
|
-
email: "alice@agent.com",
|
|
111
|
-
password: passwordHash,
|
|
112
|
-
securityClearanceId: "33333333-3333-3333-3333-333333333333", // AGENT
|
|
113
|
-
primaryPhoneId: "33333333-3333-3333-3333-333333333333",
|
|
114
|
-
isActive: true,
|
|
115
|
-
lastLoginAt: null,
|
|
116
|
-
createdAt: now,
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
id: "aaaaaaa3-aaaa-aaaa-aaaa-aaaaaaaaaaa4",
|
|
120
|
-
firstName: "Eric",
|
|
121
|
-
lastName: "Admin",
|
|
122
|
-
nationalId: nid_3,
|
|
123
|
-
email: "eric@admin.com",
|
|
124
|
-
password: passwordHash,
|
|
125
|
-
securityClearanceId: "44444444-4444-4444-4444-444444444444", // ADMIN
|
|
126
|
-
primaryPhoneId: "44444444-4444-4444-4444-444444444444",
|
|
127
|
-
isActive: true,
|
|
128
|
-
lastLoginAt: null,
|
|
129
|
-
createdAt: now,
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
id: "aaaaaaa4-aaaa-aaaa-aaaa-aaaaaaaaaaa5",
|
|
133
|
-
firstName: "Super",
|
|
134
|
-
lastName: "Admin",
|
|
135
|
-
email: "super@admin.com",
|
|
136
|
-
password: passwordHash,
|
|
137
|
-
nationalId: nid_4,
|
|
138
|
-
securityClearanceId: "55555555-5555-5555-5555-555555555555", // SUPER_ADMIN
|
|
139
|
-
primaryPhoneId: "55555555-5555-5555-5555-555555555555",
|
|
140
|
-
isActive: true,
|
|
141
|
-
lastLoginAt: null,
|
|
142
|
-
createdAt: now,
|
|
143
|
-
},
|
|
144
|
-
]);
|
|
146
|
+
// STEP 3: Update users with their primaryPhoneId
|
|
147
|
+
await queryInterface.bulkUpdate(
|
|
148
|
+
"users",
|
|
149
|
+
{ primaryPhoneId: "11111111-1111-1111-1111-111111111111" },
|
|
150
|
+
{ id: "aaaaaaa1-aaaa-aaaa-aaaa-aaaaaaaaaaa1" }
|
|
151
|
+
);
|
|
152
|
+
await queryInterface.bulkUpdate(
|
|
153
|
+
"users",
|
|
154
|
+
{ primaryPhoneId: "22222222-2222-2222-2222-222222222222" },
|
|
155
|
+
{ id: "aaaaaaa1-aaaa-aaaa-aaaa-aaaaaaaaaaa2" }
|
|
156
|
+
);
|
|
157
|
+
await queryInterface.bulkUpdate(
|
|
158
|
+
"users",
|
|
159
|
+
{ primaryPhoneId: "33333333-3333-3333-3333-333333333333" },
|
|
160
|
+
{ id: "aaaaaaa2-aaaa-aaaa-aaaa-aaaaaaaaaaa3" }
|
|
161
|
+
);
|
|
162
|
+
await queryInterface.bulkUpdate(
|
|
163
|
+
"users",
|
|
164
|
+
{ primaryPhoneId: "44444444-4444-4444-4444-444444444444" },
|
|
165
|
+
{ id: "aaaaaaa3-aaaa-aaaa-aaaa-aaaaaaaaaaa4" }
|
|
166
|
+
);
|
|
167
|
+
await queryInterface.bulkUpdate(
|
|
168
|
+
"users",
|
|
169
|
+
{ primaryPhoneId: "55555555-5555-5555-5555-555555555555" },
|
|
170
|
+
{ id: "aaaaaaa4-aaaa-aaaa-aaaa-aaaaaaaaaaa5" }
|
|
171
|
+
);
|
|
145
172
|
},
|
|
146
173
|
|
|
147
174
|
async down(queryInterface) {
|