ojamoto_models 1.0.0
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/LICENSE +21 -0
- package/certificates/global-bundle.pem +2736 -0
- package/config/config.js +52 -0
- package/index.js +3 -0
- package/migrations/2026000001-create-users.js +97 -0
- package/migrations/2026000002-create-and-seed-roles.js +43 -0
- package/migrations/2026000003-create-admin-users.js +83 -0
- package/migrations/2026000004-create-devices.js +67 -0
- package/migrations/2026000005-create-products.js +87 -0
- package/migrations/2026000006-create-addresses.js +74 -0
- package/migrations/2026000007-create-wallets.js +44 -0
- package/migrations/2026000008-create-kyc-verification.js +51 -0
- package/migrations/2026000009-create-seller-profiles.js +80 -0
- package/migrations/2026000010-create-user-roles.js +48 -0
- package/migrations/2026000011-create-sessions.js +61 -0
- package/migrations/2026000012-create-escrows.js +80 -0
- package/migrations/2026000013-create-wallet-transactions.js +70 -0
- package/migrations/2026000014-create-product-images.js +43 -0
- package/migrations/2026000015-create-escrow-events.js +50 -0
- package/migrations/2026000016-create-logistics.js +55 -0
- package/migrations/2026000017-create-ratings.js +56 -0
- package/migrations/2026000018-create-disputes.js +84 -0
- package/migrations/2026000019-create-dispute-evidence.js +50 -0
- package/migrations/2026000020-create-dispute-messages.js +44 -0
- package/migrations/2026000021-create-notifications.js +50 -0
- package/migrations/2026000022-create-audit-logs.js +57 -0
- package/migrations/2026000023-create-webhook-logs.js +46 -0
- package/migrations/2026000024-create-user-otps.js +75 -0
- package/migrations/2026000025-create-password-reset-otps.js +43 -0
- package/migrations/2026000026-create-seller-badges.js +43 -0
- package/migrations/2026000027-add-fulltext-index-for-search.js +15 -0
- package/migrations/2026000028-create-admin-notifications.js +53 -0
- package/migrations/2026000029-create-pin-reset-otp.js +30 -0
- package/models/Address.js +76 -0
- package/models/AdminNotification.js +59 -0
- package/models/AdminUser.js +115 -0
- package/models/AuditLog.js +70 -0
- package/models/Device.js +82 -0
- package/models/Dispute.js +109 -0
- package/models/DisputeEvidence.js +62 -0
- package/models/DisputeMessage.js +57 -0
- package/models/Escrow.js +110 -0
- package/models/EscrowEvent.js +63 -0
- package/models/KycVerification.js +62 -0
- package/models/Logistics.js +62 -0
- package/models/Notification.js +58 -0
- package/models/PasswordResetOTP.js +52 -0
- package/models/PinResetOTP.js +48 -0
- package/models/Product.js +100 -0
- package/models/ProductImage.js +54 -0
- package/models/Rating.js +74 -0
- package/models/Role.js +43 -0
- package/models/SellerBadges.js +45 -0
- package/models/SellerProfile.js +92 -0
- package/models/Session.js +67 -0
- package/models/User.js +198 -0
- package/models/UserOTP.js +84 -0
- package/models/UserRole.js +42 -0
- package/models/Wallet.js +63 -0
- package/models/WalletTransaction.js +81 -0
- package/models/WebhookLog.js +52 -0
- package/models/index.js +23 -0
- package/package.json +30 -0
- package/services/constants.js +162 -0
package/config/config.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require("dotenv").config();
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
development: {
|
|
7
|
+
username: process.env.DB_USERNAME,
|
|
8
|
+
password: process.env.DB_PASSWORD,
|
|
9
|
+
database: process.env.DB_NAME,
|
|
10
|
+
host: process.env.DB_HOST,
|
|
11
|
+
dialect: "mysql",
|
|
12
|
+
pool: {
|
|
13
|
+
max: 5,
|
|
14
|
+
min: 0,
|
|
15
|
+
acquire: 30000,
|
|
16
|
+
idle: 10000,
|
|
17
|
+
},
|
|
18
|
+
define: {
|
|
19
|
+
underscored: true,
|
|
20
|
+
Charset: "utf8mb4",
|
|
21
|
+
Collate: "utf8mb4_general_ci",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// production: {
|
|
26
|
+
// username: process.env.AWS_DB_USERNAME,
|
|
27
|
+
// password: process.env.AWS_DB_PASSWORD,
|
|
28
|
+
// database: process.env.AWS_DB_NAME,
|
|
29
|
+
// host: process.env.AWS_DB_HOST,
|
|
30
|
+
// dialect: "mysql",
|
|
31
|
+
// dialectOptions: {
|
|
32
|
+
// ssl: {
|
|
33
|
+
// require: true,
|
|
34
|
+
// rejectUnauthorized: false,
|
|
35
|
+
// ca: fs.readFileSync(
|
|
36
|
+
// path.join(__dirname, "../certificates/global-bundle.pem"),
|
|
37
|
+
// ),
|
|
38
|
+
// },
|
|
39
|
+
// },
|
|
40
|
+
// pool: {
|
|
41
|
+
// max: 5,
|
|
42
|
+
// min: 0,
|
|
43
|
+
// acquire: 30000,
|
|
44
|
+
// idle: 10000,
|
|
45
|
+
// },
|
|
46
|
+
// define: {
|
|
47
|
+
// underscored: true,
|
|
48
|
+
// Charset: "utf8mb4",
|
|
49
|
+
// Collate: "utf8mb4_general_ci",
|
|
50
|
+
// },
|
|
51
|
+
// },
|
|
52
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { USER_STATUS } = require("../services/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("users", {
|
|
8
|
+
user_id: {
|
|
9
|
+
type: Sequelize.INTEGER,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
uuid: {
|
|
15
|
+
type: Sequelize.UUID,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
unique: true,
|
|
18
|
+
},
|
|
19
|
+
first_name: {
|
|
20
|
+
type: Sequelize.STRING(100),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
last_name: {
|
|
24
|
+
type: Sequelize.STRING(100),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
middle_name: {
|
|
28
|
+
type: Sequelize.STRING(100),
|
|
29
|
+
allowNull: true,
|
|
30
|
+
},
|
|
31
|
+
email: {
|
|
32
|
+
type: Sequelize.STRING(255),
|
|
33
|
+
allowNull: false,
|
|
34
|
+
unique: true,
|
|
35
|
+
},
|
|
36
|
+
phone: {
|
|
37
|
+
type: Sequelize.STRING(10),
|
|
38
|
+
allowNull: false,
|
|
39
|
+
unique: true,
|
|
40
|
+
},
|
|
41
|
+
country_calling_code: {
|
|
42
|
+
type: Sequelize.STRING(3),
|
|
43
|
+
allowNull: false,
|
|
44
|
+
},
|
|
45
|
+
password_hash: {
|
|
46
|
+
type: Sequelize.STRING(255),
|
|
47
|
+
allowNull: false,
|
|
48
|
+
},
|
|
49
|
+
transaction_pin_hash: {
|
|
50
|
+
type: Sequelize.STRING(255),
|
|
51
|
+
allowNull: true,
|
|
52
|
+
},
|
|
53
|
+
status: {
|
|
54
|
+
type: Sequelize.ENUM(...Object.values(USER_STATUS)),
|
|
55
|
+
allowNull: false,
|
|
56
|
+
defaultValue: USER_STATUS.ACTIVE,
|
|
57
|
+
},
|
|
58
|
+
email_verified: {
|
|
59
|
+
type: Sequelize.BOOLEAN,
|
|
60
|
+
defaultValue: false,
|
|
61
|
+
},
|
|
62
|
+
phone_verified: {
|
|
63
|
+
type: Sequelize.BOOLEAN,
|
|
64
|
+
defaultValue: false,
|
|
65
|
+
},
|
|
66
|
+
nin_verified: {
|
|
67
|
+
type: Sequelize.BOOLEAN,
|
|
68
|
+
defaultValue: false,
|
|
69
|
+
comment: "Sellers only",
|
|
70
|
+
},
|
|
71
|
+
bank_verified: {
|
|
72
|
+
type: Sequelize.BOOLEAN,
|
|
73
|
+
defaultValue: false,
|
|
74
|
+
},
|
|
75
|
+
two_factor_enabled: {
|
|
76
|
+
type: Sequelize.BOOLEAN,
|
|
77
|
+
defaultValue: false,
|
|
78
|
+
},
|
|
79
|
+
created_at: {
|
|
80
|
+
type: Sequelize.DATE,
|
|
81
|
+
allowNull: false,
|
|
82
|
+
},
|
|
83
|
+
updated_at: {
|
|
84
|
+
type: Sequelize.DATE,
|
|
85
|
+
allowNull: false,
|
|
86
|
+
},
|
|
87
|
+
deleted_at: {
|
|
88
|
+
type: Sequelize.DATE,
|
|
89
|
+
allowNull: true,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
async down(queryInterface) {
|
|
95
|
+
await queryInterface.dropTable("users");
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ROLE_NAME } = require("../services/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("roles", {
|
|
8
|
+
role_id: {
|
|
9
|
+
type: Sequelize.INTEGER,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
name: {
|
|
15
|
+
type: Sequelize.ENUM(...Object.values(ROLE_NAME)),
|
|
16
|
+
allowNull: false,
|
|
17
|
+
unique: true,
|
|
18
|
+
},
|
|
19
|
+
created_at: {
|
|
20
|
+
type: Sequelize.DATE,
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
updated_at: {
|
|
24
|
+
type: Sequelize.DATE,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Seed the two roles immediately after creation
|
|
30
|
+
await queryInterface.bulkInsert("roles", [
|
|
31
|
+
{ name: ROLE_NAME.BUYER, created_at: new Date(), updated_at: new Date() },
|
|
32
|
+
{
|
|
33
|
+
name: ROLE_NAME.SELLER,
|
|
34
|
+
created_at: new Date(),
|
|
35
|
+
updated_at: new Date(),
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
async down(queryInterface) {
|
|
41
|
+
await queryInterface.dropTable("roles");
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ADMIN_ROLE, ADMIN_STATUS } = require("../services/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("admin_users", {
|
|
8
|
+
admin_id: {
|
|
9
|
+
type: Sequelize.INTEGER,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
uuid: {
|
|
15
|
+
type: Sequelize.UUID,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
unique: true,
|
|
18
|
+
},
|
|
19
|
+
first_name: {
|
|
20
|
+
type: Sequelize.STRING(100),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
last_name: {
|
|
24
|
+
type: Sequelize.STRING(100),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
email: {
|
|
28
|
+
type: Sequelize.STRING(255),
|
|
29
|
+
allowNull: false,
|
|
30
|
+
unique: true,
|
|
31
|
+
},
|
|
32
|
+
phone: {
|
|
33
|
+
type: Sequelize.STRING(20),
|
|
34
|
+
allowNull: false,
|
|
35
|
+
unique: true,
|
|
36
|
+
},
|
|
37
|
+
password_hash: {
|
|
38
|
+
type: Sequelize.STRING(255),
|
|
39
|
+
allowNull: false,
|
|
40
|
+
},
|
|
41
|
+
role: {
|
|
42
|
+
type: Sequelize.ENUM(...Object.values(ADMIN_ROLE)),
|
|
43
|
+
allowNull: false,
|
|
44
|
+
},
|
|
45
|
+
status: {
|
|
46
|
+
type: Sequelize.ENUM(...Object.values(ADMIN_STATUS)),
|
|
47
|
+
allowNull: false,
|
|
48
|
+
defaultValue: ADMIN_STATUS.ACTIVE,
|
|
49
|
+
},
|
|
50
|
+
two_factor_enabled: {
|
|
51
|
+
type: Sequelize.BOOLEAN,
|
|
52
|
+
allowNull: false,
|
|
53
|
+
defaultValue: true,
|
|
54
|
+
comment: "Mandatory for all admin accounts",
|
|
55
|
+
},
|
|
56
|
+
last_login_at: {
|
|
57
|
+
type: Sequelize.DATE,
|
|
58
|
+
allowNull: true,
|
|
59
|
+
},
|
|
60
|
+
// Self-referential FK — allows null for the first super admin
|
|
61
|
+
created_by: {
|
|
62
|
+
type: Sequelize.INTEGER,
|
|
63
|
+
allowNull: true,
|
|
64
|
+
references: { model: "admin_users", key: "admin_id" },
|
|
65
|
+
onDelete: "SET NULL",
|
|
66
|
+
onUpdate: "CASCADE",
|
|
67
|
+
comment: "Which super admin created this account",
|
|
68
|
+
},
|
|
69
|
+
created_at: {
|
|
70
|
+
type: Sequelize.DATE,
|
|
71
|
+
allowNull: false,
|
|
72
|
+
},
|
|
73
|
+
updated_at: {
|
|
74
|
+
type: Sequelize.DATE,
|
|
75
|
+
allowNull: false,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
async down(queryInterface) {
|
|
81
|
+
await queryInterface.dropTable("admin_users");
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable("devices", {
|
|
6
|
+
device_id: {
|
|
7
|
+
type: Sequelize.INTEGER,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
autoIncrement: true,
|
|
10
|
+
allowNull: false,
|
|
11
|
+
},
|
|
12
|
+
user_id: {
|
|
13
|
+
type: Sequelize.INTEGER,
|
|
14
|
+
allowNull: false,
|
|
15
|
+
references: { model: "users", key: "user_id" },
|
|
16
|
+
onDelete: "CASCADE",
|
|
17
|
+
onUpdate: "CASCADE",
|
|
18
|
+
},
|
|
19
|
+
device_name: {
|
|
20
|
+
type: Sequelize.STRING(100),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
device_type: {
|
|
24
|
+
type: Sequelize.STRING(50),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
comment: "mobile | desktop | tablet",
|
|
27
|
+
},
|
|
28
|
+
user_device_id: {
|
|
29
|
+
type: Sequelize.STRING(100),
|
|
30
|
+
allowNull: false,
|
|
31
|
+
},
|
|
32
|
+
push_notification_id: {
|
|
33
|
+
type: Sequelize.STRING(100),
|
|
34
|
+
allowNull: false,
|
|
35
|
+
},
|
|
36
|
+
browser: {
|
|
37
|
+
type: Sequelize.STRING(100),
|
|
38
|
+
allowNull: true,
|
|
39
|
+
},
|
|
40
|
+
ip_address: {
|
|
41
|
+
type: Sequelize.STRING(45),
|
|
42
|
+
allowNull: false,
|
|
43
|
+
comment: "IPv4 or IPv6",
|
|
44
|
+
},
|
|
45
|
+
location: {
|
|
46
|
+
type: Sequelize.STRING(500),
|
|
47
|
+
allowNull: false,
|
|
48
|
+
comment: "City, Country",
|
|
49
|
+
},
|
|
50
|
+
trusted: {
|
|
51
|
+
type: Sequelize.BOOLEAN,
|
|
52
|
+
defaultValue: false,
|
|
53
|
+
comment: "User-approved device",
|
|
54
|
+
},
|
|
55
|
+
created_at: {
|
|
56
|
+
type: Sequelize.DATE,
|
|
57
|
+
allowNull: false,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
await queryInterface.addIndex("devices", ["user_id"]);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
async down(queryInterface) {
|
|
65
|
+
await queryInterface.dropTable("devices");
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { PRODUCT_CONDITION, PRODUCT_STATUS } = require("../services/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("products", {
|
|
8
|
+
product_id: {
|
|
9
|
+
type: Sequelize.INTEGER,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
seller_id: {
|
|
15
|
+
type: Sequelize.INTEGER,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
references: { model: "users", key: "user_id" },
|
|
18
|
+
onDelete: "CASCADE",
|
|
19
|
+
onUpdate: "CASCADE",
|
|
20
|
+
},
|
|
21
|
+
name: {
|
|
22
|
+
type: Sequelize.STRING(255),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
},
|
|
25
|
+
description: {
|
|
26
|
+
type: Sequelize.TEXT,
|
|
27
|
+
allowNull: true,
|
|
28
|
+
},
|
|
29
|
+
price: {
|
|
30
|
+
type: Sequelize.DECIMAL(15, 2),
|
|
31
|
+
allowNull: false,
|
|
32
|
+
},
|
|
33
|
+
currency: {
|
|
34
|
+
type: Sequelize.STRING(3),
|
|
35
|
+
allowNull: false,
|
|
36
|
+
defaultValue: "NGN",
|
|
37
|
+
},
|
|
38
|
+
category: {
|
|
39
|
+
type: Sequelize.STRING(100),
|
|
40
|
+
allowNull: true,
|
|
41
|
+
comment: "Engine | Brake | Suspension etc.",
|
|
42
|
+
},
|
|
43
|
+
brand: {
|
|
44
|
+
type: Sequelize.STRING(100),
|
|
45
|
+
allowNull: true,
|
|
46
|
+
comment: "Toyota, Ford, Bosch etc.",
|
|
47
|
+
},
|
|
48
|
+
model: {
|
|
49
|
+
type: Sequelize.STRING(100),
|
|
50
|
+
allowNull: true,
|
|
51
|
+
comment: "Camry, F-150 etc.",
|
|
52
|
+
},
|
|
53
|
+
condition: {
|
|
54
|
+
type: Sequelize.ENUM(...Object.values(PRODUCT_CONDITION)),
|
|
55
|
+
allowNull: false,
|
|
56
|
+
},
|
|
57
|
+
stock: {
|
|
58
|
+
type: Sequelize.INTEGER,
|
|
59
|
+
allowNull: false,
|
|
60
|
+
defaultValue: 1,
|
|
61
|
+
},
|
|
62
|
+
status: {
|
|
63
|
+
type: Sequelize.ENUM(...Object.values(PRODUCT_STATUS)),
|
|
64
|
+
allowNull: false,
|
|
65
|
+
defaultValue: PRODUCT_STATUS.DRAFT,
|
|
66
|
+
},
|
|
67
|
+
created_at: {
|
|
68
|
+
type: Sequelize.DATE,
|
|
69
|
+
allowNull: false,
|
|
70
|
+
},
|
|
71
|
+
updated_at: {
|
|
72
|
+
type: Sequelize.DATE,
|
|
73
|
+
allowNull: false,
|
|
74
|
+
},
|
|
75
|
+
deleted_at: {
|
|
76
|
+
type: Sequelize.DATE,
|
|
77
|
+
allowNull: true,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
await queryInterface.addIndex("products", ["seller_id"]);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async down(queryInterface) {
|
|
85
|
+
await queryInterface.dropTable("products");
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ADDRESS_LABEL } = require("../services/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("addresses", {
|
|
8
|
+
address_id: {
|
|
9
|
+
type: Sequelize.INTEGER,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
user_id: {
|
|
15
|
+
type: Sequelize.INTEGER,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
references: { model: "users", key: "user_id" },
|
|
18
|
+
onDelete: "CASCADE",
|
|
19
|
+
onUpdate: "CASCADE",
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
type: Sequelize.ENUM(...Object.values(ADDRESS_LABEL)),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
},
|
|
25
|
+
address_line1: {
|
|
26
|
+
type: Sequelize.STRING(255),
|
|
27
|
+
allowNull: false,
|
|
28
|
+
},
|
|
29
|
+
address_line2: {
|
|
30
|
+
type: Sequelize.STRING(255),
|
|
31
|
+
allowNull: true,
|
|
32
|
+
},
|
|
33
|
+
city: {
|
|
34
|
+
type: Sequelize.STRING(100),
|
|
35
|
+
allowNull: false,
|
|
36
|
+
},
|
|
37
|
+
state: {
|
|
38
|
+
type: Sequelize.STRING(100),
|
|
39
|
+
allowNull: false,
|
|
40
|
+
},
|
|
41
|
+
country: {
|
|
42
|
+
type: Sequelize.STRING(100),
|
|
43
|
+
allowNull: false,
|
|
44
|
+
},
|
|
45
|
+
postal_code: {
|
|
46
|
+
type: Sequelize.STRING(20),
|
|
47
|
+
allowNull: true,
|
|
48
|
+
},
|
|
49
|
+
is_default: {
|
|
50
|
+
type: Sequelize.BOOLEAN,
|
|
51
|
+
allowNull: false,
|
|
52
|
+
defaultValue: false,
|
|
53
|
+
},
|
|
54
|
+
created_at: {
|
|
55
|
+
type: Sequelize.DATE,
|
|
56
|
+
allowNull: false,
|
|
57
|
+
},
|
|
58
|
+
updated_at: {
|
|
59
|
+
type: Sequelize.DATE,
|
|
60
|
+
allowNull: false,
|
|
61
|
+
},
|
|
62
|
+
deleted_at: {
|
|
63
|
+
type: Sequelize.DATE,
|
|
64
|
+
allowNull: true,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await queryInterface.addIndex("addresses", ["user_id"]);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
async down(queryInterface) {
|
|
72
|
+
await queryInterface.dropTable("addresses");
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable("wallets", {
|
|
6
|
+
wallet_id: {
|
|
7
|
+
type: Sequelize.INTEGER,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
autoIncrement: true,
|
|
10
|
+
allowNull: false,
|
|
11
|
+
},
|
|
12
|
+
user_id: {
|
|
13
|
+
type: Sequelize.INTEGER,
|
|
14
|
+
allowNull: false,
|
|
15
|
+
unique: true,
|
|
16
|
+
references: { model: "users", key: "user_id" },
|
|
17
|
+
onDelete: "CASCADE",
|
|
18
|
+
onUpdate: "CASCADE",
|
|
19
|
+
comment: "One wallet per user",
|
|
20
|
+
},
|
|
21
|
+
available_balance: {
|
|
22
|
+
type: Sequelize.DECIMAL(15, 2),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
defaultValue: 0.0,
|
|
25
|
+
comment: "Spendable funds",
|
|
26
|
+
},
|
|
27
|
+
locked_balance: {
|
|
28
|
+
type: Sequelize.DECIMAL(15, 2),
|
|
29
|
+
allowNull: false,
|
|
30
|
+
defaultValue: 0.0,
|
|
31
|
+
comment: "Funds currently held in active escrows",
|
|
32
|
+
},
|
|
33
|
+
currency: {
|
|
34
|
+
type: Sequelize.STRING(3),
|
|
35
|
+
allowNull: false,
|
|
36
|
+
defaultValue: "NGN",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async down(queryInterface) {
|
|
42
|
+
await queryInterface.dropTable("wallets");
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { KYC_STATUS, KYC_PROVIDER } = require("../services/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("kyc_verifications", {
|
|
8
|
+
kyc_verification_id: {
|
|
9
|
+
type: Sequelize.INTEGER,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
user_id: {
|
|
15
|
+
type: Sequelize.INTEGER,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
unique: true,
|
|
18
|
+
references: { model: "users", key: "user_id" },
|
|
19
|
+
onDelete: "CASCADE",
|
|
20
|
+
onUpdate: "CASCADE",
|
|
21
|
+
},
|
|
22
|
+
nin_data_json: {
|
|
23
|
+
type: Sequelize.JSON,
|
|
24
|
+
allowNull: true,
|
|
25
|
+
comment: "Raw NIN API response from provider",
|
|
26
|
+
},
|
|
27
|
+
bank_data_json: {
|
|
28
|
+
type: Sequelize.JSON,
|
|
29
|
+
allowNull: true,
|
|
30
|
+
comment: "Resolved account name and bank details",
|
|
31
|
+
},
|
|
32
|
+
verification_status: {
|
|
33
|
+
type: Sequelize.ENUM(...Object.values(KYC_STATUS)),
|
|
34
|
+
allowNull: false,
|
|
35
|
+
defaultValue: KYC_STATUS.PENDING,
|
|
36
|
+
},
|
|
37
|
+
provider: {
|
|
38
|
+
type: Sequelize.ENUM(...Object.values(KYC_PROVIDER)),
|
|
39
|
+
allowNull: true,
|
|
40
|
+
},
|
|
41
|
+
created_at: {
|
|
42
|
+
type: Sequelize.DATE,
|
|
43
|
+
allowNull: false,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
async down(queryInterface) {
|
|
49
|
+
await queryInterface.dropTable("kyc_verifications");
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
SELLER_VERIFICATION_STATUS,
|
|
5
|
+
SELLER_TYPE,
|
|
6
|
+
} = require("../services/constants");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
async up(queryInterface, Sequelize) {
|
|
10
|
+
await queryInterface.createTable("seller_profiles", {
|
|
11
|
+
seller_profile_id: {
|
|
12
|
+
type: Sequelize.INTEGER,
|
|
13
|
+
primaryKey: true,
|
|
14
|
+
autoIncrement: true,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
},
|
|
17
|
+
user_id: {
|
|
18
|
+
type: Sequelize.INTEGER,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
unique: true,
|
|
21
|
+
references: { model: "users", key: "user_id" },
|
|
22
|
+
onDelete: "CASCADE",
|
|
23
|
+
onUpdate: "CASCADE",
|
|
24
|
+
},
|
|
25
|
+
user_type: {
|
|
26
|
+
type: Sequelize.ENUM(...Object.values(SELLER_TYPE)),
|
|
27
|
+
allowNull: false,
|
|
28
|
+
},
|
|
29
|
+
store_name: {
|
|
30
|
+
type: Sequelize.STRING(150),
|
|
31
|
+
allowNull: false,
|
|
32
|
+
},
|
|
33
|
+
store_slug: {
|
|
34
|
+
type: Sequelize.STRING(150),
|
|
35
|
+
allowNull: false,
|
|
36
|
+
unique: true,
|
|
37
|
+
comment: "URL-safe identifier",
|
|
38
|
+
},
|
|
39
|
+
description: {
|
|
40
|
+
type: Sequelize.TEXT,
|
|
41
|
+
allowNull: true,
|
|
42
|
+
},
|
|
43
|
+
logo_url: {
|
|
44
|
+
type: Sequelize.STRING(500),
|
|
45
|
+
allowNull: true,
|
|
46
|
+
comment: "AWS S3 URL",
|
|
47
|
+
},
|
|
48
|
+
avg_rating: {
|
|
49
|
+
type: Sequelize.DECIMAL(3, 2),
|
|
50
|
+
allowNull: true,
|
|
51
|
+
comment: "Computed rolling average",
|
|
52
|
+
},
|
|
53
|
+
total_sales: {
|
|
54
|
+
type: Sequelize.INTEGER,
|
|
55
|
+
defaultValue: 0,
|
|
56
|
+
},
|
|
57
|
+
dispute_count: {
|
|
58
|
+
type: Sequelize.INTEGER,
|
|
59
|
+
defaultValue: 0,
|
|
60
|
+
},
|
|
61
|
+
verification_status: {
|
|
62
|
+
type: Sequelize.ENUM(...Object.values(SELLER_VERIFICATION_STATUS)),
|
|
63
|
+
allowNull: false,
|
|
64
|
+
defaultValue: SELLER_VERIFICATION_STATUS.UNVERIFIED,
|
|
65
|
+
},
|
|
66
|
+
created_at: {
|
|
67
|
+
type: Sequelize.DATE,
|
|
68
|
+
allowNull: false,
|
|
69
|
+
},
|
|
70
|
+
updated_at: {
|
|
71
|
+
type: Sequelize.DATE,
|
|
72
|
+
allowNull: false,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
async down(queryInterface) {
|
|
78
|
+
await queryInterface.dropTable("seller_profiles");
|
|
79
|
+
},
|
|
80
|
+
};
|