whitelabel-db 1.3.0 → 1.3.1
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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.down = exports.up = void 0;
|
|
13
|
+
const sequelize_1 = require("sequelize");
|
|
14
|
+
const up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
// Change pointsEarned from INTEGER to DECIMAL(12, 2)
|
|
17
|
+
yield queryInterface.changeColumn('booking_loyalty_record', 'pointsEarned', {
|
|
18
|
+
type: sequelize_1.DataTypes.DECIMAL(12, 2),
|
|
19
|
+
allowNull: true,
|
|
20
|
+
});
|
|
21
|
+
// Change pointsBurned from INTEGER to DECIMAL(12, 2)
|
|
22
|
+
yield queryInterface.changeColumn('booking_loyalty_record', 'pointsBurned', {
|
|
23
|
+
type: sequelize_1.DataTypes.DECIMAL(12, 2),
|
|
24
|
+
allowNull: false,
|
|
25
|
+
defaultValue: 0,
|
|
26
|
+
});
|
|
27
|
+
// Add tierId column
|
|
28
|
+
yield queryInterface.addColumn('booking_loyalty_record', 'tierId', {
|
|
29
|
+
type: sequelize_1.DataTypes.UUID,
|
|
30
|
+
allowNull: true,
|
|
31
|
+
references: {
|
|
32
|
+
model: 'loyalty_program_tier',
|
|
33
|
+
key: 'id',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
// Add index on tierId
|
|
37
|
+
yield queryInterface.addIndex('booking_loyalty_record', ['tierId'], {
|
|
38
|
+
name: 'idx_booking_loyalty_record_tier_id',
|
|
39
|
+
});
|
|
40
|
+
console.log('booking_loyalty_record updated successfully.');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error('Error in migration:', error.message);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
exports.up = up;
|
|
47
|
+
const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
// Remove index on tierId
|
|
50
|
+
yield queryInterface.removeIndex('booking_loyalty_record', 'idx_booking_loyalty_record_tier_id');
|
|
51
|
+
// Remove tierId column
|
|
52
|
+
yield queryInterface.removeColumn('booking_loyalty_record', 'tierId');
|
|
53
|
+
// Revert pointsBurned to INTEGER
|
|
54
|
+
yield queryInterface.changeColumn('booking_loyalty_record', 'pointsBurned', {
|
|
55
|
+
type: sequelize_1.DataTypes.INTEGER,
|
|
56
|
+
allowNull: false,
|
|
57
|
+
defaultValue: 0,
|
|
58
|
+
});
|
|
59
|
+
// Revert pointsEarned to INTEGER
|
|
60
|
+
yield queryInterface.changeColumn('booking_loyalty_record', 'pointsEarned', {
|
|
61
|
+
type: sequelize_1.DataTypes.INTEGER,
|
|
62
|
+
allowNull: true,
|
|
63
|
+
});
|
|
64
|
+
console.log('booking_loyalty_record rollback successful.');
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error('Error in rollback:', error.message);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
exports.down = down;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Model } from 'sequelize-typescript';
|
|
2
2
|
import { Booking } from './Booking';
|
|
3
3
|
import { LoyaltyProgram } from './LoyaltyProgram';
|
|
4
|
-
import { EarnRule } from './LoyaltyProgramTier';
|
|
4
|
+
import { LoyaltyProgramTier, EarnRule } from './LoyaltyProgramTier';
|
|
5
5
|
export declare class BookingLoyaltyRecord extends Model<Partial<BookingLoyaltyRecord>> {
|
|
6
6
|
id: string;
|
|
7
7
|
bookingId: string;
|
|
8
8
|
booking?: Booking;
|
|
9
9
|
loyaltyProgramId: string;
|
|
10
10
|
loyaltyProgram?: LoyaltyProgram;
|
|
11
|
+
tierId?: string;
|
|
12
|
+
tier?: LoyaltyProgramTier;
|
|
11
13
|
membershipIdentifier?: string;
|
|
12
14
|
tierAtBooking?: string;
|
|
13
15
|
pointsEarned?: number;
|
|
@@ -13,6 +13,7 @@ exports.BookingLoyaltyRecord = void 0;
|
|
|
13
13
|
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
14
|
const Booking_1 = require("./Booking");
|
|
15
15
|
const LoyaltyProgram_1 = require("./LoyaltyProgram");
|
|
16
|
+
const LoyaltyProgramTier_1 = require("./LoyaltyProgramTier");
|
|
16
17
|
let BookingLoyaltyRecord = class BookingLoyaltyRecord extends sequelize_typescript_1.Model {
|
|
17
18
|
};
|
|
18
19
|
exports.BookingLoyaltyRecord = BookingLoyaltyRecord;
|
|
@@ -52,6 +53,20 @@ __decorate([
|
|
|
52
53
|
(0, sequelize_typescript_1.BelongsTo)(() => LoyaltyProgram_1.LoyaltyProgram),
|
|
53
54
|
__metadata("design:type", LoyaltyProgram_1.LoyaltyProgram)
|
|
54
55
|
], BookingLoyaltyRecord.prototype, "loyaltyProgram", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, sequelize_typescript_1.ForeignKey)(() => LoyaltyProgramTier_1.LoyaltyProgramTier),
|
|
58
|
+
sequelize_typescript_1.Index,
|
|
59
|
+
(0, sequelize_typescript_1.Column)({
|
|
60
|
+
type: sequelize_typescript_1.DataType.UUID,
|
|
61
|
+
allowNull: true,
|
|
62
|
+
comment: 'Foreign key to loyalty program tier',
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], BookingLoyaltyRecord.prototype, "tierId", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, sequelize_typescript_1.BelongsTo)(() => LoyaltyProgramTier_1.LoyaltyProgramTier),
|
|
68
|
+
__metadata("design:type", LoyaltyProgramTier_1.LoyaltyProgramTier)
|
|
69
|
+
], BookingLoyaltyRecord.prototype, "tier", void 0);
|
|
55
70
|
__decorate([
|
|
56
71
|
(0, sequelize_typescript_1.Column)({
|
|
57
72
|
type: sequelize_typescript_1.DataType.STRING,
|
|
@@ -70,7 +85,7 @@ __decorate([
|
|
|
70
85
|
], BookingLoyaltyRecord.prototype, "tierAtBooking", void 0);
|
|
71
86
|
__decorate([
|
|
72
87
|
(0, sequelize_typescript_1.Column)({
|
|
73
|
-
type: sequelize_typescript_1.DataType.
|
|
88
|
+
type: sequelize_typescript_1.DataType.DECIMAL(12, 2),
|
|
74
89
|
allowNull: true,
|
|
75
90
|
comment: 'Final points awarded (from partner or WL calc)',
|
|
76
91
|
}),
|
|
@@ -78,7 +93,7 @@ __decorate([
|
|
|
78
93
|
], BookingLoyaltyRecord.prototype, "pointsEarned", void 0);
|
|
79
94
|
__decorate([
|
|
80
95
|
(0, sequelize_typescript_1.Column)({
|
|
81
|
-
type: sequelize_typescript_1.DataType.
|
|
96
|
+
type: sequelize_typescript_1.DataType.DECIMAL(12, 2),
|
|
82
97
|
allowNull: false,
|
|
83
98
|
defaultValue: 0,
|
|
84
99
|
comment: 'Future: points burned for this booking',
|
|
@@ -145,6 +160,10 @@ exports.BookingLoyaltyRecord = BookingLoyaltyRecord = __decorate([
|
|
|
145
160
|
fields: ['loyaltyProgramId'],
|
|
146
161
|
name: 'idx_booking_loyalty_record_program_id',
|
|
147
162
|
},
|
|
163
|
+
{
|
|
164
|
+
fields: ['tierId'],
|
|
165
|
+
name: 'idx_booking_loyalty_record_tier_id',
|
|
166
|
+
},
|
|
148
167
|
],
|
|
149
168
|
})
|
|
150
169
|
], BookingLoyaltyRecord);
|