@churchsoln/dbms 1.0.47 → 1.0.49
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/Dockerfile +21 -21
- package/Makefile +132 -132
- package/app.js +37 -37
- package/config/config.js +33 -33
- package/config/errorCodes.js +65 -65
- package/config/errorMsgs.js +82 -82
- package/constants/index.js +94 -94
- package/controllers/church.js +100 -100
- package/controllers/index.js +6 -6
- package/controllers/master.js +138 -138
- package/controllers/migration.js +24 -24
- package/controllers/seed.js +33 -33
- package/db-setup.js +87 -87
- package/deployment/docker-compose.local.yml +64 -64
- package/deployment/docker-compose.yml +62 -62
- package/deployment/nginx/nginx-certs/localhost.crt +22 -22
- package/deployment/nginx/nginx-certs/localhost.key +28 -28
- package/deployment/nginx/nginx.local.conf +72 -72
- package/middlewares/church-filter.js +16 -16
- package/migrations/church/20221226151615-create-province.js +27 -27
- package/migrations/church/20221226151616-create-city.js +41 -41
- package/migrations/church/20221226151617-create-subRole.js +25 -25
- package/migrations/church/20221226151618-create-membership.js +68 -68
- package/migrations/church/20221226151619-create-member.js +140 -140
- package/migrations/church/20221227151615-create-user.js +60 -60
- package/migrations/church/20230826140644-create-eventsUpdates.js +29 -29
- package/migrations/church/20230904143429-create-ministries.js +26 -26
- package/migrations/church/20231021160018-create-gallery.js +28 -28
- package/migrations/church/20231105074019-create-feedback.js +28 -28
- package/migrations/church/20231111113342-create-banner.js +29 -29
- package/migrations/church/20231216105640-create-directoryBoard.js +31 -31
- package/migrations/church/20240214160101-create-volunteer.js +31 -31
- package/migrations/church/20240330111437-create-download.js +29 -29
- package/migrations/church/20240427170617-create-links.js +26 -26
- package/migrations/church/20240815170617-create-userTransfer.js +63 -63
- package/migrations/church/20240815170620-create-subRolePermission.js +40 -40
- package/migrations/church/20240915170620-create-transferType.js +25 -25
- package/migrations/church/20240917170620-create-accounts.js +27 -27
- package/migrations/church/20240918170621-create-church.js +54 -54
- package/migrations/church/20240918170622-create-group.js +61 -61
- package/migrations/church/20240918170623-create-groupMembers.js +74 -74
- package/migrations/church/20240918170627-create-pledge.js +96 -96
- package/migrations/church/20240919170627-create-contributionBatch.js +42 -42
- package/migrations/church/20240919170628-create-contributionTransaction.js +82 -82
- package/migrations/church/20240919170629-create-contributionTransactionLine.js +74 -74
- package/migrations/church/20240919170630-update-groupMembers.js +77 -77
- package/migrations/church/20241204170631-create-pledgeAccount.js +55 -55
- package/migrations/church/20241204170632-create-memberStatus.js +26 -0
- package/migrations/church/20241204170633-update-member.js +33 -0
- package/migrations/church/20241204170634-update-membership.js +33 -0
- package/migrations/church/20241204170635-update-pledge.js +33 -0
- package/migrations/church/20241204170636-update-contributionTransactionLine.js +33 -0
- package/migrations/common/20221226140655-create-subscriptionPlan.js +31 -31
- package/migrations/common/20221226143006-create-role.js +25 -25
- package/migrations/common/20240815170619-create-permission.js +27 -27
- package/migrations/common/20240815170620-create-church.js +56 -56
- package/migrations/common/20240815170621-create-churchDomain.js +40 -40
- package/migrations/common/20240918170621-create-churchPermission.js +53 -53
- package/migrations/common/20240918170622-create-user.js +35 -35
- package/migrations/common/20240918170627-create-subscriptionPlanPermission.js +53 -53
- package/models/church/accounts.js +23 -27
- package/models/church/banner.js +29 -29
- package/models/church/church.js +62 -62
- package/models/church/city.js +23 -23
- package/models/church/contributionBatch.js +45 -45
- package/models/church/contributionTransaction.js +90 -90
- package/models/church/contributionTransactionLine.js +81 -80
- package/models/church/directoryBoard.js +33 -33
- package/models/church/download.js +35 -35
- package/models/church/eventsUpdates.js +29 -29
- package/models/church/feedback.js +27 -27
- package/models/church/gallery.js +33 -33
- package/models/church/group.js +78 -78
- package/models/church/groupMembers.js +73 -73
- package/models/church/index.js +30 -30
- package/models/church/links.js +22 -22
- package/models/church/member.js +161 -171
- package/models/church/memberStatus.js +22 -0
- package/models/church/membership.js +80 -81
- package/models/church/ministries.js +16 -16
- package/models/church/pledge.js +65 -65
- package/models/church/pledgeAccount.js +45 -37
- package/models/church/province.js +23 -23
- package/models/church/subRole.js +21 -21
- package/models/church/subRolePermission.js +22 -22
- package/models/church/transferType.js +15 -15
- package/models/church/user.js +78 -78
- package/models/church/userTransfer.js +45 -45
- package/models/church/volunteer.js +33 -33
- package/models/common/church.js +58 -58
- package/models/common/churchDomain.js +21 -21
- package/models/common/churchPermission.js +26 -26
- package/models/common/index.js +40 -40
- package/models/common/permission.js +17 -17
- package/models/common/role.js +15 -15
- package/models/common/subscriptionPlan.js +34 -34
- package/models/common/subscriptionPlanPermission.js +33 -33
- package/models/common/user.js +39 -39
- package/package.json +41 -41
- package/public/swagger/church.json +521 -521
- package/public/swagger/master.json +537 -537
- package/public/swagger/migration.json +83 -83
- package/public/swagger/seed.json +98 -98
- package/queues/db-create.js +9 -9
- package/queues/index.js +5 -5
- package/queues/master.js +9 -9
- package/queues/migration.js +9 -9
- package/queues/seed.js +9 -9
- package/redis/config.js +5 -5
- package/routes/index.js +30 -30
- package/routes/v1/church.js +45 -45
- package/routes/v1/index.js +7 -7
- package/routes/v1/master.js +68 -68
- package/routes/v1/migration.js +10 -10
- package/routes/v1/seed.js +12 -12
- package/seeders/church/20241005124245-province.js +101 -101
- package/seeders/church/20241005124547-city.js +87 -87
- package/seeders/church/20241005131418-transferType.js +40 -40
- package/seeders/church/20241005131419-memberStatus.js +34 -0
- package/seeders/common/20241005123516-subscriptionPlan.js +43 -43
- package/seeders/common/20241005124105-role.js +38 -38
- package/seeders/common/20241005153047-permission.js +252 -242
- package/seeders/common/20241005153048-user.js +48 -48
- package/services/church.js +312 -312
- package/services/index.js +6 -6
- package/services/master.js +344 -344
- package/services/migration.js +30 -30
- package/services/seed.js +39 -39
- package/utils/churchManager.js +98 -98
- package/utils/crypto.js +40 -40
- package/utils/docUpload.js +51 -51
- package/utils/encryptDecrypt.js +26 -26
- package/utils/index.js +33 -33
- package/utils/logger.js +104 -104
- package/utils/response.js +108 -108
- package/utils/swagger.js +25 -25
- package/utils/verifyToken.js +58 -58
- package/validators/church.js +154 -154
- package/validators/index.js +3 -3
- package/validators/master.js +152 -152
- package/workers/db-create.js +37 -37
- package/workers/index.js +4 -4
- package/workers/master.js +50 -50
- package/workers/migrations.js +63 -63
- package/workers/seed.js +85 -85
package/models/church/user.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
const utils = require("../../utils");
|
|
2
|
-
//
|
|
3
|
-
module.exports = (sequelize, DataTypes) => {
|
|
4
|
-
const user = sequelize.define(
|
|
5
|
-
"User",
|
|
6
|
-
{
|
|
7
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
-
|
|
9
|
-
// Link to the individual profile
|
|
10
|
-
memberId: {
|
|
11
|
-
type: DataTypes.INTEGER,
|
|
12
|
-
set(memberId) {
|
|
13
|
-
this.setDataValue("memberId", memberId?.id || memberId);
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// Authentication Fields
|
|
18
|
-
username: {
|
|
19
|
-
type: DataTypes.STRING,
|
|
20
|
-
allowNull: false,
|
|
21
|
-
unique: true,
|
|
22
|
-
},
|
|
23
|
-
password: {
|
|
24
|
-
type: DataTypes.STRING,
|
|
25
|
-
allowNull: false,
|
|
26
|
-
set(password) {
|
|
27
|
-
if (password) {
|
|
28
|
-
const encrypted = utils.genHash(password);
|
|
29
|
-
this.setDataValue("password", encrypted);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
email: {
|
|
34
|
-
type: DataTypes.STRING,
|
|
35
|
-
allowNull: false,
|
|
36
|
-
unique: true,
|
|
37
|
-
validate: { isEmail: true },
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
// Roles & Permissions
|
|
41
|
-
roleId: { type: DataTypes.INTEGER },
|
|
42
|
-
subRoleId: { type: DataTypes.INTEGER },
|
|
43
|
-
enableLoginAccess: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
44
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
45
|
-
|
|
46
|
-
// Metadata
|
|
47
|
-
lastLogin: { type: DataTypes.DATE },
|
|
48
|
-
createdAt: { type: DataTypes.DATE },
|
|
49
|
-
updatedAt: { type: DataTypes.DATE },
|
|
50
|
-
},
|
|
51
|
-
{ freezeTableName: true, timestamps: false }
|
|
52
|
-
);
|
|
53
|
-
user.associate = function (models) {
|
|
54
|
-
user.belongsTo(models.member, { foreignKey: "memberId", as: "member" });
|
|
55
|
-
user.belongsTo(models.subRole, { foreignKey: "subRoleId", as: "subRole" });
|
|
56
|
-
};
|
|
57
|
-
const selectedFields = [
|
|
58
|
-
"id",
|
|
59
|
-
"memberId",
|
|
60
|
-
"username",
|
|
61
|
-
"email",
|
|
62
|
-
"roleId",
|
|
63
|
-
"subRoleId",
|
|
64
|
-
"enableLoginAccess",
|
|
65
|
-
"status",
|
|
66
|
-
"lastLogin",
|
|
67
|
-
"createdAt",
|
|
68
|
-
"updatedAt",
|
|
69
|
-
]
|
|
70
|
-
user.selectedFields = [
|
|
71
|
-
...selectedFields,
|
|
72
|
-
"password"
|
|
73
|
-
];
|
|
74
|
-
user.responseFields = selectedFields;
|
|
75
|
-
user.listFields = selectedFields;
|
|
76
|
-
user.transferFields = selectedFields;
|
|
77
|
-
return user;
|
|
78
|
-
};
|
|
1
|
+
const utils = require("../../utils");
|
|
2
|
+
//
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const user = sequelize.define(
|
|
5
|
+
"User",
|
|
6
|
+
{
|
|
7
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
+
|
|
9
|
+
// Link to the individual profile
|
|
10
|
+
memberId: {
|
|
11
|
+
type: DataTypes.INTEGER,
|
|
12
|
+
set(memberId) {
|
|
13
|
+
this.setDataValue("memberId", memberId?.id || memberId);
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// Authentication Fields
|
|
18
|
+
username: {
|
|
19
|
+
type: DataTypes.STRING,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
unique: true,
|
|
22
|
+
},
|
|
23
|
+
password: {
|
|
24
|
+
type: DataTypes.STRING,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
set(password) {
|
|
27
|
+
if (password) {
|
|
28
|
+
const encrypted = utils.genHash(password);
|
|
29
|
+
this.setDataValue("password", encrypted);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
email: {
|
|
34
|
+
type: DataTypes.STRING,
|
|
35
|
+
allowNull: false,
|
|
36
|
+
unique: true,
|
|
37
|
+
validate: { isEmail: true },
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// Roles & Permissions
|
|
41
|
+
roleId: { type: DataTypes.INTEGER },
|
|
42
|
+
subRoleId: { type: DataTypes.INTEGER },
|
|
43
|
+
enableLoginAccess: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
44
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
45
|
+
|
|
46
|
+
// Metadata
|
|
47
|
+
lastLogin: { type: DataTypes.DATE },
|
|
48
|
+
createdAt: { type: DataTypes.DATE },
|
|
49
|
+
updatedAt: { type: DataTypes.DATE },
|
|
50
|
+
},
|
|
51
|
+
{ freezeTableName: true, timestamps: false }
|
|
52
|
+
);
|
|
53
|
+
user.associate = function (models) {
|
|
54
|
+
user.belongsTo(models.member, { foreignKey: "memberId", as: "member" });
|
|
55
|
+
user.belongsTo(models.subRole, { foreignKey: "subRoleId", as: "subRole" });
|
|
56
|
+
};
|
|
57
|
+
const selectedFields = [
|
|
58
|
+
"id",
|
|
59
|
+
"memberId",
|
|
60
|
+
"username",
|
|
61
|
+
"email",
|
|
62
|
+
"roleId",
|
|
63
|
+
"subRoleId",
|
|
64
|
+
"enableLoginAccess",
|
|
65
|
+
"status",
|
|
66
|
+
"lastLogin",
|
|
67
|
+
"createdAt",
|
|
68
|
+
"updatedAt",
|
|
69
|
+
]
|
|
70
|
+
user.selectedFields = [
|
|
71
|
+
...selectedFields,
|
|
72
|
+
"password"
|
|
73
|
+
];
|
|
74
|
+
user.responseFields = selectedFields;
|
|
75
|
+
user.listFields = selectedFields;
|
|
76
|
+
user.transferFields = selectedFields;
|
|
77
|
+
return user;
|
|
78
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const { TRANSFER_STATUS } = require("../../constants");
|
|
2
|
-
|
|
3
|
-
module.exports = (sequelize, DataTypes) => {
|
|
4
|
-
const userTransfer = sequelize.define(
|
|
5
|
-
"UserTransfer",
|
|
6
|
-
{
|
|
7
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
-
transferType: { type: DataTypes.STRING },
|
|
9
|
-
transferStatus: {
|
|
10
|
-
type: DataTypes.STRING,
|
|
11
|
-
defaultValue: TRANSFER_STATUS.PENDING,
|
|
12
|
-
},
|
|
13
|
-
targetFamilyCode: { type: DataTypes.STRING },
|
|
14
|
-
remarks: { type: DataTypes.TEXT },
|
|
15
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
16
|
-
toUserId: { type: DataTypes.INTEGER },
|
|
17
|
-
createdBy: { type: DataTypes.INTEGER },
|
|
18
|
-
createdAt: {
|
|
19
|
-
type: DataTypes.DATE,
|
|
20
|
-
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
21
|
-
},
|
|
22
|
-
updatedAt: {
|
|
23
|
-
type: DataTypes.DATE,
|
|
24
|
-
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{ freezeTableName: true, timestamps: false }
|
|
28
|
-
);
|
|
29
|
-
userTransfer.associate = function (models) {
|
|
30
|
-
userTransfer.belongsTo(models.user, { foreignKey: "toUserId", as: "toUser" });
|
|
31
|
-
userTransfer.belongsTo(models.user, { foreignKey: "createdBy", as: "createdByUser" });
|
|
32
|
-
};
|
|
33
|
-
userTransfer.selectedFields = [
|
|
34
|
-
"id",
|
|
35
|
-
"transferType",
|
|
36
|
-
"transferStatus",
|
|
37
|
-
"targetFamilyCode",
|
|
38
|
-
"remarks",
|
|
39
|
-
"toUserId",
|
|
40
|
-
"createdBy",
|
|
41
|
-
"createdAt",
|
|
42
|
-
"updatedAt",
|
|
43
|
-
];
|
|
44
|
-
return userTransfer;
|
|
45
|
-
};
|
|
1
|
+
const { TRANSFER_STATUS } = require("../../constants");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const userTransfer = sequelize.define(
|
|
5
|
+
"UserTransfer",
|
|
6
|
+
{
|
|
7
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
+
transferType: { type: DataTypes.STRING },
|
|
9
|
+
transferStatus: {
|
|
10
|
+
type: DataTypes.STRING,
|
|
11
|
+
defaultValue: TRANSFER_STATUS.PENDING,
|
|
12
|
+
},
|
|
13
|
+
targetFamilyCode: { type: DataTypes.STRING },
|
|
14
|
+
remarks: { type: DataTypes.TEXT },
|
|
15
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
16
|
+
toUserId: { type: DataTypes.INTEGER },
|
|
17
|
+
createdBy: { type: DataTypes.INTEGER },
|
|
18
|
+
createdAt: {
|
|
19
|
+
type: DataTypes.DATE,
|
|
20
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
21
|
+
},
|
|
22
|
+
updatedAt: {
|
|
23
|
+
type: DataTypes.DATE,
|
|
24
|
+
defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{ freezeTableName: true, timestamps: false }
|
|
28
|
+
);
|
|
29
|
+
userTransfer.associate = function (models) {
|
|
30
|
+
userTransfer.belongsTo(models.user, { foreignKey: "toUserId", as: "toUser" });
|
|
31
|
+
userTransfer.belongsTo(models.user, { foreignKey: "createdBy", as: "createdByUser" });
|
|
32
|
+
};
|
|
33
|
+
userTransfer.selectedFields = [
|
|
34
|
+
"id",
|
|
35
|
+
"transferType",
|
|
36
|
+
"transferStatus",
|
|
37
|
+
"targetFamilyCode",
|
|
38
|
+
"remarks",
|
|
39
|
+
"toUserId",
|
|
40
|
+
"createdBy",
|
|
41
|
+
"createdAt",
|
|
42
|
+
"updatedAt",
|
|
43
|
+
];
|
|
44
|
+
return userTransfer;
|
|
45
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const volunteer = sequelize.define(
|
|
3
|
-
"Volunteer",
|
|
4
|
-
{
|
|
5
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
-
title: { type: DataTypes.TEXT },
|
|
7
|
-
content: { type: DataTypes.TEXT },
|
|
8
|
-
type: { type: DataTypes.STRING },
|
|
9
|
-
year: { type: DataTypes.STRING },
|
|
10
|
-
original_name: { type: DataTypes.STRING },
|
|
11
|
-
url: { type: DataTypes.TEXT },
|
|
12
|
-
order: { type: DataTypes.INTEGER },
|
|
13
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
14
|
-
createdAt: { type: DataTypes.DATE },
|
|
15
|
-
updatedAt: { type: DataTypes.DATE },
|
|
16
|
-
},
|
|
17
|
-
{ freezeTableName: true, timestamps: false }
|
|
18
|
-
);
|
|
19
|
-
volunteer.selectedFields = [
|
|
20
|
-
"id",
|
|
21
|
-
"title",
|
|
22
|
-
"content",
|
|
23
|
-
"type",
|
|
24
|
-
"year",
|
|
25
|
-
"original_name",
|
|
26
|
-
"url",
|
|
27
|
-
"order",
|
|
28
|
-
"status",
|
|
29
|
-
"createdAt",
|
|
30
|
-
"updatedAt",
|
|
31
|
-
];
|
|
32
|
-
return volunteer;
|
|
33
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const volunteer = sequelize.define(
|
|
3
|
+
"Volunteer",
|
|
4
|
+
{
|
|
5
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
title: { type: DataTypes.TEXT },
|
|
7
|
+
content: { type: DataTypes.TEXT },
|
|
8
|
+
type: { type: DataTypes.STRING },
|
|
9
|
+
year: { type: DataTypes.STRING },
|
|
10
|
+
original_name: { type: DataTypes.STRING },
|
|
11
|
+
url: { type: DataTypes.TEXT },
|
|
12
|
+
order: { type: DataTypes.INTEGER },
|
|
13
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
14
|
+
createdAt: { type: DataTypes.DATE },
|
|
15
|
+
updatedAt: { type: DataTypes.DATE },
|
|
16
|
+
},
|
|
17
|
+
{ freezeTableName: true, timestamps: false }
|
|
18
|
+
);
|
|
19
|
+
volunteer.selectedFields = [
|
|
20
|
+
"id",
|
|
21
|
+
"title",
|
|
22
|
+
"content",
|
|
23
|
+
"type",
|
|
24
|
+
"year",
|
|
25
|
+
"original_name",
|
|
26
|
+
"url",
|
|
27
|
+
"order",
|
|
28
|
+
"status",
|
|
29
|
+
"createdAt",
|
|
30
|
+
"updatedAt",
|
|
31
|
+
];
|
|
32
|
+
return volunteer;
|
|
33
|
+
};
|
package/models/common/church.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
const { ONBOARD_STATUS } = require("../../constants");
|
|
2
|
-
|
|
3
|
-
module.exports = (sequelize, DataTypes) => {
|
|
4
|
-
const church = sequelize.define(
|
|
5
|
-
"Church",
|
|
6
|
-
{
|
|
7
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
-
name: { type: DataTypes.STRING },
|
|
9
|
-
connectionUrl: { type: DataTypes.STRING },
|
|
10
|
-
email: { type: DataTypes.STRING },
|
|
11
|
-
phoneNumber: { type: DataTypes.STRING },
|
|
12
|
-
contactPerson: { type: DataTypes.STRING },
|
|
13
|
-
registeredAt: { type: DataTypes.DATEONLY },
|
|
14
|
-
subscribedAt: { type: DataTypes.DATEONLY },
|
|
15
|
-
subscriptionPlanId: { type: DataTypes.INTEGER },
|
|
16
|
-
expiresAt: { type: DataTypes.DATEONLY },
|
|
17
|
-
dbCreationStatus: {
|
|
18
|
-
type: DataTypes.STRING,
|
|
19
|
-
defaultValue: ONBOARD_STATUS.DB_CREATION_IN_PROGRESS,
|
|
20
|
-
},
|
|
21
|
-
migrationStatus: { type: DataTypes.STRING },
|
|
22
|
-
seedStatus: { type: DataTypes.STRING },
|
|
23
|
-
status: { type: DataTypes.BOOLEAN },
|
|
24
|
-
createdAt: { type: DataTypes.DATE },
|
|
25
|
-
updatedAt: { type: DataTypes.DATE },
|
|
26
|
-
},
|
|
27
|
-
{ freezeTableName: true, timestamps: false }
|
|
28
|
-
);
|
|
29
|
-
church.associate = function (models) {
|
|
30
|
-
church.hasMany(models.churchDomain, {
|
|
31
|
-
foreignKey: "churchId",
|
|
32
|
-
as: "churchDomain",
|
|
33
|
-
});
|
|
34
|
-
church.belongsTo(models.subscriptionPlan, {
|
|
35
|
-
foreignKey: "subscriptionPlanId",
|
|
36
|
-
as: "subscriptionPlan",
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
church.selectedFields = [
|
|
40
|
-
"id",
|
|
41
|
-
"name",
|
|
42
|
-
"connectionUrl",
|
|
43
|
-
"email",
|
|
44
|
-
"phoneNumber",
|
|
45
|
-
"contactPerson",
|
|
46
|
-
"registeredAt",
|
|
47
|
-
"subscribedAt",
|
|
48
|
-
"expiresAt",
|
|
49
|
-
"subscriptionPlanId",
|
|
50
|
-
"dbCreationStatus",
|
|
51
|
-
"migrationStatus",
|
|
52
|
-
"seedStatus",
|
|
53
|
-
"status",
|
|
54
|
-
"createdAt",
|
|
55
|
-
"updatedAt",
|
|
56
|
-
];
|
|
57
|
-
return church;
|
|
58
|
-
};
|
|
1
|
+
const { ONBOARD_STATUS } = require("../../constants");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const church = sequelize.define(
|
|
5
|
+
"Church",
|
|
6
|
+
{
|
|
7
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
+
name: { type: DataTypes.STRING },
|
|
9
|
+
connectionUrl: { type: DataTypes.STRING },
|
|
10
|
+
email: { type: DataTypes.STRING },
|
|
11
|
+
phoneNumber: { type: DataTypes.STRING },
|
|
12
|
+
contactPerson: { type: DataTypes.STRING },
|
|
13
|
+
registeredAt: { type: DataTypes.DATEONLY },
|
|
14
|
+
subscribedAt: { type: DataTypes.DATEONLY },
|
|
15
|
+
subscriptionPlanId: { type: DataTypes.INTEGER },
|
|
16
|
+
expiresAt: { type: DataTypes.DATEONLY },
|
|
17
|
+
dbCreationStatus: {
|
|
18
|
+
type: DataTypes.STRING,
|
|
19
|
+
defaultValue: ONBOARD_STATUS.DB_CREATION_IN_PROGRESS,
|
|
20
|
+
},
|
|
21
|
+
migrationStatus: { type: DataTypes.STRING },
|
|
22
|
+
seedStatus: { type: DataTypes.STRING },
|
|
23
|
+
status: { type: DataTypes.BOOLEAN },
|
|
24
|
+
createdAt: { type: DataTypes.DATE },
|
|
25
|
+
updatedAt: { type: DataTypes.DATE },
|
|
26
|
+
},
|
|
27
|
+
{ freezeTableName: true, timestamps: false }
|
|
28
|
+
);
|
|
29
|
+
church.associate = function (models) {
|
|
30
|
+
church.hasMany(models.churchDomain, {
|
|
31
|
+
foreignKey: "churchId",
|
|
32
|
+
as: "churchDomain",
|
|
33
|
+
});
|
|
34
|
+
church.belongsTo(models.subscriptionPlan, {
|
|
35
|
+
foreignKey: "subscriptionPlanId",
|
|
36
|
+
as: "subscriptionPlan",
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
church.selectedFields = [
|
|
40
|
+
"id",
|
|
41
|
+
"name",
|
|
42
|
+
"connectionUrl",
|
|
43
|
+
"email",
|
|
44
|
+
"phoneNumber",
|
|
45
|
+
"contactPerson",
|
|
46
|
+
"registeredAt",
|
|
47
|
+
"subscribedAt",
|
|
48
|
+
"expiresAt",
|
|
49
|
+
"subscriptionPlanId",
|
|
50
|
+
"dbCreationStatus",
|
|
51
|
+
"migrationStatus",
|
|
52
|
+
"seedStatus",
|
|
53
|
+
"status",
|
|
54
|
+
"createdAt",
|
|
55
|
+
"updatedAt",
|
|
56
|
+
];
|
|
57
|
+
return church;
|
|
58
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const churchDomain = sequelize.define(
|
|
3
|
-
"ChurchDomain",
|
|
4
|
-
{
|
|
5
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
-
churchId: { type: DataTypes.INTEGER },
|
|
7
|
-
domain: { type: DataTypes.STRING },
|
|
8
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
9
|
-
createdAt: { type: DataTypes.DATE },
|
|
10
|
-
updatedAt: { type: DataTypes.DATE },
|
|
11
|
-
},
|
|
12
|
-
{ freezeTableName: true, timestamps: false }
|
|
13
|
-
);
|
|
14
|
-
churchDomain.associate = (models) => {
|
|
15
|
-
churchDomain.belongsTo(models.church, {
|
|
16
|
-
foreignKey: "churchId",
|
|
17
|
-
as: "church",
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
return churchDomain;
|
|
21
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const churchDomain = sequelize.define(
|
|
3
|
+
"ChurchDomain",
|
|
4
|
+
{
|
|
5
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
churchId: { type: DataTypes.INTEGER },
|
|
7
|
+
domain: { type: DataTypes.STRING },
|
|
8
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
9
|
+
createdAt: { type: DataTypes.DATE },
|
|
10
|
+
updatedAt: { type: DataTypes.DATE },
|
|
11
|
+
},
|
|
12
|
+
{ freezeTableName: true, timestamps: false }
|
|
13
|
+
);
|
|
14
|
+
churchDomain.associate = (models) => {
|
|
15
|
+
churchDomain.belongsTo(models.church, {
|
|
16
|
+
foreignKey: "churchId",
|
|
17
|
+
as: "church",
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
return churchDomain;
|
|
21
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const churchPermission = sequelize.define(
|
|
3
|
-
"ChurchPermission",
|
|
4
|
-
{
|
|
5
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
-
churchId: { type: DataTypes.INTEGER },
|
|
7
|
-
permissionId: { type: DataTypes.INTEGER },
|
|
8
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
9
|
-
createdAt: { type: DataTypes.DATE },
|
|
10
|
-
updatedAt: { type: DataTypes.DATE },
|
|
11
|
-
},
|
|
12
|
-
{ freezeTableName: true, timestamps: false }
|
|
13
|
-
);
|
|
14
|
-
churchPermission.associate = function (models) {
|
|
15
|
-
churchPermission.belongsTo(models.permission, {
|
|
16
|
-
foreignKey: "permissionId",
|
|
17
|
-
as: "permission",
|
|
18
|
-
});
|
|
19
|
-
churchPermission.belongsTo(models.church, {
|
|
20
|
-
foreignKey: "churchId",
|
|
21
|
-
as: "church",
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
churchPermission.selectedFields = ["id", "churchId", "permissionId", "createdAt"];
|
|
25
|
-
return churchPermission;
|
|
26
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const churchPermission = sequelize.define(
|
|
3
|
+
"ChurchPermission",
|
|
4
|
+
{
|
|
5
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
churchId: { type: DataTypes.INTEGER },
|
|
7
|
+
permissionId: { type: DataTypes.INTEGER },
|
|
8
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
9
|
+
createdAt: { type: DataTypes.DATE },
|
|
10
|
+
updatedAt: { type: DataTypes.DATE },
|
|
11
|
+
},
|
|
12
|
+
{ freezeTableName: true, timestamps: false }
|
|
13
|
+
);
|
|
14
|
+
churchPermission.associate = function (models) {
|
|
15
|
+
churchPermission.belongsTo(models.permission, {
|
|
16
|
+
foreignKey: "permissionId",
|
|
17
|
+
as: "permission",
|
|
18
|
+
});
|
|
19
|
+
churchPermission.belongsTo(models.church, {
|
|
20
|
+
foreignKey: "churchId",
|
|
21
|
+
as: "church",
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
churchPermission.selectedFields = ["id", "churchId", "permissionId", "createdAt"];
|
|
25
|
+
return churchPermission;
|
|
26
|
+
};
|
package/models/common/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const Sequelize = require("sequelize");
|
|
6
|
-
const basename = path.basename(__filename);
|
|
7
|
-
const env = process.env.NODE_ENV || "development";
|
|
8
|
-
const config = require("../../config/config")[env];
|
|
9
|
-
const db = {};
|
|
10
|
-
let sequelize;
|
|
11
|
-
if (config.url) {
|
|
12
|
-
sequelize = new Sequelize(config.url, {
|
|
13
|
-
...config,
|
|
14
|
-
dialectOptions: { multipleStatements: true },
|
|
15
|
-
logging: false,
|
|
16
|
-
});
|
|
17
|
-
} else {
|
|
18
|
-
sequelize = new Sequelize(config.database, config.username, config.password, {
|
|
19
|
-
...config,
|
|
20
|
-
dialectOptions: { multipleStatements: true },
|
|
21
|
-
logging: false,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
db.Sequelize = Sequelize;
|
|
25
|
-
db.sequelize = sequelize;
|
|
26
|
-
db.sequelize.dialect.supports.schemas = true;
|
|
27
|
-
db.config = config;
|
|
28
|
-
sequelize.authenticate();
|
|
29
|
-
console.log(`Database Connection has been established successfully to ${config.database}.`);
|
|
30
|
-
fs.readdirSync(__dirname)
|
|
31
|
-
.filter((file) => file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js")
|
|
32
|
-
.forEach((file) => {
|
|
33
|
-
db[file.split(".")[0]] = require("./" + file)(sequelize, Sequelize);
|
|
34
|
-
});
|
|
35
|
-
Object.keys(db).forEach((modelName) => {
|
|
36
|
-
if (db[modelName].associate) {
|
|
37
|
-
db[modelName].associate(db);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
module.exports = db;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const Sequelize = require("sequelize");
|
|
6
|
+
const basename = path.basename(__filename);
|
|
7
|
+
const env = process.env.NODE_ENV || "development";
|
|
8
|
+
const config = require("../../config/config")[env];
|
|
9
|
+
const db = {};
|
|
10
|
+
let sequelize;
|
|
11
|
+
if (config.url) {
|
|
12
|
+
sequelize = new Sequelize(config.url, {
|
|
13
|
+
...config,
|
|
14
|
+
dialectOptions: { multipleStatements: true },
|
|
15
|
+
logging: false,
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
sequelize = new Sequelize(config.database, config.username, config.password, {
|
|
19
|
+
...config,
|
|
20
|
+
dialectOptions: { multipleStatements: true },
|
|
21
|
+
logging: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
db.Sequelize = Sequelize;
|
|
25
|
+
db.sequelize = sequelize;
|
|
26
|
+
db.sequelize.dialect.supports.schemas = true;
|
|
27
|
+
db.config = config;
|
|
28
|
+
sequelize.authenticate();
|
|
29
|
+
console.log(`Database Connection has been established successfully to ${config.database}.`);
|
|
30
|
+
fs.readdirSync(__dirname)
|
|
31
|
+
.filter((file) => file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js")
|
|
32
|
+
.forEach((file) => {
|
|
33
|
+
db[file.split(".")[0]] = require("./" + file)(sequelize, Sequelize);
|
|
34
|
+
});
|
|
35
|
+
Object.keys(db).forEach((modelName) => {
|
|
36
|
+
if (db[modelName].associate) {
|
|
37
|
+
db[modelName].associate(db);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
module.exports = db;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const permission = sequelize.define(
|
|
3
|
-
"Permission",
|
|
4
|
-
{
|
|
5
|
-
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
-
name: { type: DataTypes.STRING },
|
|
7
|
-
isSubscription: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
8
|
-
cost: { type: DataTypes.FLOAT, defaultValue: 0 },
|
|
9
|
-
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
10
|
-
createdAt: { type: DataTypes.DATE },
|
|
11
|
-
updatedAt: { type: DataTypes.DATE },
|
|
12
|
-
},
|
|
13
|
-
{ freezeTableName: true, timestamps: false }
|
|
14
|
-
);
|
|
15
|
-
permission.selectedFields = ["id", "name", "isSubscription", "cost", "createdAt"];
|
|
16
|
-
return permission;
|
|
17
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const permission = sequelize.define(
|
|
3
|
+
"Permission",
|
|
4
|
+
{
|
|
5
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
name: { type: DataTypes.STRING },
|
|
7
|
+
isSubscription: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
8
|
+
cost: { type: DataTypes.FLOAT, defaultValue: 0 },
|
|
9
|
+
status: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
10
|
+
createdAt: { type: DataTypes.DATE },
|
|
11
|
+
updatedAt: { type: DataTypes.DATE },
|
|
12
|
+
},
|
|
13
|
+
{ freezeTableName: true, timestamps: false }
|
|
14
|
+
);
|
|
15
|
+
permission.selectedFields = ["id", "name", "isSubscription", "cost", "createdAt"];
|
|
16
|
+
return permission;
|
|
17
|
+
};
|