dip-dobit-shared-model 1.0.9 → 1.0.11
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/.vscode/settings.json +3 -0
- package/migrations/20260507180000-add-field-to-dobituser-table.js +0 -19
- package/migrations/20260512115000-add-appUserId-to-Transactions.js +25 -0
- package/migrations/20260513121000-add-fields-to-DobitUser.js +40 -0
- package/migrations/20260516013000-remove-dobitUserId-from-DobitUserOTPs-table.js +25 -0
- package/migrations/20260516013500-drop-foreignKey-in-DobitUserOTP-table.js +30 -0
- package/migrations/20260516014000-add-username-to-DobitUserOTP-table.js +20 -0
- package/models/dobitUser.js +15 -0
- package/models/dobitUserOTP.js +5 -22
- package/package.json +1 -1
- /package/migrations/{20260512112000-add-new-fields-to-DobitUsers.js → 20260512114000-add-new-fields-to-DobitUsers.js} +0 -0
|
@@ -36,22 +36,3 @@ module.exports = {
|
|
|
36
36
|
await queryInterface.removeColumn("DobitUsers", "pushNotificationId");
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
// "use strict";
|
|
41
|
-
|
|
42
|
-
// module.exports = {
|
|
43
|
-
// up: async (queryInterface, Sequelize) => {
|
|
44
|
-
// await queryInterface.addColumn("DobitUsers", "appUserId", {
|
|
45
|
-
// type: Sequelize.INTEGER.UNSIGNED,
|
|
46
|
-
// allowNull: false,
|
|
47
|
-
// unique: true,
|
|
48
|
-
// after: "dobitUserId",
|
|
49
|
-
// onUpdate: "CASCADE",
|
|
50
|
-
// onDelete: "NO ACTION",
|
|
51
|
-
// });
|
|
52
|
-
// },
|
|
53
|
-
|
|
54
|
-
// down: async (queryInterface, Sequelize) => {
|
|
55
|
-
// await queryInterface.removeColumn("DobitUsers", "appUserId");
|
|
56
|
-
// },
|
|
57
|
-
// };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
const tableDescription = await queryInterface.describeTable("Transactions");
|
|
6
|
+
|
|
7
|
+
if (!tableDescription.appUserId) {
|
|
8
|
+
await queryInterface.addColumn("Transactions", "appUserId", {
|
|
9
|
+
type: Sequelize.BIGINT.UNSIGNED,
|
|
10
|
+
allowNull: true, // temporarily allow null for existing rows
|
|
11
|
+
after: "dobitUserId",
|
|
12
|
+
references: {
|
|
13
|
+
model: "DobitUsers",
|
|
14
|
+
key: "appUserId",
|
|
15
|
+
},
|
|
16
|
+
onUpdate: "CASCADE",
|
|
17
|
+
onDelete: "CASCADE",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
async down(queryInterface) {
|
|
23
|
+
await queryInterface.removeColumn("Transactions", "appUserId");
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
up: async (queryInterface, Sequelize) => {
|
|
5
|
+
const tableDescription = await queryInterface.describeTable("DobitUsers");
|
|
6
|
+
|
|
7
|
+
if (!tableDescription.biometricPublicKey) {
|
|
8
|
+
await queryInterface.addColumn("DobitUsers", "biometricPublicKey", {
|
|
9
|
+
type: Sequelize.STRING(700),
|
|
10
|
+
allowNull: true,
|
|
11
|
+
unique: true,
|
|
12
|
+
after: "biometrics",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!tableDescription.walletBalance) {
|
|
17
|
+
await queryInterface.addColumn("DobitUsers", "walletBalance", {
|
|
18
|
+
type: Sequelize.DECIMAL(10, 2),
|
|
19
|
+
allowNull: true,
|
|
20
|
+
defaultValue: 0.0,
|
|
21
|
+
after: "promotionalOffers",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!tableDescription.currency) {
|
|
26
|
+
await queryInterface.addColumn("DobitUsers", "currency", {
|
|
27
|
+
type: Sequelize.STRING,
|
|
28
|
+
allowNull: true,
|
|
29
|
+
defaultValue: "NGN",
|
|
30
|
+
after: "walletBalance",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
down: async (queryInterface) => {
|
|
36
|
+
await queryInterface.removeColumn("DobitUsers", "biometricPublicKey");
|
|
37
|
+
await queryInterface.removeColumn("DobitUsers", "walletBalance");
|
|
38
|
+
await queryInterface.removeColumn("DobitUsers", "currency");
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
const tableDescription =
|
|
6
|
+
await queryInterface.describeTable("DobitUserOTPs");
|
|
7
|
+
|
|
8
|
+
if (tableDescription.dobitUserId) {
|
|
9
|
+
await queryInterface.removeColumn("DobitUserOTPs", "dobitUserId");
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
async down(queryInterface, Sequelize) {
|
|
14
|
+
const tableDescription =
|
|
15
|
+
await queryInterface.describeTable("DobitUserOTPs");
|
|
16
|
+
|
|
17
|
+
if (!tableDescription.dobitUserId) {
|
|
18
|
+
await queryInterface.addColumn("DobitUserOTPs", "dobitUserId", {
|
|
19
|
+
type: Sequelize.INTEGER.UNSIGNED,
|
|
20
|
+
allowNull: true,
|
|
21
|
+
after: "otpId",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface) {
|
|
5
|
+
// Drop the appUserId foreign key constraint
|
|
6
|
+
try {
|
|
7
|
+
await queryInterface.removeConstraint(
|
|
8
|
+
"DobitUserOTPs",
|
|
9
|
+
"DobitUserOTPs_appUserId_foreign_idx",
|
|
10
|
+
);
|
|
11
|
+
console.log("Constraint dropped successfully");
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.log("Constraint not found, skipping:", e.message);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
async down(queryInterface, Sequelize) {
|
|
18
|
+
await queryInterface.addConstraint("DobitUserOTPs", {
|
|
19
|
+
fields: ["appUserId"],
|
|
20
|
+
type: "foreign key",
|
|
21
|
+
name: "DobitUserOTPs_appUserId_foreign_idx",
|
|
22
|
+
references: {
|
|
23
|
+
table: "DobitUsers",
|
|
24
|
+
field: "appUserId",
|
|
25
|
+
},
|
|
26
|
+
onUpdate: "CASCADE",
|
|
27
|
+
onDelete: "CASCADE",
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
up: async (queryInterface, Sequelize) => {
|
|
5
|
+
const tableDescription =
|
|
6
|
+
await queryInterface.describeTable("DobitUserOTPs");
|
|
7
|
+
|
|
8
|
+
if (!tableDescription.username) {
|
|
9
|
+
await queryInterface.addColumn("DobitUserOTPs", "username", {
|
|
10
|
+
type: Sequelize.STRING,
|
|
11
|
+
allowNull: true,
|
|
12
|
+
after: "email",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
down: async (queryInterface) => {
|
|
18
|
+
await queryInterface.removeColumn("DobitUserOTPs", "username");
|
|
19
|
+
},
|
|
20
|
+
};
|
package/models/dobitUser.js
CHANGED
|
@@ -93,6 +93,11 @@ module.exports = (sequelize) => {
|
|
|
93
93
|
allowNull: false,
|
|
94
94
|
defaultValue: false,
|
|
95
95
|
},
|
|
96
|
+
biometricPublicKey: {
|
|
97
|
+
type: DataTypes.STRING(700),
|
|
98
|
+
allowNull: true,
|
|
99
|
+
unique: true,
|
|
100
|
+
},
|
|
96
101
|
pushNotification: {
|
|
97
102
|
type: DataTypes.BOOLEAN,
|
|
98
103
|
allowNull: false,
|
|
@@ -108,6 +113,16 @@ module.exports = (sequelize) => {
|
|
|
108
113
|
allowNull: false,
|
|
109
114
|
defaultValue: true,
|
|
110
115
|
},
|
|
116
|
+
walletBalance: {
|
|
117
|
+
type: DataTypes.DECIMAL(10, 2),
|
|
118
|
+
allowNull: false,
|
|
119
|
+
defaultValue: 0.0,
|
|
120
|
+
},
|
|
121
|
+
currency: {
|
|
122
|
+
type: DataTypes.STRING,
|
|
123
|
+
allowNull: false,
|
|
124
|
+
defaultValue: "NGN",
|
|
125
|
+
},
|
|
111
126
|
userCreatedby: {
|
|
112
127
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
113
128
|
allowNull: true,
|
package/models/dobitUserOTP.js
CHANGED
|
@@ -4,12 +4,7 @@ const { Model, DataTypes } = require("sequelize");
|
|
|
4
4
|
|
|
5
5
|
module.exports = (sequelize) => {
|
|
6
6
|
class DobitUserOTP extends Model {
|
|
7
|
-
static associate(models) {
|
|
8
|
-
DobitUserOTP.belongsTo(models.DobitUsers, {
|
|
9
|
-
as: "user",
|
|
10
|
-
foreignKey: "dobitUserId",
|
|
11
|
-
});
|
|
12
|
-
}
|
|
7
|
+
static associate(models) {}
|
|
13
8
|
}
|
|
14
9
|
|
|
15
10
|
DobitUserOTP.init(
|
|
@@ -20,30 +15,18 @@ module.exports = (sequelize) => {
|
|
|
20
15
|
autoIncrement: true,
|
|
21
16
|
allowNull: false,
|
|
22
17
|
},
|
|
23
|
-
dobitUserId: {
|
|
24
|
-
type: DataTypes.INTEGER.UNSIGNED,
|
|
25
|
-
allowNull: false,
|
|
26
|
-
references: {
|
|
27
|
-
model: "DobitUsers",
|
|
28
|
-
key: "dobitUserId",
|
|
29
|
-
},
|
|
30
|
-
onUpdate: "CASCADE",
|
|
31
|
-
onDelete: "CASCADE",
|
|
32
|
-
},
|
|
33
18
|
appUserId: {
|
|
34
19
|
type: DataTypes.BIGINT.UNSIGNED,
|
|
35
20
|
allowNull: false,
|
|
36
|
-
references: {
|
|
37
|
-
model: "DobitUsers",
|
|
38
|
-
key: "appUserId",
|
|
39
|
-
},
|
|
40
|
-
onUpdate: "CASCADE",
|
|
41
|
-
onDelete: "CASCADE",
|
|
42
21
|
},
|
|
43
22
|
email: {
|
|
44
23
|
type: DataTypes.STRING,
|
|
45
24
|
allowNull: false,
|
|
46
25
|
},
|
|
26
|
+
username: {
|
|
27
|
+
type: DataTypes.STRING,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
},
|
|
47
30
|
otp: {
|
|
48
31
|
type: DataTypes.STRING,
|
|
49
32
|
allowNull: false,
|
package/package.json
CHANGED