dip-dobit-shared-model 1.0.10 → 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/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/dobitUserOTP.js +5 -22
- package/package.json +1 -1
|
@@ -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 =
|
|
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/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,
|