@kipicore/dbcore 1.1.665 → 1.1.666

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,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any, Sequelize: any): Promise<void>;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+ module.exports = {
3
+ up: async (queryInterface, Sequelize) => {
4
+ const table = await queryInterface.describeTable('file_storage');
5
+ if (table.uploaded_from) {
6
+ // In PostgreSQL, changing from ENUM to VARCHAR requires a USING clause
7
+ try {
8
+ await queryInterface.sequelize.query('ALTER TABLE file_storage ALTER COLUMN uploaded_from TYPE VARCHAR(255) USING uploaded_from::varchar;');
9
+ await queryInterface.changeColumn('file_storage', 'uploaded_from', {
10
+ type: Sequelize.STRING,
11
+ allowNull: true,
12
+ });
13
+ }
14
+ catch (error) {
15
+ // Fallback if the raw query fails
16
+ await queryInterface.changeColumn('file_storage', 'uploaded_from', {
17
+ type: Sequelize.STRING,
18
+ allowNull: true,
19
+ });
20
+ }
21
+ }
22
+ },
23
+ down: async (queryInterface, Sequelize) => {
24
+ const table = await queryInterface.describeTable('file_storage');
25
+ if (table.uploaded_from) {
26
+ try {
27
+ await queryInterface.sequelize.query('ALTER TABLE file_storage ALTER COLUMN uploaded_from TYPE "enum_file_storage_uploaded_from" USING uploaded_from::text::"enum_file_storage_uploaded_from";');
28
+ await queryInterface.changeColumn('file_storage', 'uploaded_from', {
29
+ type: Sequelize.ENUM('INSTITUTE_APP', 'SCHOOL_APP', 'GLOBAL_APP', 'STUDENT_APP', 'VENDOR_APP'),
30
+ allowNull: false,
31
+ });
32
+ }
33
+ catch (error) {
34
+ // Fallback
35
+ await queryInterface.changeColumn('file_storage', 'uploaded_from', {
36
+ type: Sequelize.ENUM('INSTITUTE_APP', 'SCHOOL_APP', 'GLOBAL_APP', 'STUDENT_APP', 'VENDOR_APP'),
37
+ allowNull: false,
38
+ });
39
+ }
40
+ }
41
+ }
42
+ };
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const sequelize_1 = require("sequelize");
4
4
  const index_1 = require("./index");
5
- const app_1 = require("../../constants/app");
6
5
  class FileStorageModel extends sequelize_1.Model {
7
6
  static associate(models) {
8
7
  const { UserModel, UserDirectoryModel } = models;
@@ -72,9 +71,9 @@ FileStorageModel.init({
72
71
  allowNull: true,
73
72
  },
74
73
  uploadedFrom: {
75
- type: sequelize_1.DataTypes.ENUM,
76
- values: Object.values(app_1.APP_TYPE),
77
- allowNull: false,
74
+ type: sequelize_1.DataTypes.STRING,
75
+ field: 'uploaded_from',
76
+ allowNull: true,
78
77
  },
79
78
  instituteId: {
80
79
  type: sequelize_1.DataTypes.UUID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.665",
3
+ "version": "1.1.666",
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",