@tigerdata/mcp-boilerplate 1.3.3 → 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.
@@ -10,15 +10,7 @@ export async function cliEntrypoint(stdioEntrypoint, httpEntrypoint, instrumenta
10
10
  if (dbConfig) {
11
11
  const { createMigrator } = await import('./migrate.js');
12
12
  log.info('starting server...');
13
- try {
14
- log.info('Running database migrations...');
15
- await createMigrator(dbConfig).run();
16
- log.info('Database migrations completed successfully');
17
- }
18
- catch (error) {
19
- log.error('Database migration failed:', error);
20
- throw error;
21
- }
13
+ await createMigrator(dbConfig).run();
22
14
  }
23
15
  // Dynamically import only the requested module to prevent all modules from initializing
24
16
  switch (scriptName) {
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
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import migrate from 'migrate';
3
3
  import { Client } from 'pg';
4
+ import { log } from './logger.js';
4
5
  const createStateStore = (name, schema = 'public') => {
5
6
  let client;
6
7
  // Use a hash of the project name to create a lock
@@ -62,20 +63,43 @@ export const createMigrator = (config) => {
62
63
  const stateStore = createStateStore(serviceName, schema);
63
64
  return {
64
65
  run: async () => new Promise((resolve, reject) => {
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
+ };
65
84
  migrate.load({
66
85
  stateStore,
67
86
  migrationsDirectory: migrationsDirectory ?? './migrations',
68
87
  }, (err, set) => {
69
88
  if (err) {
89
+ restore();
90
+ log.error('Database migration failed:', err);
70
91
  stateStore.close().finally(() => reject(err));
71
92
  return;
72
93
  }
73
94
  set.up((err) => {
95
+ restore();
74
96
  stateStore.close().finally(() => {
75
97
  if (err) {
98
+ log.error('Database migration failed:', err);
76
99
  reject(err);
77
100
  }
78
101
  else {
102
+ log.info('Database migrations completed successfully');
79
103
  resolve();
80
104
  }
81
105
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigerdata/mcp-boilerplate",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "MCP boilerplate code for Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "author": "TigerData",