@kipicore/dbcore 1.1.478 → 1.1.480

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.
@@ -3,11 +3,22 @@ module.exports = {
3
3
  up: async (queryInterface, Sequelize) => {
4
4
  const transaction = await queryInterface.sequelize.transaction();
5
5
  try {
6
+ // First convert ENUM to STRING using explicit cast
7
+ await queryInterface.sequelize.query(`
8
+ ALTER TABLE "user_payouts"
9
+ ALTER COLUMN "type" DROP DEFAULT,
10
+ ALTER COLUMN "type" TYPE VARCHAR USING "type"::text;
11
+ `, { transaction });
12
+ // Then set new default value
6
13
  await queryInterface.changeColumn('user_payouts', 'type', {
7
14
  type: Sequelize.STRING,
8
- allowNull: false,
15
+ allowNull: true,
9
16
  defaultValue: 'NONE',
10
17
  }, { transaction });
18
+ // Optional: Drop old enum type if no longer needed
19
+ await queryInterface.sequelize.query(`
20
+ DROP TYPE IF EXISTS "enum_user_payouts_type";
21
+ `, { transaction });
11
22
  await transaction.commit();
12
23
  }
13
24
  catch (error) {
@@ -18,6 +29,17 @@ module.exports = {
18
29
  down: async (queryInterface, Sequelize) => {
19
30
  const transaction = await queryInterface.sequelize.transaction();
20
31
  try {
32
+ // Recreate ENUM type
33
+ await queryInterface.sequelize.query(`
34
+ CREATE TYPE "enum_user_payouts_type" AS ENUM
35
+ ('PERCENTAGE', 'HOURLY', 'MONTHLY', 'ANNUAL', 'NONE');
36
+ `, { transaction });
37
+ await queryInterface.sequelize.query(`
38
+ ALTER TABLE "user_payouts"
39
+ ALTER COLUMN "type" DROP DEFAULT,
40
+ ALTER COLUMN "type" TYPE "enum_user_payouts_type"
41
+ USING "type"::"enum_user_payouts_type";
42
+ `, { transaction });
21
43
  await queryInterface.changeColumn('user_payouts', 'type', {
22
44
  type: Sequelize.ENUM('PERCENTAGE', 'HOURLY', 'MONTHLY', 'ANNUAL', 'NONE'),
23
45
  allowNull: false,
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -3,10 +3,10 @@ module.exports = {
3
3
  up: async (queryInterface, Sequelize) => {
4
4
  const transaction = await queryInterface.sequelize.transaction();
5
5
  try {
6
- await queryInterface.changeColumn('user_payout_details', 'type', {
7
- type: Sequelize.STRING,
8
- allowNull: false,
9
- defaultValue: 'NONE',
6
+ await queryInterface.addColumn('payout_transaction_histories', 'paid_amount', {
7
+ type: Sequelize.FLOAT,
8
+ allowNull: true,
9
+ defaultValue: 0,
10
10
  }, { transaction });
11
11
  await transaction.commit();
12
12
  }
@@ -15,13 +15,10 @@ module.exports = {
15
15
  throw error;
16
16
  }
17
17
  },
18
- down: async (queryInterface, Sequelize) => {
18
+ down: async (queryInterface) => {
19
19
  const transaction = await queryInterface.sequelize.transaction();
20
20
  try {
21
- await queryInterface.changeColumn('user_payout_details', 'type', {
22
- type: Sequelize.ENUM('PERCENTAGE', 'HOURLY', 'MONTHLY', 'ANNUAL', 'NONE'),
23
- allowNull: false,
24
- }, { transaction });
21
+ await queryInterface.removeColumn('payout_transaction_histories', 'paid_amount', { transaction });
25
22
  await transaction.commit();
26
23
  }
27
24
  catch (error) {
@@ -9,8 +9,9 @@ export interface IPayoutTransactionHistoryModelAttributes {
9
9
  payableAmount: number;
10
10
  additionalPayoutIds: string[];
11
11
  paidDate?: Date;
12
- payoutDate?: string;
12
+ payoutDate?: Date;
13
13
  status?: PAYOUT_STATUS;
14
+ paidAmount: number;
14
15
  createdBy?: string;
15
16
  updatedBy?: string;
16
17
  deletedBy?: string;
@@ -14,6 +14,7 @@ declare class PayoutTransactionHistoryModel extends Model<IPayoutTransactionHist
14
14
  paidDate: Date;
15
15
  payoutDate: Date;
16
16
  status: PAYOUT_STATUS;
17
+ paidAmount: number;
17
18
  createdBy: string;
18
19
  updatedBy: string;
19
20
  deletedBy: string;
@@ -72,6 +72,12 @@ PayoutTransactionHistoryModel.init({
72
72
  defaultValue: 0,
73
73
  field: 'total_amount',
74
74
  },
75
+ paidAmount: {
76
+ type: sequelize_1.DataTypes.FLOAT,
77
+ allowNull: true,
78
+ defaultValue: 0,
79
+ field: 'paid_amount',
80
+ },
75
81
  payableAmount: {
76
82
  type: sequelize_1.DataTypes.FLOAT,
77
83
  allowNull: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.478",
3
+ "version": "1.1.480",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -1,2 +0,0 @@
1
- export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
- export function down(queryInterface: any, Sequelize: any): Promise<void>;