@kipicore/dbcore 1.1.646 → 1.1.647
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,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = {
|
|
3
|
+
up: async (queryInterface, Sequelize) => {
|
|
4
|
+
const table = await queryInterface.describeTable('institutes');
|
|
5
|
+
if (table.status) {
|
|
6
|
+
// In PostgreSQL, changing from ENUM to VARCHAR often requires a USING clause
|
|
7
|
+
try {
|
|
8
|
+
await queryInterface.sequelize.query('ALTER TABLE institutes ALTER COLUMN status TYPE VARCHAR(255) USING status::varchar;');
|
|
9
|
+
await queryInterface.changeColumn('institutes', 'status', {
|
|
10
|
+
type: Sequelize.STRING,
|
|
11
|
+
allowNull: false,
|
|
12
|
+
defaultValue: 'ACTIVE',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
// Fallback if the raw query fails
|
|
17
|
+
await queryInterface.changeColumn('institutes', 'status', {
|
|
18
|
+
type: Sequelize.STRING,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
defaultValue: 'ACTIVE',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
down: async (queryInterface, Sequelize) => {
|
|
26
|
+
const table = await queryInterface.describeTable('institutes');
|
|
27
|
+
if (table.status) {
|
|
28
|
+
try {
|
|
29
|
+
await queryInterface.sequelize.query('ALTER TABLE institutes ALTER COLUMN status TYPE "enum_institutes_status" USING status::text::"enum_institutes_status";');
|
|
30
|
+
await queryInterface.changeColumn('institutes', 'status', {
|
|
31
|
+
type: Sequelize.ENUM('ACTIVE', 'INACTIVE', 'PENDING', 'BLOCKED'), // Typical statuses, can adapt if needed
|
|
32
|
+
allowNull: false,
|
|
33
|
+
defaultValue: 'ACTIVE',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
// Fallback
|
|
38
|
+
await queryInterface.changeColumn('institutes', 'status', {
|
|
39
|
+
type: Sequelize.ENUM('ACTIVE', 'INACTIVE', 'PENDING', 'BLOCKED'),
|
|
40
|
+
allowNull: false,
|
|
41
|
+
defaultValue: 'ACTIVE',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -65,10 +65,9 @@ InstituteModel.init({
|
|
|
65
65
|
name: { type: sequelize_1.DataTypes.STRING(100), allowNull: false },
|
|
66
66
|
email: { type: sequelize_1.DataTypes.STRING(50), allowNull: false },
|
|
67
67
|
status: {
|
|
68
|
-
type: sequelize_1.DataTypes.
|
|
68
|
+
type: sequelize_1.DataTypes.STRING,
|
|
69
69
|
allowNull: false,
|
|
70
70
|
defaultValue: app_1.INSTITUTE_STATUS.ACTIVE,
|
|
71
|
-
values: Object.values(app_1.INSTITUTE_STATUS),
|
|
72
71
|
},
|
|
73
72
|
type: {
|
|
74
73
|
type: sequelize_1.DataTypes.ENUM,
|
package/package.json
CHANGED