@mtg-tracker/common 1.0.12 → 1.0.14

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.
@@ -1,2 +1,2 @@
1
1
  import mysql from 'mysql2/promise';
2
- export declare function runMigrations(pool: mysql.Pool, service: string): Promise<void>;
2
+ export declare function runMigrations(pool: mysql.Pool, migrationsDir: string, service: string): Promise<void>;
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.runMigrations = runMigrations;
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const path_1 = __importDefault(require("path"));
18
- function runMigrations(pool, service) {
18
+ function runMigrations(pool, migrationsDir, service) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  console.log(`Running database migrations for the ${service} service...`);
21
21
  // Sanitize service name
@@ -29,8 +29,12 @@ function runMigrations(pool, service) {
29
29
  executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
30
30
  )
31
31
  `);
32
- // Get all migration files
33
- const migrationsDir = path_1.default.join(__dirname, 'migrations');
32
+ // Check if migrations directory exists
33
+ if (!fs_1.default.existsSync(migrationsDir)) {
34
+ console.log(`No migrations directory found at ${migrationsDir}, skipping migrations...`);
35
+ return;
36
+ }
37
+ // Get all migration files from the provided directory
34
38
  const files = fs_1.default.readdirSync(migrationsDir)
35
39
  .filter(file => file.endsWith('_up.sql'))
36
40
  .sort(); // Sort to ensure correct order
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtg-tracker/common",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",