@tigerdata/mcp-boilerplate 1.3.4 → 1.3.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/index.d.ts +1 -1
- package/dist/migrate.js +19 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { registerExitHandlers } from './registerExitHandlers.js';
|
|
|
7
7
|
export { StatusError } from './StatusError.js';
|
|
8
8
|
export { stdioServerFactory } from './stdio.js';
|
|
9
9
|
export { addAiResultToSpan, withSpan } from './tracing.js';
|
|
10
|
-
export type { ApiFactory, InferSchema, McpFeatureFlags, ParsedQs, PromptFactory, ResourceFactory, } from './types.js';
|
|
10
|
+
export type { ApiFactory, InferSchema, McpFeatureFlags, MigrationsConfig, ParsedQs, PromptFactory, ResourceFactory, } from './types.js';
|
package/dist/migrate.js
CHANGED
|
@@ -64,16 +64,35 @@ export const createMigrator = (config) => {
|
|
|
64
64
|
return {
|
|
65
65
|
run: async () => new Promise((resolve, reject) => {
|
|
66
66
|
log.info('Running database migrations...');
|
|
67
|
+
// Set search_path via PGOPTIONS so every pg.Client created by migration
|
|
68
|
+
// files picks it up automatically, without touching the migration files.
|
|
69
|
+
const prevPgOptions = process.env.PGOPTIONS;
|
|
70
|
+
if (schema) {
|
|
71
|
+
process.env.PGOPTIONS =
|
|
72
|
+
`${prevPgOptions ?? ''} --search_path=${schema},public`.trim();
|
|
73
|
+
}
|
|
74
|
+
const restore = () => {
|
|
75
|
+
if (schema) {
|
|
76
|
+
if (prevPgOptions === undefined) {
|
|
77
|
+
delete process.env.PGOPTIONS;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
process.env.PGOPTIONS = prevPgOptions;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
67
84
|
migrate.load({
|
|
68
85
|
stateStore,
|
|
69
86
|
migrationsDirectory: migrationsDirectory ?? './migrations',
|
|
70
87
|
}, (err, set) => {
|
|
71
88
|
if (err) {
|
|
89
|
+
restore();
|
|
72
90
|
log.error('Database migration failed:', err);
|
|
73
91
|
stateStore.close().finally(() => reject(err));
|
|
74
92
|
return;
|
|
75
93
|
}
|
|
76
94
|
set.up((err) => {
|
|
95
|
+
restore();
|
|
77
96
|
stateStore.close().finally(() => {
|
|
78
97
|
if (err) {
|
|
79
98
|
log.error('Database migration failed:', err);
|