@kipicore/dbcore 1.1.244 → 1.1.245
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,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sequelize_1 = require("sequelize");
|
|
4
|
+
exports.default = {
|
|
5
|
+
up: async (queryInterface) => {
|
|
6
|
+
// 1. Change column type to STRING
|
|
7
|
+
await queryInterface.changeColumn('academic_calendars', 'status', {
|
|
8
|
+
type: sequelize_1.DataTypes.STRING,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
defaultValue: 'FUTURE_ACADEMIC_CALENDAR',
|
|
11
|
+
});
|
|
12
|
+
// 2. Drop old ENUM type (Postgres only)
|
|
13
|
+
await queryInterface.sequelize.query(`
|
|
14
|
+
DO $$
|
|
15
|
+
BEGIN
|
|
16
|
+
IF EXISTS (
|
|
17
|
+
SELECT 1 FROM pg_type WHERE typname = 'enum_academic_calendars_status'
|
|
18
|
+
) THEN
|
|
19
|
+
DROP TYPE "enum_academic_calendars_status";
|
|
20
|
+
END IF;
|
|
21
|
+
END$$;
|
|
22
|
+
`);
|
|
23
|
+
},
|
|
24
|
+
down: async (queryInterface) => {
|
|
25
|
+
// 1. Recreate ENUM type
|
|
26
|
+
await queryInterface.sequelize.query(`
|
|
27
|
+
CREATE TYPE "enum_academic_calendars_status" AS ENUM (
|
|
28
|
+
'PAST_ACADEMIC_CALENDAR',
|
|
29
|
+
'CURRENT_ACADEMIC_CALENDAR',
|
|
30
|
+
'FUTURE_ACADEMIC_CALENDAR',
|
|
31
|
+
'SUB_ACADEMIC_CALENDAR'
|
|
32
|
+
);
|
|
33
|
+
`);
|
|
34
|
+
// 2. Convert STRING back to ENUM
|
|
35
|
+
await queryInterface.changeColumn('academic_calendars', 'status', {
|
|
36
|
+
type: sequelize_1.DataTypes.ENUM('PAST_ACADEMIC_CALENDAR', 'CURRENT_ACADEMIC_CALENDAR', 'FUTURE_ACADEMIC_CALENDAR', 'SUB_ACADEMIC_CALENDAR'),
|
|
37
|
+
allowNull: false,
|
|
38
|
+
defaultValue: 'FUTURE_ACADEMIC_CALENDAR',
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
};
|
package/package.json
CHANGED