fix(migrations): use migration file extension according to runtime

We need to use .ts only if we run inside ts-node
or other tools that use it. In all other cases, we need to
refer to the .js migration files.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2023-10-08 16:56:56 +02:00 committed by Philip Molares
parent f8f198f9c9
commit 10776de54f
2 changed files with 26 additions and 1 deletions

View file

@ -38,6 +38,7 @@ import { WebsocketModule } from './realtime/websocket/websocket.module';
import { RevisionsModule } from './revisions/revisions.module';
import { SessionModule } from './sessions/session.module';
import { UsersModule } from './users/users.module';
import { detectTsNode } from './utils/detectTsNode';
const routes: Routes = [
{
@ -70,7 +71,11 @@ const routes: Routes = [
autoLoadEntities: true,
logging: true,
logger: logger,
migrations: [`**/migrations/${databaseConfig.type}-*{.ts,.js}`],
migrations: [
`**/migrations/${databaseConfig.type}-*.${
detectTsNode() ? 'ts' : 'js'
}`,
],
migrationsRun: true,
};
},