fix: missing migration folder broke non-root setups (#17266)

This commit is contained in:
Jason Rasmussen 2025-03-31 16:18:13 -04:00 committed by GitHub
parent 5b63b9fc8b
commit 186c573565
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,8 @@ import { Injectable } from '@nestjs/common';
import AsyncLock from 'async-lock';
import { FileMigrationProvider, Kysely, Migrator, sql, Transaction } from 'kysely';
import { InjectKysely } from 'nestjs-kysely';
import { mkdir, readdir } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import semver from 'semver';
import { EXTENSION_NAMES, POSTGRES_VERSION_RANGE, VECTOR_VERSION_RANGE, VECTORS_VERSION_RANGE } from 'src/constants';
@ -212,8 +213,11 @@ export class DatabaseRepository {
// eslint-disable-next-line unicorn/prefer-module
const migrationFolder = join(__dirname, '..', 'schema/migrations');
// TODO remove after we have at least one kysely migration
await mkdir(migrationFolder, { recursive: true });
if (!existsSync(migrationFolder)) {
return;
}
this.logger.debug('Running kysely migrations');
const migrator = new Migrator({