vr-migrations 1.0.27 → 1.0.29
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.
|
@@ -7,7 +7,7 @@ module.exports = {
|
|
|
7
7
|
type: Sequelize.UUID,
|
|
8
8
|
defaultValue: Sequelize.UUIDV4,
|
|
9
9
|
primaryKey: true,
|
|
10
|
-
allowNull: false
|
|
10
|
+
allowNull: false,
|
|
11
11
|
},
|
|
12
12
|
|
|
13
13
|
userId: {
|
|
@@ -15,10 +15,10 @@ module.exports = {
|
|
|
15
15
|
allowNull: false,
|
|
16
16
|
references: {
|
|
17
17
|
model: "users",
|
|
18
|
-
key: "id"
|
|
18
|
+
key: "id",
|
|
19
19
|
},
|
|
20
20
|
onUpdate: "CASCADE",
|
|
21
|
-
onDelete: "RESTRICT"
|
|
21
|
+
onDelete: "RESTRICT",
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
devicePaymentPlanId: {
|
|
@@ -26,15 +26,15 @@ module.exports = {
|
|
|
26
26
|
allowNull: false,
|
|
27
27
|
references: {
|
|
28
28
|
model: "device_payment_plans",
|
|
29
|
-
key: "id"
|
|
29
|
+
key: "id",
|
|
30
30
|
},
|
|
31
31
|
onUpdate: "CASCADE",
|
|
32
|
-
onDelete: "RESTRICT"
|
|
32
|
+
onDelete: "RESTRICT",
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
transactionId: {
|
|
36
36
|
type: Sequelize.UUID,
|
|
37
|
-
allowNull: true
|
|
37
|
+
allowNull: true,
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
idempotencyKeyId: {
|
|
@@ -42,50 +42,50 @@ module.exports = {
|
|
|
42
42
|
allowNull: true,
|
|
43
43
|
references: {
|
|
44
44
|
model: "idempotency_records",
|
|
45
|
-
key: "id"
|
|
45
|
+
key: "id",
|
|
46
46
|
},
|
|
47
47
|
onUpdate: "CASCADE",
|
|
48
|
-
onDelete: "SET NULL"
|
|
48
|
+
onDelete: "SET NULL",
|
|
49
49
|
},
|
|
50
50
|
|
|
51
51
|
amount: {
|
|
52
52
|
type: Sequelize.FLOAT,
|
|
53
|
-
allowNull: false
|
|
53
|
+
allowNull: false,
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
provider: {
|
|
57
57
|
type: Sequelize.ENUM("mtn_momo", "airtel_money"),
|
|
58
|
-
allowNull: false
|
|
58
|
+
allowNull: false,
|
|
59
59
|
},
|
|
60
60
|
|
|
61
61
|
providerReference: {
|
|
62
62
|
type: Sequelize.STRING,
|
|
63
|
-
allowNull: true
|
|
63
|
+
allowNull: true,
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
status: {
|
|
67
|
-
type: Sequelize.ENUM("
|
|
67
|
+
type: Sequelize.ENUM("PENDING", "SUCCESSFUL", "FAILED"),
|
|
68
68
|
allowNull: false,
|
|
69
|
-
defaultValue: "
|
|
69
|
+
defaultValue: "PENDING",
|
|
70
70
|
},
|
|
71
71
|
|
|
72
72
|
metadata: {
|
|
73
73
|
type: Sequelize.JSONB,
|
|
74
74
|
allowNull: false,
|
|
75
|
-
defaultValue: {}
|
|
75
|
+
defaultValue: {},
|
|
76
76
|
},
|
|
77
77
|
|
|
78
78
|
createdAt: {
|
|
79
79
|
type: Sequelize.DATE,
|
|
80
80
|
allowNull: false,
|
|
81
|
-
defaultValue: Sequelize.fn("NOW")
|
|
81
|
+
defaultValue: Sequelize.fn("NOW"),
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
updatedAt: {
|
|
85
85
|
type: Sequelize.DATE,
|
|
86
86
|
allowNull: false,
|
|
87
|
-
defaultValue: Sequelize.fn("NOW")
|
|
88
|
-
}
|
|
87
|
+
defaultValue: Sequelize.fn("NOW"),
|
|
88
|
+
},
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
await queryInterface.addIndex("payments", ["userId"]);
|
|
@@ -102,5 +102,5 @@ module.exports = {
|
|
|
102
102
|
await queryInterface.sequelize.query(
|
|
103
103
|
'DROP TYPE IF EXISTS "enum_payments_status";'
|
|
104
104
|
);
|
|
105
|
-
}
|
|
105
|
+
},
|
|
106
106
|
};
|
|
@@ -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) {
|