import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CoffeesModule } from './coffees/coffees.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { NestTypeOrmCommandsModule } from 'nestjs-typeorm-commands';
@Module({
imports: [
CoffeesModule,
TypeOrmModule.forRoot({
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'pass123',
database: 'postgres',
autoLoadEntities: true,
}),
NestTypeOrmCommandsModule.forRoot({
migrationsDir: 'src/migrations',
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
After running npm run migration:run I get the following output, telling me that no migrations are pending:
$ npm run migration:run
> testing-project@0.0.1 migration:run
> ts-node -r tsconfig-paths/register src/cli.ts typeorm migration:run
query: SELECT version();
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
No migrations are pending
However, I do see migrations exist in dist/migration folder in Nest.
I tried adding migrations: ['dist/migrations/*.js'], to TypeOrmModule.forRoot as well but it didn't work as well.
app.module.ts
After running
npm run migration:run
I get the following output, telling me that no migrations are pending:However, I do see migrations exist in
dist/migration
folder in Nest.I tried adding
migrations: ['dist/migrations/*.js'],
toTypeOrmModule.forRoot
as well but it didn't work as well.Steps to reproduce:
pnpm install
to install deps & then rundocker-compose up -d
to run postgres dbsrc/coffees/entities/coffee.entity.ts
file and append a newdescription
column like so:npm run migration:generate SchemaSync
to generate migrationnpm run build
to build the appnpm run migration:run
and then you will see it doesn't run the new migration