@churchsoln/dbms 1.0.18 → 1.0.20

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.
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, DataTypes) => {
5
+ await queryInterface
6
+ .createTable(
7
+ "Pledge",
8
+ {
9
+ id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
10
+ userId: { type: DataTypes.INTEGER },
11
+ accountId: { type: DataTypes.INTEGER },
12
+ frequency: { type: DataTypes.STRING },
13
+ duration: { type: DataTypes.INTEGER },
14
+ pledged: { type: DataTypes.INTEGER },
15
+ received: { type: DataTypes.INTEGER },
16
+ remaining: { type: DataTypes.INTEGER },
17
+ status: { type: DataTypes.BOOLEAN, defaultValue: true },
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
+ createdBy: { type: DataTypes.INTEGER },
27
+ updatedBy: { type: DataTypes.INTEGER },
28
+ deletedAt: { type: DataTypes.DATE },
29
+ deletedBy: { type: DataTypes.INTEGER },
30
+ },
31
+ { timestamps: false }
32
+ )
33
+ .then(() =>
34
+ queryInterface.addConstraint("Pledge", {
35
+ fields: ["userId"],
36
+ type: "foreign key",
37
+ name: "Pledge_UserId_Fkey",
38
+ references: {
39
+ table: "User",
40
+ field: "id",
41
+ },
42
+ onDelete: "cascade",
43
+ onUpdate: "cascade",
44
+ })
45
+ ).then(() =>
46
+ queryInterface.addConstraint("Pledge", {
47
+ fields: ["accountId"],
48
+ type: "foreign key",
49
+ name: "Pledge_AccountId_Fkey",
50
+ references: {
51
+ table: "Accounts",
52
+ field: "id",
53
+ },
54
+ onDelete: "cascade",
55
+ onUpdate: "cascade",
56
+ })
57
+ ).then(() =>
58
+ queryInterface.addConstraint("Pledge", {
59
+ fields: ["createdBy"],
60
+ type: "foreign key",
61
+ name: "Pledge_CreatedBy_Fkey",
62
+ references: {
63
+ table: "User",
64
+ field: "id",
65
+ },
66
+ onDelete: "cascade",
67
+ onUpdate: "cascade",
68
+ })
69
+ ).then(() =>
70
+ queryInterface.addConstraint("Pledge", {
71
+ fields: ["updatedBy"],
72
+ type: "foreign key",
73
+ name: "Pledge_UpdatedBy_Fkey",
74
+ references: {
75
+ table: "User",
76
+ field: "id",
77
+ },
78
+ onDelete: "cascade",
79
+ onUpdate: "cascade",
80
+ })
81
+ ).then(() =>
82
+ queryInterface.addConstraint("Pledge", {
83
+ fields: ["deletedBy"],
84
+ type: "foreign key",
85
+ name: "Pledge_DeletedBy_Fkey",
86
+ references: {
87
+ table: "User",
88
+ field: "id",
89
+ },
90
+ onDelete: "cascade",
91
+ onUpdate: "cascade",
92
+ })
93
+ );
94
+ },
95
+ down: async (queryInterface) => {
96
+ await queryInterface.dropTable("Pledge");
97
+ },
98
+ };
@@ -0,0 +1,69 @@
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const pledge = sequelize.define(
3
+ "Pledge",
4
+ {
5
+ id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
6
+ userId: { type: DataTypes.INTEGER },
7
+ accountId: { type: DataTypes.INTEGER },
8
+ frequency: { type: DataTypes.STRING },
9
+ duration: { type: DataTypes.INTEGER },
10
+ pledged: { type: DataTypes.INTEGER },
11
+ received: { type: DataTypes.INTEGER },
12
+ remaining: { type: DataTypes.INTEGER },
13
+ status: { type: DataTypes.BOOLEAN, defaultValue: true },
14
+ createdAt: {
15
+ type: DataTypes.DATE,
16
+ defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
17
+ },
18
+ updatedAt: {
19
+ type: DataTypes.DATE,
20
+ defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
21
+ },
22
+ createdBy: { type: DataTypes.INTEGER },
23
+ updatedBy: { type: DataTypes.INTEGER },
24
+ deletedAt: { type: DataTypes.DATE },
25
+ deletedBy: { type: DataTypes.INTEGER },
26
+ },
27
+ { freezeTableName: true, timestamps: false }
28
+ );
29
+ pledge.associate = function (models) {
30
+ pledge.belongsTo(models.user, {
31
+ foreignKey: "userId",
32
+ as: "user",
33
+ });
34
+ pledge.belongsTo(models.accounts, {
35
+ foreignKey: "accountId",
36
+ as: "accounts",
37
+ });
38
+ pledge.belongsTo(models.user, {
39
+ foreignKey: "createdBy",
40
+ as: "createdByUser",
41
+ });
42
+ pledge.belongsTo(models.user, {
43
+ foreignKey: "updatedBy",
44
+ as: "updatedByUser",
45
+ });
46
+ pledge.belongsTo(models.user, {
47
+ foreignKey: "deletedBy",
48
+ as: "deletedByUser",
49
+ });
50
+ };
51
+ pledge.selectedFields = [
52
+ "id",
53
+ "userId",
54
+ "accountId",
55
+ "frequency",
56
+ "duration",
57
+ "pledged",
58
+ "received",
59
+ "remaining",
60
+ "status",
61
+ "createdAt",
62
+ "updatedAt",
63
+ "createdBy",
64
+ "updatedBy",
65
+ "deletedAt",
66
+ "deletedBy",
67
+ ];
68
+ return pledge;
69
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchsoln/dbms",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "prestart": "node db-setup.js",