node-server-engine 1.10.3 → 1.10.5
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.
- package/dist/entities/Sequelize/Sequelize.config.js +7 -4
- package/dist/entities/Sequelize/Sequelize.config.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.js +34 -3
- package/dist/entities/Sequelize/Sequelize.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.js +88 -48
- package/dist/utils/dbMigration/dbMigration.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js +83 -51
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,17 +7,20 @@ exports.test = exports.staging = exports.production = exports.development = expo
|
|
|
7
7
|
var _Sequelize = require("./Sequelize.validate");
|
|
8
8
|
// Check that environment variables are correctly set
|
|
9
9
|
(0, _Sequelize.validateSequelizeEnvironment)();
|
|
10
|
+
|
|
11
|
+
// Check if SQL_HOST is a Unix socket path (Cloud SQL)
|
|
12
|
+
const isUnixSocket = process.env.SQL_HOST?.startsWith('/');
|
|
10
13
|
const config = {
|
|
11
14
|
username: process.env.SQL_USER,
|
|
12
15
|
password: process.env.SQL_PASSWORD,
|
|
13
16
|
database: process.env.SQL_DB,
|
|
14
17
|
host: process.env.SQL_HOST,
|
|
15
|
-
port
|
|
16
|
-
|
|
18
|
+
// Don't set port for Unix socket connections (Cloud SQL)
|
|
19
|
+
port: isUnixSocket ? undefined : process.env.SQL_PORT ? parseInt(process.env.SQL_PORT) : 5432,
|
|
17
20
|
dialect: process.env.SQL_TYPE ?? 'postgres',
|
|
18
21
|
// Dynamically set the dialect (postgres, mysql, mssql)
|
|
19
|
-
logging: false,
|
|
20
|
-
//
|
|
22
|
+
logging: process.env.SQL_LOGGING === 'true' ? console.log : false,
|
|
23
|
+
// Enable SQL logging with SQL_LOGGING=true
|
|
21
24
|
define: {
|
|
22
25
|
freezeTableName: false,
|
|
23
26
|
// Prevent automatic pluralization of table names
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequelize.config.js","names":["_Sequelize","require","validateSequelizeEnvironment","
|
|
1
|
+
{"version":3,"file":"Sequelize.config.js","names":["_Sequelize","require","validateSequelizeEnvironment","isUnixSocket","process","env","SQL_HOST","startsWith","config","username","SQL_USER","password","SQL_PASSWORD","database","SQL_DB","host","port","undefined","SQL_PORT","parseInt","dialect","SQL_TYPE","logging","SQL_LOGGING","console","log","define","freezeTableName","charset","collate","retry","max","NODE_ENV","dialectOptions","pool","min","acquire","idle","evict","requestTimeout","connectTimeout","encrypt","trustServerCertificate","timezone","ssl","PG_SSL","rejectUnauthorized","development","exports","staging","production","test","_default","default"],"sources":["../../../src/entities/Sequelize/Sequelize.config.ts"],"sourcesContent":["import { Options, Dialect } from 'sequelize';\nimport { validateSequelizeEnvironment } from './Sequelize.validate';\n\n// Check that environment variables are correctly set\nvalidateSequelizeEnvironment();\n\n// Check if SQL_HOST is a Unix socket path (Cloud SQL)\nconst isUnixSocket = process.env.SQL_HOST?.startsWith('/');\n\nconst config: Options = {\n username: process.env.SQL_USER,\n password: process.env.SQL_PASSWORD,\n database: process.env.SQL_DB,\n host: process.env.SQL_HOST,\n // Don't set port for Unix socket connections (Cloud SQL)\n port: isUnixSocket ? undefined : (process.env.SQL_PORT ? parseInt(process.env.SQL_PORT) : 5432),\n dialect: (process.env.SQL_TYPE ?? 'postgres') as Dialect, // Dynamically set the dialect (postgres, mysql, mssql)\n logging: process.env.SQL_LOGGING === 'true' ? console.log : false, // Enable SQL logging with SQL_LOGGING=true\n define: {\n freezeTableName: false, // Prevent automatic pluralization of table names\n charset: 'utf8mb4', // Set character set for MySQL/MariaDB\n collate: 'utf8mb4_unicode_ci' // Set collation for MySQL/MariaDB\n },\n retry: {\n max: process.env.NODE_ENV === 'test' ? 0 : 3 // Disable retries in test environment to prevent unhandled rejections\n },\n dialectOptions: {},\n pool: {\n max: process.env.NODE_ENV === 'test' ? 1 : 5,\n min: 0,\n acquire: process.env.NODE_ENV === 'test' ? 1000 : 30000, // Reduce acquire timeout in test\n idle: process.env.NODE_ENV === 'test' ? 1000 : 10000, // Reduce idle time in test\n evict: process.env.NODE_ENV === 'test' ? 100 : 1000 // How often to check for idle connections\n },\n};\n\n// Additional configurations for MSSQL\nif (config.dialect === 'mssql') {\n config.dialectOptions = {\n requestTimeout: 30000, // Increase request timeout for MSSQL\n connectTimeout: 30000, // Increase connection timeout for MSSQL\n encrypt: true, // Use encryption for MSSQL (set to false if not needed)\n trustServerCertificate: true, // Set to true if using self-signed certificates\n };\n}\n\n// Add specific dialect configurations if necessary for MySQL/PostgreSQL\nif (config.dialect === 'mysql') {\n config.dialectOptions = {\n timezone: 'Z', // Set timezone for MySQL\n };\n}\n\nif (config.dialect === 'postgres') {\n config.dialectOptions = {\n ssl: process.env.PG_SSL === 'true' ? { rejectUnauthorized: false } : false, // SSL options for PostgreSQL (if required)\n };\n}\n\nexport const development = config;\nexport const staging = config;\nexport const production = config;\nexport const test = config;\nexport default config;\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA,IAAAC,uCAA4B,EAAC,CAAC;;AAE9B;AACA,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAEC,UAAU,CAAC,GAAG,CAAC;AAE1D,MAAMC,MAAe,GAAG;EACtBC,QAAQ,EAAEL,OAAO,CAACC,GAAG,CAACK,QAAQ;EAC9BC,QAAQ,EAAEP,OAAO,CAACC,GAAG,CAACO,YAAY;EAClCC,QAAQ,EAAET,OAAO,CAACC,GAAG,CAACS,MAAM;EAC5BC,IAAI,EAAEX,OAAO,CAACC,GAAG,CAACC,QAAQ;EAC1B;EACAU,IAAI,EAAEb,YAAY,GAAGc,SAAS,GAAIb,OAAO,CAACC,GAAG,CAACa,QAAQ,GAAGC,QAAQ,CAACf,OAAO,CAACC,GAAG,CAACa,QAAQ,CAAC,GAA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AAc,GAAG;IACtBU,QAAQ,EAAE,GAAG,CAAE;EACjB,CAAC;AACH;AAEA,IAAInC,MAAM,CAACY,OAAO,KAAK,UAAU,EAAE;EACjCZ,MAAM,CAACyB,cAAc,GAAG;IACtBW,GAAG,EAAExC,OAAO,CAACC,GAAG,CAACwC,MAAM,KAAK,MAAM,GAAG;MAAEC,kBAAkB,EAAE;IAAM,CAAC,GAAG,KAAK,CAAE;EAC9E,CAAC;AACH;AAEO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGvC,MAAM;AAC1B,MAAMyC,OAAO,GAAAD,OAAA,CAAAC,OAAA,GAAGzC,MAAM;AACtB,MAAM0C,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG1C,MAAM;AACzB,MAAM2C,IAAI,GAAAH,OAAA,CAAAG,IAAA,GAAG3C,MAAM;AAAC,IAAA4C,QAAA,GAAAJ,OAAA,CAAAK,OAAA,GACZ7C,MAAM","ignoreList":[]}
|
|
@@ -49,9 +49,40 @@ function init() {
|
|
|
49
49
|
// In test environment, authentication happens automatically with SQLite
|
|
50
50
|
// For other environments, authenticate and log the result
|
|
51
51
|
if (process.env.NODE_ENV !== 'test') {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
// Add timeout to prevent hanging on connection issues
|
|
53
|
+
const authTimeout = setTimeout(() => {
|
|
54
|
+
(0, _report.reportError)({
|
|
55
|
+
message: 'Database authentication timeout after 30 seconds',
|
|
56
|
+
data: {
|
|
57
|
+
host: process.env.SQL_HOST,
|
|
58
|
+
database: process.env.SQL_DB,
|
|
59
|
+
user: process.env.SQL_USER
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}, 30000);
|
|
63
|
+
void sequelizeClient.authenticate().then(() => {
|
|
64
|
+
clearTimeout(authTimeout);
|
|
65
|
+
(0, _report.reportInfo)({
|
|
66
|
+
message: 'Connected to database successfully',
|
|
67
|
+
data: {
|
|
68
|
+
host: process.env.SQL_HOST,
|
|
69
|
+
database: process.env.SQL_DB,
|
|
70
|
+
dialect: sequelizeClient?.getDialect()
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}).catch(err => {
|
|
74
|
+
clearTimeout(authTimeout);
|
|
75
|
+
(0, _report.reportError)({
|
|
76
|
+
message: 'Failed to connect to database',
|
|
77
|
+
data: {
|
|
78
|
+
error: err.message,
|
|
79
|
+
host: process.env.SQL_HOST,
|
|
80
|
+
database: process.env.SQL_DB,
|
|
81
|
+
user: process.env.SQL_USER
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
(0, _report.reportError)(err);
|
|
85
|
+
});
|
|
55
86
|
}
|
|
56
87
|
_LifecycleController.LifecycleController.register(sequelize);
|
|
57
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequelize.js","names":["_sequelizeTypescript","require","_Sequelize","_interopRequireDefault","_Sequelize2","_EngineError","_LifecycleController","_report","sequelizeClient","exports","sequelize","Proxy","get","target","property","init","shutdown","addModels","EngineError","message","createSequelizeClient","process","env","NODE_ENV","authenticate","then","reportInfo","catch","err","
|
|
1
|
+
{"version":3,"file":"Sequelize.js","names":["_sequelizeTypescript","require","_Sequelize","_interopRequireDefault","_Sequelize2","_EngineError","_LifecycleController","_report","sequelizeClient","exports","sequelize","Proxy","get","target","property","init","shutdown","addModels","EngineError","message","createSequelizeClient","process","env","NODE_ENV","authTimeout","setTimeout","reportError","data","host","SQL_HOST","database","SQL_DB","user","SQL_USER","authenticate","then","clearTimeout","reportInfo","dialect","getDialect","catch","err","error","LifecycleController","register","close","console","undefined","models","addHook","result","convertToPlain","instance","toJSON","plain","Object","keys","forEach","key","Array","isArray","sync","Sequelize","storage","logging","validateSequelizeEnvironment","SQL_PASSWORD","dbConfig"],"sources":["../../../src/entities/Sequelize/Sequelize.ts"],"sourcesContent":["import { Sequelize, ModelCtor } from 'sequelize-typescript';\nimport dbConfig from './Sequelize.config';\nimport { Sequelize as SequelizeInterface } from './Sequelize.types';\nimport { validateSequelizeEnvironment } from './Sequelize.validate';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { reportInfo, reportError } from 'utils/report';\n\nexport let sequelizeClient: undefined | Sequelize;\n\n/**\n * We use a proxy to extend the Sequelize behavior and allow initialization of the client only when needed while keeping the same interface\n */\nexport const sequelize = new Proxy<SequelizeInterface>(\n // Due to how we do the proxying, we are forced to ignore ts-errors, we could never create an object that respects the interface properly\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n {},\n {\n get: function (target, property): unknown {\n if (property === 'init') return init;\n if (property === 'shutdown') return shutdown;\n if (property === 'addModels') return addModels;\n // Create the sequelize client if it does not exist\n if (!sequelizeClient)\n throw new EngineError({\n message: 'Sequelize client was not initialized'\n });\n // Call the function on the sequelize client\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return sequelizeClient[property] as unknown;\n }\n }\n);\n\n/** On init create client and connect */\nexport function init(): void {\n // Ignore if already initialized\n if (sequelizeClient) return;\n sequelizeClient = createSequelizeClient();\n \n // In test environment, authentication happens automatically with SQLite\n // For other environments, authenticate and log the result\n if (process.env.NODE_ENV !== 'test') {\n // Add timeout to prevent hanging on connection issues\n const authTimeout = setTimeout(() => {\n reportError({\n message: 'Database authentication timeout after 30 seconds',\n data: {\n host: process.env.SQL_HOST,\n database: process.env.SQL_DB,\n user: process.env.SQL_USER\n }\n });\n }, 30000);\n\n void sequelizeClient\n .authenticate()\n .then(() => {\n clearTimeout(authTimeout);\n reportInfo({ \n message: 'Connected to database successfully',\n data: {\n host: process.env.SQL_HOST,\n database: process.env.SQL_DB,\n dialect: sequelizeClient?.getDialect()\n }\n });\n })\n .catch((err: Error) => {\n clearTimeout(authTimeout);\n reportError({\n message: 'Failed to connect to database',\n data: {\n error: err.message,\n host: process.env.SQL_HOST,\n database: process.env.SQL_DB,\n user: process.env.SQL_USER\n }\n });\n reportError(err);\n });\n }\n \n LifecycleController.register(sequelize);\n}\n\n/** On shutdown close connection and clear client */\nexport async function shutdown(): Promise<void> {\n if (sequelizeClient) {\n try {\n // For SQLite, just close the client (closing connection manager first causes SQLITE_MISUSE)\n // For other dialects, sequelize.close() handles everything properly\n await sequelizeClient.close();\n } catch (error) {\n // Ignore errors during shutdown\n if (process.env.NODE_ENV !== 'test') {\n console.error('Error closing sequelize client:', error);\n }\n }\n }\n sequelizeClient = undefined;\n}\n\nexport function addModels(models: Array<ModelCtor>): void {\n if (!sequelizeClient)\n throw new EngineError({\n message: 'Sequelize client was not initialized'\n });\n sequelizeClient.addModels(models);\n \n // Override toJSON behavior globally to ensure consistency between dev and prod\n // In dev (ts-node), property access works directly on instances\n // In prod (compiled), we need explicit serialization\n // This hook intercepts all afterFind results and converts them to plain objects\n sequelizeClient.addHook('afterFind', (result) => {\n if (!result) return;\n \n const convertToPlain = (instance: any) => {\n if (!instance || !instance.toJSON) return instance;\n const plain = instance.toJSON();\n // Copy the plain object properties back to the instance\n // This makes property access work without .toJSON() in compiled code\n Object.keys(plain).forEach(key => {\n instance[key] = plain[key];\n });\n };\n \n if (Array.isArray(result)) {\n result.forEach(convertToPlain);\n } else {\n convertToPlain(result);\n }\n });\n \n sequelizeClient.sync();\n}\n\n/** Create Sequelize client */\nexport function createSequelizeClient(): Sequelize {\n // Use in-memory SQLite for test environment to avoid real database connections\n if (process.env.NODE_ENV === 'test') {\n return new Sequelize({\n dialect: 'sqlite',\n storage: ':memory:',\n logging: false\n });\n }\n \n // Throw an error if there is no host initial\n validateSequelizeEnvironment();\n return new Sequelize(\n process.env.SQL_DB as string,\n process.env.SQL_USER as string,\n process.env.SQL_PASSWORD as string,\n dbConfig\n );\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK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Migrations() {
|
|
|
42
42
|
if (!_Sequelize.sequelize) throw new _EngineError.EngineError({
|
|
43
43
|
message: 'Sequelize is not initialized'
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
await (0, _migrateMetadataTable.migrateMetadataTable)(_Sequelize.sequelize);
|
|
47
|
-
const migrationPaths = getMigrationPaths();
|
|
48
|
-
if (!migrationPaths || migrationPaths.length <= 0) {
|
|
45
|
+
try {
|
|
49
46
|
(0, _report.reportDebug)({
|
|
50
47
|
namespace,
|
|
51
|
-
message: '
|
|
48
|
+
message: 'Starting migration process',
|
|
52
49
|
data: {
|
|
53
|
-
|
|
50
|
+
sqlHost: process.env.SQL_HOST,
|
|
51
|
+
sqlDb: process.env.SQL_DB,
|
|
52
|
+
sqlUser: process.env.SQL_USER,
|
|
53
|
+
nodeEnv: process.env.NODE_ENV
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
// First make sure that the metadata table is up to date
|
|
58
|
+
(0, _report.reportDebug)({
|
|
59
|
+
namespace,
|
|
60
|
+
message: 'Migrating metadata table'
|
|
61
|
+
});
|
|
62
|
+
await (0, _migrateMetadataTable.migrateMetadataTable)(_Sequelize.sequelize);
|
|
63
|
+
const migrationPaths = getMigrationPaths();
|
|
64
|
+
if (!migrationPaths || migrationPaths.length <= 0) {
|
|
65
|
+
(0, _report.reportDebug)({
|
|
66
|
+
namespace,
|
|
67
|
+
message: 'No valid migration paths found.',
|
|
68
|
+
data: {
|
|
69
|
+
migrationPaths
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
down: async () => {
|
|
80
|
-
const migration = await migrationPromise;
|
|
81
|
-
return migration.down(context);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
75
|
+
// Process migrations sequentially to avoid race conditions
|
|
76
|
+
for (const path of migrationPaths) {
|
|
77
|
+
(0, _report.reportDebug)({
|
|
78
|
+
namespace,
|
|
79
|
+
message: 'Processing migration path',
|
|
80
|
+
data: {
|
|
81
|
+
path
|
|
84
82
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
});
|
|
84
|
+
const migrator = new _umzug.Umzug({
|
|
85
|
+
migrations: {
|
|
86
|
+
glob: path,
|
|
87
|
+
resolve: ({
|
|
88
|
+
name,
|
|
89
|
+
path,
|
|
90
|
+
context
|
|
91
|
+
}) => {
|
|
92
|
+
const nameWithoutExtension = name.replace(/\.(ts|js)$/, '');
|
|
93
|
+
|
|
94
|
+
// Use dynamic import for better TypeScript/ES module support
|
|
95
|
+
const migrationPromise = (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(path || '');
|
|
96
|
+
return {
|
|
97
|
+
name: nameWithoutExtension,
|
|
98
|
+
up: async () => {
|
|
99
|
+
(0, _report.reportDebug)({
|
|
100
|
+
namespace,
|
|
101
|
+
message: `Running migration: ${nameWithoutExtension}`
|
|
102
|
+
});
|
|
103
|
+
const migration = await migrationPromise;
|
|
104
|
+
return migration.up(context);
|
|
105
|
+
},
|
|
106
|
+
down: async () => {
|
|
107
|
+
const migration = await migrationPromise;
|
|
108
|
+
return migration.down(context);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
context: _Sequelize.sequelize.getQueryInterface(),
|
|
114
|
+
storage: new _umzug.SequelizeStorage({
|
|
115
|
+
sequelize: _Sequelize.sequelize
|
|
116
|
+
}),
|
|
117
|
+
logger: console
|
|
118
|
+
});
|
|
119
|
+
(0, _report.reportDebug)({
|
|
120
|
+
namespace,
|
|
121
|
+
message: 'Starting pending database migrations',
|
|
122
|
+
data: {
|
|
123
|
+
path
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
await migrator.up();
|
|
127
|
+
(0, _report.reportInfo)({
|
|
128
|
+
message: 'Database migration completed successfully',
|
|
129
|
+
data: {
|
|
130
|
+
path
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
} catch (error) {
|
|
92
135
|
(0, _report.reportDebug)({
|
|
93
136
|
namespace,
|
|
94
|
-
message: '
|
|
95
|
-
data: {
|
|
96
|
-
path
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
await migrator.up();
|
|
100
|
-
(0, _report.reportInfo)({
|
|
101
|
-
message: 'Database migration completed successfully',
|
|
137
|
+
message: 'Migration failed with error',
|
|
102
138
|
data: {
|
|
103
|
-
|
|
139
|
+
error: error instanceof Error ? error.message : String(error),
|
|
140
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
141
|
+
sqlHost: process.env.SQL_HOST,
|
|
142
|
+
sqlDb: process.env.SQL_DB
|
|
104
143
|
}
|
|
105
144
|
});
|
|
145
|
+
throw error;
|
|
106
146
|
}
|
|
107
147
|
}
|
|
108
148
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbMigration.js","names":["_fs","require","_path","_umzug","_migrateMetadataTable","_models","_EngineError","_Sequelize","_report","_semverCompare","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","namespace","getMigrationPaths","prodDefaultPath","join","process","cwd","devDefaultPath","path","env","DB_MIGRATIONS_DIR","NODE_ENV","filter","existsSync","lstatSync","isDirectory","reportDebug","message","data","prodPath","devPath","customPath","map","p","runPendingMigrations","sequelize","EngineError","migrateMetadataTable","migrationPaths","length","migrator","Umzug","migrations","glob","resolve","name","context","nameWithoutExtension","replace","migrationPromise","specifier","Promise","then","s","up","migration","down","getQueryInterface","storage","SequelizeStorage","logger","console","reportInfo","rollbackMigrations","BUILD_ID","SequelizeMeta","findAll","order","raw","rollbackUntil","find","version","semverCompare","buildId","to","testRecreateDB","options","query","SQL_TYPE","clean","testClearDB","transaction","clearDbTransaction","model","keys","models","includeMetadata","table","tableName"],"sources":["../../../src/utils/dbMigration/dbMigration.ts"],"sourcesContent":["import { existsSync, lstatSync } from 'fs';\nimport { join } from 'path';\nimport { Sequelize, Transaction } from 'sequelize';\nimport { Umzug, SequelizeStorage } from 'umzug';\nimport { ClearDbOptions, RecreateDbOptions } from './dbMigration.types';\nimport { migrateMetadataTable } from './migrateMetadataTable';\nimport { SequelizeMeta } from 'db/models';\nimport { EngineError } from 'entities/EngineError';\nimport { sequelize } from 'entities/Sequelize';\nimport { reportDebug, reportInfo } from 'utils/report';\nimport { semverCompare } from 'utils/semverCompare';\n\nconst namespace = 'engine:utils:dbMigration';\n\nfunction getMigrationPaths(): Array<string> | undefined {\n // We look between possibilities for the first directory that exists and matches our expectations\n // First a user specified one, then the production default, then the development default\n const prodDefaultPath = join(process.cwd(), './dist/db/migrations');\n const devDefaultPath = join(process.cwd(), './src/db/migrations');\n const path = [\n process.env.DB_MIGRATIONS_DIR,\n process.env.NODE_ENV === 'prod' ? prodDefaultPath : devDefaultPath\n ].filter((path) => path && existsSync(path) && lstatSync(path).isDirectory());\n reportDebug({\n namespace,\n message: 'Obtaining Umzug migration options',\n data: {\n path,\n prodPath: prodDefaultPath,\n devPath: devDefaultPath,\n customPath: process.env.DB_MIGRATIONS_DIR\n }\n });\n return path.map((p) =>\n process.env.NODE_ENV === 'prod' ? `${p}/*.js` : `${p}/*.ts`\n );\n}\n\n/** Run all the non-executed migrations one by one */\nexport async function runPendingMigrations(): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n // First make sure that the metadata table is up to date\n await migrateMetadataTable(sequelize);\n const migrationPaths = getMigrationPaths();\n\n if (!migrationPaths || migrationPaths.length <= 0) {\n reportDebug({\n namespace,\n message: 'No valid migration paths found.',\n data: { migrationPaths }\n });\n return;\n }\n\n // Process migrations sequentially to avoid race conditions\n for (const path of migrationPaths) {\n const migrator = new Umzug({\n migrations: {\n glob: path,\n resolve: ({ name, path, context }) => {\n const nameWithoutExtension = name.replace(/\\.(ts|js)$/, '');\n \n // Use dynamic import for better TypeScript/ES module support\n const migrationPromise = import(path || '');\n return {\n name: nameWithoutExtension,\n up: async () => {\n const migration = await migrationPromise;\n return migration.up(context);\n },\n down: async () => {\n const migration = await migrationPromise;\n return migration.down(context);\n }\n };\n }\n },\n context: sequelize.getQueryInterface(),\n storage: new SequelizeStorage({ sequelize }),\n logger: console\n });\n\n reportDebug({\n namespace,\n message: 'Starting pending database migrations',\n data: { path }\n });\n await migrator.up();\n reportInfo({\n message: 'Database migration completed successfully',\n data: { path }\n });\n }\n}\n\n/** Rollback all migrations up to a specified target version */\nexport async function rollbackMigrations(): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n if (!process.env.BUILD_ID)\n throw new EngineError({ message: 'BUILD_ID is not defined' });\n\n // Fetch executed migrations in ascending order\n const migrations = await SequelizeMeta.findAll({\n order: [['name', 'ASC']],\n raw: true\n });\n const rollbackUntil = migrations.find(\n (migration) =>\n migration.version &&\n semverCompare(migration.version, process.env.BUILD_ID as string) === 1\n );\n\n if (!rollbackUntil) {\n reportDebug({\n namespace,\n message: 'No rollback target found for the current BUILD_ID.',\n data: { buildId: process.env.BUILD_ID }\n });\n return;\n }\n\n const migrationPaths = getMigrationPaths();\n\n if (!migrationPaths || migrationPaths.length <= 0) {\n reportDebug({\n namespace,\n message: 'No valid migration paths found for rollback.',\n data: { migrationPaths }\n });\n return;\n }\n\n // Process rollback migrations sequentially\n for (const path of migrationPaths) {\n const migrator = new Umzug({\n migrations: {\n glob: path,\n resolve: ({ name, path, context }) => {\n // Strip file extension to ensure consistent naming across .ts and .js files\n const nameWithoutExtension = name.replace(/\\.(ts|js)$/, '');\n \n const migrationPromise = import(path || '');\n return {\n name: nameWithoutExtension,\n up: async () => {\n const migration = await migrationPromise;\n return migration.up(context);\n },\n down: async () => {\n const migration = await migrationPromise;\n return migration.down(context);\n }\n };\n }\n },\n context: sequelize.getQueryInterface(),\n storage: new SequelizeStorage({ sequelize }),\n logger: console\n });\n\n reportDebug({\n namespace,\n message: `Rolling back migrations up to: ${rollbackUntil.name}`,\n data: { path }\n });\n\n await migrator.down({ to: rollbackUntil.name });\n }\n}\n\n/**\n * Recreate the whole database\n * Quick way to make sure that we are working on a clean database\n * /!\\ Should only be used when running tests\n */\nexport async function testRecreateDB(\n options: RecreateDbOptions = {}\n): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n await sequelize.query(\n `DROP SCHEMA public${process.env.SQL_TYPE === 'postgres' ? ' CASCADE' : ''}`\n );\n await sequelize.query(`CREATE SCHEMA public`);\n if (!options.clean) await runPendingMigrations();\n}\n\n/**\n * Empty all the schemas in the database\n * Quick way to flush the database data while keep the structure\n * /!\\ Should only be used when running tests\n */\nexport async function testClearDB(options: ClearDbOptions = {}): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n await sequelize.transaction(clearDbTransaction(sequelize, options));\n}\n\n/** DB clearing transaction */\nfunction clearDbTransaction(sequelize: Sequelize, options: ClearDbOptions) {\n return async (t: Transaction): Promise<void> => {\n for (const model of Object.keys(sequelize.models)) {\n // We ignore the migration metadata schema\n if (!options.includeMetadata && model === 'sequelizeMeta') continue;\n const table = sequelize.models[model].tableName;\n await sequelize.query(\n `TRUNCATE ${table}${process.env.SQL_TYPE === 'postgres' ? ' CASCADE' : ''};`,\n {\n raw: true,\n transaction: t\n }\n );\n }\n };\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,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,KAAK,UAAU,GAAG,UAAU,GAAG,EAAE,GAAG,EAC5E;QACEV,GAAG,EAAE,IAAI;QACTa,WAAW,EAAExF;MACf,CACF,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"dbMigration.js","names":["_fs","require","_path","_umzug","_migrateMetadataTable","_models","_EngineError","_Sequelize","_report","_semverCompare","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","namespace","getMigrationPaths","prodDefaultPath","join","process","cwd","devDefaultPath","path","env","DB_MIGRATIONS_DIR","NODE_ENV","filter","existsSync","lstatSync","isDirectory","reportDebug","message","data","prodPath","devPath","customPath","map","p","runPendingMigrations","sequelize","EngineError","sqlHost","SQL_HOST","sqlDb","SQL_DB","sqlUser","SQL_USER","nodeEnv","migrateMetadataTable","migrationPaths","length","migrator","Umzug","migrations","glob","resolve","name","context","nameWithoutExtension","replace","migrationPromise","specifier","Promise","then","s","up","migration","down","getQueryInterface","storage","SequelizeStorage","logger","console","reportInfo","error","Error","String","stack","undefined","rollbackMigrations","BUILD_ID","SequelizeMeta","findAll","order","raw","rollbackUntil","find","version","semverCompare","buildId","to","testRecreateDB","options","query","SQL_TYPE","clean","testClearDB","transaction","clearDbTransaction","model","keys","models","includeMetadata","table","tableName"],"sources":["../../../src/utils/dbMigration/dbMigration.ts"],"sourcesContent":["import { existsSync, lstatSync } from 'fs';\nimport { join } from 'path';\nimport { Sequelize, Transaction } from 'sequelize';\nimport { Umzug, SequelizeStorage } from 'umzug';\nimport { ClearDbOptions, RecreateDbOptions } from './dbMigration.types';\nimport { migrateMetadataTable } from './migrateMetadataTable';\nimport { SequelizeMeta } from 'db/models';\nimport { EngineError } from 'entities/EngineError';\nimport { sequelize } from 'entities/Sequelize';\nimport { reportDebug, reportInfo } from 'utils/report';\nimport { semverCompare } from 'utils/semverCompare';\n\nconst namespace = 'engine:utils:dbMigration';\n\nfunction getMigrationPaths(): Array<string> | undefined {\n // We look between possibilities for the first directory that exists and matches our expectations\n // First a user specified one, then the production default, then the development default\n const prodDefaultPath = join(process.cwd(), './dist/db/migrations');\n const devDefaultPath = join(process.cwd(), './src/db/migrations');\n const path = [\n process.env.DB_MIGRATIONS_DIR,\n process.env.NODE_ENV === 'prod' ? prodDefaultPath : devDefaultPath\n ].filter((path) => path && existsSync(path) && lstatSync(path).isDirectory());\n reportDebug({\n namespace,\n message: 'Obtaining Umzug migration options',\n data: {\n path,\n prodPath: prodDefaultPath,\n devPath: devDefaultPath,\n customPath: process.env.DB_MIGRATIONS_DIR\n }\n });\n return path.map((p) =>\n process.env.NODE_ENV === 'prod' ? `${p}/*.js` : `${p}/*.ts`\n );\n}\n\n/** Run all the non-executed migrations one by one */\nexport async function runPendingMigrations(): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n \n try {\n reportDebug({\n namespace,\n message: 'Starting migration process',\n data: {\n sqlHost: process.env.SQL_HOST,\n sqlDb: process.env.SQL_DB,\n sqlUser: process.env.SQL_USER,\n nodeEnv: process.env.NODE_ENV\n }\n });\n\n // First make sure that the metadata table is up to date\n reportDebug({\n namespace,\n message: 'Migrating metadata table'\n });\n await migrateMetadataTable(sequelize);\n \n const migrationPaths = getMigrationPaths();\n\n if (!migrationPaths || migrationPaths.length <= 0) {\n reportDebug({\n namespace,\n message: 'No valid migration paths found.',\n data: { migrationPaths }\n });\n return;\n }\n\n // Process migrations sequentially to avoid race conditions\n for (const path of migrationPaths) {\n reportDebug({\n namespace,\n message: 'Processing migration path',\n data: { path }\n });\n\n const migrator = new Umzug({\n migrations: {\n glob: path,\n resolve: ({ name, path, context }) => {\n const nameWithoutExtension = name.replace(/\\.(ts|js)$/, '');\n \n // Use dynamic import for better TypeScript/ES module support\n const migrationPromise = import(path || '');\n return {\n name: nameWithoutExtension,\n up: async () => {\n reportDebug({\n namespace,\n message: `Running migration: ${nameWithoutExtension}`\n });\n const migration = await migrationPromise;\n return migration.up(context);\n },\n down: async () => {\n const migration = await migrationPromise;\n return migration.down(context);\n }\n };\n }\n },\n context: sequelize.getQueryInterface(),\n storage: new SequelizeStorage({ sequelize }),\n logger: console\n });\n\n reportDebug({\n namespace,\n message: 'Starting pending database migrations',\n data: { path }\n });\n \n await migrator.up();\n \n reportInfo({\n message: 'Database migration completed successfully',\n data: { path }\n });\n }\n } catch (error) {\n reportDebug({\n namespace,\n message: 'Migration failed with error',\n data: {\n error: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n sqlHost: process.env.SQL_HOST,\n sqlDb: process.env.SQL_DB\n }\n });\n throw error;\n }\n}\n\n/** Rollback all migrations up to a specified target version */\nexport async function rollbackMigrations(): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n if (!process.env.BUILD_ID)\n throw new EngineError({ message: 'BUILD_ID is not defined' });\n\n // Fetch executed migrations in ascending order\n const migrations = await SequelizeMeta.findAll({\n order: [['name', 'ASC']],\n raw: true\n });\n const rollbackUntil = migrations.find(\n (migration) =>\n migration.version &&\n semverCompare(migration.version, process.env.BUILD_ID as string) === 1\n );\n\n if (!rollbackUntil) {\n reportDebug({\n namespace,\n message: 'No rollback target found for the current BUILD_ID.',\n data: { buildId: process.env.BUILD_ID }\n });\n return;\n }\n\n const migrationPaths = getMigrationPaths();\n\n if (!migrationPaths || migrationPaths.length <= 0) {\n reportDebug({\n namespace,\n message: 'No valid migration paths found for rollback.',\n data: { migrationPaths }\n });\n return;\n }\n\n // Process rollback migrations sequentially\n for (const path of migrationPaths) {\n const migrator = new Umzug({\n migrations: {\n glob: path,\n resolve: ({ name, path, context }) => {\n // Strip file extension to ensure consistent naming across .ts and .js files\n const nameWithoutExtension = name.replace(/\\.(ts|js)$/, '');\n \n const migrationPromise = import(path || '');\n return {\n name: nameWithoutExtension,\n up: async () => {\n const migration = await migrationPromise;\n return migration.up(context);\n },\n down: async () => {\n const migration = await migrationPromise;\n return migration.down(context);\n }\n };\n }\n },\n context: sequelize.getQueryInterface(),\n storage: new SequelizeStorage({ sequelize }),\n logger: console\n });\n\n reportDebug({\n namespace,\n message: `Rolling back migrations up to: ${rollbackUntil.name}`,\n data: { path }\n });\n\n await migrator.down({ to: rollbackUntil.name });\n }\n}\n\n/**\n * Recreate the whole database\n * Quick way to make sure that we are working on a clean database\n * /!\\ Should only be used when running tests\n */\nexport async function testRecreateDB(\n options: RecreateDbOptions = {}\n): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n await sequelize.query(\n `DROP SCHEMA public${process.env.SQL_TYPE === 'postgres' ? ' CASCADE' : ''}`\n );\n await sequelize.query(`CREATE SCHEMA public`);\n if (!options.clean) await runPendingMigrations();\n}\n\n/**\n * Empty all the schemas in the database\n * Quick way to flush the database data while keep the structure\n * /!\\ Should only be used when running tests\n */\nexport async function testClearDB(options: ClearDbOptions = {}): Promise<void> {\n if (!sequelize)\n throw new EngineError({ message: 'Sequelize is not initialized' });\n await sequelize.transaction(clearDbTransaction(sequelize, options));\n}\n\n/** DB clearing transaction */\nfunction clearDbTransaction(sequelize: Sequelize, options: ClearDbOptions) {\n return async (t: Transaction): Promise<void> => {\n for (const model of Object.keys(sequelize.models)) {\n // We ignore the migration metadata schema\n if (!options.includeMetadata && model === 'sequelizeMeta') continue;\n const table = sequelize.models[model].tableName;\n await sequelize.query(\n `TRUNCATE ${table}${process.env.SQL_TYPE === 'postgres' ? ' CASCADE' : ''};`,\n {\n raw: true,\n transaction: t\n }\n );\n }\n };\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;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,UAAU,GAAG,EAAE,EAC5E,CAAC;EACD,MAAMvD,oBAAS,CAACsD,KAAK,CAAC,sBAAsB,CAAC;EAC7C,IAAI,CAACD,OAAO,CAACG,KAAK,EAAE,MAAMzD,oBAAoB,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACO,eAAe0D,WAAWA,CAACJ,OAAuB,GAAG,CAAC,CAAC,EAAiB;EAC7E,IAAI,CAACrD,oBAAS,EACZ,MAAM,IAAIC,wBAAW,CAAC;IAAET,OAAO,EAAE;EAA+B,CAAC,CAAC;EACpE,MAAMQ,oBAAS,CAAC0D,WAAW,CAACC,kBAAkB,CAAC3D,oBAAS,EAAEqD,OAAO,CAAC,CAAC;AACrE;;AAEA;AACA,SAASM,kBAAkBA,CAAC3D,SAAoB,EAAEqD,OAAuB,EAAE;EACzE,OAAO,MAAO/F,CAAc,IAAoB;IAC9C,KAAK,MAAMsG,KAAK,IAAIvF,MAAM,CAACwF,IAAI,CAAC7D,SAAS,CAAC8D,MAAM,CAAC,EAAE;MACjD;MACA,IAAI,CAACT,OAAO,CAACU,eAAe,IAAIH,KAAK,KAAK,eAAe,EAAE;MAC3D,MAAMI,KAAK,GAAGhE,SAAS,CAAC8D,MAAM,CAACF,KAAK,CAAC,CAACK,SAAS;MAC/C,MAAMjE,SAAS,CAACsD,KAAK,CACnB,YAAYU,KAAK,GAAGpF,OAAO,CAACI,GAAG,CAACuE,QAAQ,KAAK,UAAU,GAAG,UAAU,GAAG,EAAE,GAAG,EAC5E;QACEV,GAAG,EAAE,IAAI;QACTa,WAAW,EAAEpG;MACf,CACF,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,82 +14,114 @@ const namespace = 'engine:utils:dbMigration';
|
|
|
14
14
|
* Therefore, we use a more classic approach with this function and pure SQL queries
|
|
15
15
|
*/
|
|
16
16
|
async function migrateMetadataTable(sequelize) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// We check if we have a custom sequelize_meta table yet
|
|
24
|
-
const tables = await sequelize.query(query, {
|
|
25
|
-
type: _sequelize.QueryTypes.SELECT
|
|
26
|
-
});
|
|
27
|
-
const hasCustomSequelizeMeta = process.env.SQL_TYPE === 'postgres' ? tables.some(table => table[0] === 'sequelize_meta') : tables.some(table => Object.values(table)[0] === 'sequelize_meta');
|
|
28
|
-
const hasLegacySequelizeMeta = process.env.SQL_TYPE === 'postgres' ? tables.some(table => table[0] === 'SequelizeMeta') : tables.some(table => Object.values(table)[0] === 'SequelizeMeta');
|
|
29
|
-
if (!hasCustomSequelizeMeta) {
|
|
17
|
+
try {
|
|
18
|
+
(0, _report.reportDebug)({
|
|
19
|
+
namespace,
|
|
20
|
+
message: 'Executing metadata migration routine'
|
|
21
|
+
});
|
|
22
|
+
const query = `SELECT table_name FROM information_schema.tables`;
|
|
30
23
|
(0, _report.reportDebug)({
|
|
31
24
|
namespace,
|
|
32
|
-
message: '
|
|
25
|
+
message: 'Checking for existing metadata tables',
|
|
26
|
+
data: {
|
|
27
|
+
sqlType: process.env.SQL_TYPE
|
|
28
|
+
}
|
|
33
29
|
});
|
|
34
30
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
// We check if we have a custom sequelize_meta table yet
|
|
32
|
+
const tables = await sequelize.query(query, {
|
|
33
|
+
type: _sequelize.QueryTypes.SELECT
|
|
34
|
+
});
|
|
35
|
+
const hasCustomSequelizeMeta = process.env.SQL_TYPE === 'postgres' ? tables.some(table => table[0] === 'sequelize_meta') : tables.some(table => Object.values(table)[0] === 'sequelize_meta');
|
|
36
|
+
const hasLegacySequelizeMeta = process.env.SQL_TYPE === 'postgres' ? tables.some(table => table[0] === 'SequelizeMeta') : tables.some(table => Object.values(table)[0] === 'SequelizeMeta');
|
|
37
|
+
if (!hasCustomSequelizeMeta) {
|
|
38
|
+
(0, _report.reportDebug)({
|
|
39
|
+
namespace,
|
|
40
|
+
message: 'No metadata table found, creating new one'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Define SQL for creating the table based on the database type
|
|
44
|
+
let createTableQuery = '';
|
|
45
|
+
switch (process.env.SQL_TYPE) {
|
|
46
|
+
case 'mysql':
|
|
47
|
+
case 'postgres':
|
|
48
|
+
createTableQuery = `
|
|
41
49
|
CREATE TABLE sequelize_meta (
|
|
42
50
|
name VARCHAR(100) PRIMARY KEY,
|
|
43
51
|
version VARCHAR(25),
|
|
44
52
|
createdAt TIMESTAMP NOT NULL,
|
|
45
53
|
updatedAt TIMESTAMP NOT NULL
|
|
46
54
|
)`;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
break;
|
|
56
|
+
case 'mssql':
|
|
57
|
+
createTableQuery = `
|
|
50
58
|
CREATE TABLE sequelize_meta (
|
|
51
59
|
name VARCHAR(100) PRIMARY KEY,
|
|
52
60
|
version VARCHAR(25),
|
|
53
61
|
createdAt DATETIME NOT NULL,
|
|
54
62
|
updatedAt DATETIME NOT NULL
|
|
55
63
|
)`;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
throw new Error('Unsupported SQL type');
|
|
67
|
+
}
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
await sequelize.query(createTableQuery, {
|
|
63
|
-
type: _sequelize.QueryTypes.RAW
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Migrate the data from the old table to the new one if needed
|
|
67
|
-
if (hasLegacySequelizeMeta) {
|
|
69
|
+
// Create the new sequelize_meta table if it does not exist
|
|
68
70
|
(0, _report.reportDebug)({
|
|
69
71
|
namespace,
|
|
70
|
-
message: '
|
|
72
|
+
message: 'Creating sequelize_meta table',
|
|
73
|
+
data: {
|
|
74
|
+
sqlType: process.env.SQL_TYPE
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
await sequelize.query(createTableQuery, {
|
|
78
|
+
type: _sequelize.QueryTypes.RAW
|
|
71
79
|
});
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
(0, _report.reportDebug)({
|
|
81
|
+
namespace,
|
|
82
|
+
message: 'sequelize_meta table created successfully'
|
|
74
83
|
});
|
|
75
|
-
|
|
84
|
+
|
|
85
|
+
// Migrate the data from the old table to the new one if needed
|
|
86
|
+
if (hasLegacySequelizeMeta) {
|
|
87
|
+
(0, _report.reportDebug)({
|
|
88
|
+
namespace,
|
|
89
|
+
message: 'Legacy metadata table found, migrating data'
|
|
90
|
+
});
|
|
91
|
+
const migrations = await sequelize.query('SELECT name FROM SequelizeMeta ORDER BY name', {
|
|
92
|
+
type: _sequelize.QueryTypes.SELECT
|
|
93
|
+
});
|
|
94
|
+
const insertQuery = `
|
|
76
95
|
INSERT INTO sequelize_meta (name, version, createdAt, updatedAt) VALUES
|
|
77
96
|
${migrations.map(migration => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
switch (process.env.SQL_TYPE) {
|
|
98
|
+
case 'mysql':
|
|
99
|
+
case 'postgres':
|
|
100
|
+
return `('${migration.name}', NULL, NOW(), NOW())`;
|
|
101
|
+
case 'mssql':
|
|
102
|
+
return `('${migration.name}', NULL, GETDATE(), GETDATE())`;
|
|
103
|
+
default:
|
|
104
|
+
throw new Error('Unsupported SQL type');
|
|
105
|
+
}
|
|
106
|
+
}).join(',')}
|
|
88
107
|
`;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
await sequelize.query(insertQuery, {
|
|
109
|
+
type: _sequelize.QueryTypes.INSERT
|
|
110
|
+
});
|
|
111
|
+
}
|
|
92
112
|
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
(0, _report.reportError)({
|
|
115
|
+
namespace,
|
|
116
|
+
message: 'Error in metadata migration',
|
|
117
|
+
data: {
|
|
118
|
+
error: error instanceof Error ? error.message : String(error),
|
|
119
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
120
|
+
sqlType: process.env.SQL_TYPE,
|
|
121
|
+
sqlHost: process.env.SQL_HOST
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
throw error;
|
|
93
125
|
}
|
|
94
126
|
}
|
|
95
127
|
//# sourceMappingURL=migrateMetadataTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateMetadataTable.js","names":["_sequelize","require","_report","namespace","migrateMetadataTable","sequelize","reportDebug","message","query","
|
|
1
|
+
{"version":3,"file":"migrateMetadataTable.js","names":["_sequelize","require","_report","namespace","migrateMetadataTable","sequelize","reportDebug","message","query","data","sqlType","process","env","SQL_TYPE","tables","type","QueryTypes","SELECT","hasCustomSequelizeMeta","some","table","Object","values","hasLegacySequelizeMeta","createTableQuery","Error","RAW","migrations","insertQuery","map","migration","name","join","INSERT","error","reportError","String","stack","undefined","sqlHost","SQL_HOST"],"sources":["../../../../src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.ts"],"sourcesContent":["import { Sequelize, QueryTypes } from 'sequelize';\nimport { SequelizeMeta } from 'db/models';\nimport { reportDebug, reportError } from 'utils/report';\n\nconst namespace = 'engine:utils:dbMigration';\n\n/**\n * Run migrations on the metadata table\n * The table containing the migrations metadata cannot be handled through migrations\n * Therefore, we use a more classic approach with this function and pure SQL queries\n */\nexport async function migrateMetadataTable(\n sequelize: Sequelize\n): Promise<void> {\n try {\n reportDebug({ namespace, message: 'Executing metadata migration routine' });\n\n const query = `SELECT table_name FROM information_schema.tables`;\n\n reportDebug({ \n namespace, \n message: 'Checking for existing metadata tables',\n data: { sqlType: process.env.SQL_TYPE }\n });\n\n // We check if we have a custom sequelize_meta table yet\n const tables = await sequelize.query<Array<string>>(query, {\n type: QueryTypes.SELECT\n });\n\n const hasCustomSequelizeMeta =\n process.env.SQL_TYPE === 'postgres'\n ? tables.some((table) => table[0] === 'sequelize_meta')\n : tables.some((table) => Object.values(table)[0] === 'sequelize_meta');\n const hasLegacySequelizeMeta =\n process.env.SQL_TYPE === 'postgres'\n ? tables.some((table) => table[0] === 'SequelizeMeta')\n : tables.some((table) => Object.values(table)[0] === 'SequelizeMeta');\n if (!hasCustomSequelizeMeta) {\n reportDebug({\n namespace,\n message: 'No metadata table found, creating new one'\n });\n\n // Define SQL for creating the table based on the database type\n let createTableQuery = '';\n\n switch (process.env.SQL_TYPE) {\n case 'mysql':\n case 'postgres':\n createTableQuery = `\n CREATE TABLE sequelize_meta (\n name VARCHAR(100) PRIMARY KEY,\n version VARCHAR(25),\n createdAt TIMESTAMP NOT NULL,\n updatedAt TIMESTAMP NOT NULL\n )`;\n break;\n case 'mssql':\n createTableQuery = `\n CREATE TABLE sequelize_meta (\n name VARCHAR(100) PRIMARY KEY,\n version VARCHAR(25),\n createdAt DATETIME NOT NULL,\n updatedAt DATETIME NOT NULL\n )`;\n break;\n default:\n throw new Error('Unsupported SQL type');\n }\n\n // Create the new sequelize_meta table if it does not exist\n reportDebug({ \n namespace, \n message: 'Creating sequelize_meta table',\n data: { sqlType: process.env.SQL_TYPE }\n });\n await sequelize.query(createTableQuery, { type: QueryTypes.RAW });\n reportDebug({ namespace, message: 'sequelize_meta table created successfully' });\n\n // Migrate the data from the old table to the new one if needed\n if (hasLegacySequelizeMeta) {\n reportDebug({\n namespace,\n message: 'Legacy metadata table found, migrating data'\n });\n\n const migrations = await sequelize.query<SequelizeMeta>(\n 'SELECT name FROM SequelizeMeta ORDER BY name',\n {\n type: QueryTypes.SELECT\n }\n );\n\n const insertQuery = `\n INSERT INTO sequelize_meta (name, version, createdAt, updatedAt) VALUES\n ${migrations\n .map((migration) => {\n switch (process.env.SQL_TYPE) {\n case 'mysql':\n case 'postgres':\n return `('${migration.name}', NULL, NOW(), NOW())`;\n case 'mssql':\n return `('${migration.name}', NULL, GETDATE(), GETDATE())`;\n default:\n throw new Error('Unsupported SQL type');\n }\n })\n .join(',')}\n `;\n\n await sequelize.query(insertQuery, { type: QueryTypes.INSERT });\n }\n }\n } catch (error) {\n reportError({\n namespace,\n message: 'Error in metadata migration',\n data: {\n error: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n sqlType: process.env.SQL_TYPE,\n sqlHost: process.env.SQL_HOST\n }\n });\n throw error;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,SAAS,GAAG,0BAA0B;;AAE5C;AACA;AACA;AACA;AACA;AACO,eAAeC,oBAAoBA,CACxCC,SAAoB,EACL;EACf,IAAI;IACF,IAAAC,mBAAW,EAAC;MAAEH,SAAS;MAAEI,OAAO,EAAE;IAAuC,CAAC,CAAC;IAE3E,MAAMC,KAAK,GAAG,kDAAkD;IAEhE,IAAAF,mBAAW,EAAC;MACVH,SAAS;MACTI,OAAO,EAAE,uCAAuC;MAChDE,IAAI,EAAE;QAAEC,OAAO,EAAEC,OAAO,CAACC,GAAG,CAACC;MAAS;IACxC,CAAC,CAAC;;IAEF;IACA,MAAMC,MAAM,GAAG,MAAMT,SAAS,CAACG,KAAK,CAAgBA,KAAK,EAAE;MACzDO,IAAI,EAAEC,qBAAU,CAACC;IACnB,CAAC,CAAC;IAEJ,MAAMC,sBAAsB,GAC1BP,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,UAAU,GAC/BC,MAAM,CAACK,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,GACrDN,MAAM,CAACK,IAAI,CAAEC,KAAK,IAAKC,MAAM,CAACC,MAAM,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC;IAC1E,MAAMG,sBAAsB,GAC1BZ,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,UAAU,GAC/BC,MAAM,CAAC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A,UAAUD,UAAU,CACTE,GAAG,CAAEC,SAAS,IAAK;UAClB,QAAQnB,OAAO,CAACC,GAAG,CAACC,QAAQ;YAC1B,KAAK,OAAO;YACZ,KAAK,UAAU;cACb,OAAO,KAAKiB,SAAS,CAACC,IAAI,wBAAwB;YACpD,KAAK,OAAO;cACV,OAAO,KAAKD,SAAS,CAACC,IAAI,gCAAgC;YAC5D;cACE,MAAM,IAAIN,KAAK,CAAC,sBAAsB,CAAC;UAC3C;QACF,CAAC,CAAC,CACDO,IAAI,CAAC,GAAG,CAAC;AACpB,KAAK;QAEC,MAAM3B,SAAS,CAACG,KAAK,CAACoB,WAAW,EAAE;UAAEb,IAAI,EAAEC,qBAAU,CAACiB;QAAO,CAAC,CAAC;MACjE;IACF;EACA,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,IAAAC,mBAAW,EAAC;MACVhC,SAAS;MACTI,OAAO,EAAE,6BAA6B;MACtCE,IAAI,EAAE;QACJyB,KAAK,EAAEA,KAAK,YAAYT,KAAK,GAAGS,KAAK,CAAC3B,OAAO,GAAG6B,MAAM,CAACF,KAAK,CAAC;QAC7DG,KAAK,EAAEH,KAAK,YAAYT,KAAK,GAAGS,KAAK,CAACG,KAAK,GAAGC,SAAS;QACvD5B,OAAO,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ;QAC7B0B,OAAO,EAAE5B,OAAO,CAACC,GAAG,CAAC4B;MACvB;IACF,CAAC,CAAC;IACF,MAAMN,KAAK;EACb;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-server-engine",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.5",
|
|
4
4
|
"description": "Framework used to develop backend services. This package ships with a lot of features to standardize the creation of services, letting you focus on the business logic.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|