whitelabel-db 1.5.0 → 1.6.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.
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
// Purpose: Mirror the hotel `bookings` lifecycle for flights — the row is now
|
|
14
|
+
// created at PREBOOK time (before a bookingId exists), keyed by prebookId, then
|
|
15
|
+
// the bookingId is filled in at booking-creation. Adds a unique, indexed
|
|
16
|
+
// `prebookId` column and relaxes `bookingId` to nullable.
|
|
17
|
+
const sequelize_1 = require("sequelize");
|
|
18
|
+
const TABLE_NAME = 'flight_bookings';
|
|
19
|
+
const PREBOOK_ID_COLUMN = 'prebookId';
|
|
20
|
+
const up = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const tableDescription = yield queryInterface.describeTable(TABLE_NAME);
|
|
22
|
+
const existingColumns = Object.keys(tableDescription);
|
|
23
|
+
if (!existingColumns.includes(PREBOOK_ID_COLUMN)) {
|
|
24
|
+
yield queryInterface.addColumn(TABLE_NAME, PREBOOK_ID_COLUMN, {
|
|
25
|
+
type: sequelize_1.DataTypes.STRING,
|
|
26
|
+
allowNull: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// bookingId is unknown until the booking is created — relax NOT NULL.
|
|
30
|
+
yield queryInterface.changeColumn(TABLE_NAME, 'bookingId', {
|
|
31
|
+
type: sequelize_1.DataTypes.STRING,
|
|
32
|
+
allowNull: true,
|
|
33
|
+
});
|
|
34
|
+
// Unique + lookup index on prebookId (fail gracefully if it already exists).
|
|
35
|
+
try {
|
|
36
|
+
yield queryInterface.addIndex(TABLE_NAME, [PREBOOK_ID_COLUMN], {
|
|
37
|
+
name: 'idx_flight_bookings_prebook_id',
|
|
38
|
+
unique: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
43
|
+
if (!message.includes('already exists')) {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
exports.up = up;
|
|
49
|
+
const down = (queryInterface) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const tableDescription = yield queryInterface.describeTable(TABLE_NAME);
|
|
51
|
+
const existingColumns = Object.keys(tableDescription);
|
|
52
|
+
try {
|
|
53
|
+
yield queryInterface.removeIndex(TABLE_NAME, 'idx_flight_bookings_prebook_id');
|
|
54
|
+
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
// index may not exist — ignore
|
|
57
|
+
}
|
|
58
|
+
if (existingColumns.includes(PREBOOK_ID_COLUMN)) {
|
|
59
|
+
yield queryInterface.removeColumn(TABLE_NAME, PREBOOK_ID_COLUMN);
|
|
60
|
+
}
|
|
61
|
+
// Restore NOT NULL on bookingId. Note: only safe if no null rows remain.
|
|
62
|
+
yield queryInterface.changeColumn(TABLE_NAME, 'bookingId', {
|
|
63
|
+
type: sequelize_1.DataTypes.STRING,
|
|
64
|
+
allowNull: false,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
exports.down = down;
|
|
@@ -3,7 +3,8 @@ import { Project } from './Project';
|
|
|
3
3
|
import { Guest } from './Guest';
|
|
4
4
|
export declare class FlightBooking extends Model<Partial<FlightBooking>> {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
6
|
+
prebookId?: string;
|
|
7
|
+
bookingId?: string;
|
|
7
8
|
projectId: string;
|
|
8
9
|
project?: Project;
|
|
9
10
|
ticketedEmailSent: boolean;
|
|
@@ -27,9 +27,18 @@ __decorate([
|
|
|
27
27
|
], FlightBooking.prototype, "id", void 0);
|
|
28
28
|
__decorate([
|
|
29
29
|
sequelize_typescript_1.Unique,
|
|
30
|
+
sequelize_typescript_1.Index,
|
|
30
31
|
(0, sequelize_typescript_1.Column)({
|
|
31
32
|
type: sequelize_typescript_1.DataType.STRING,
|
|
32
|
-
allowNull:
|
|
33
|
+
allowNull: true,
|
|
34
|
+
}),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], FlightBooking.prototype, "prebookId", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
sequelize_typescript_1.Unique,
|
|
39
|
+
(0, sequelize_typescript_1.Column)({
|
|
40
|
+
type: sequelize_typescript_1.DataType.STRING,
|
|
41
|
+
allowNull: true,
|
|
33
42
|
}),
|
|
34
43
|
__metadata("design:type", String)
|
|
35
44
|
], FlightBooking.prototype, "bookingId", void 0);
|