skip to Main Content

I have one nestjs app where I’m using typeorm, PostgreSQL . This app is working fine on linux/mac os. But in windows 11, no data found on migration table, that’s why no table is created on PostgreSQL database. When I run npm run start:dev, it is showing following message on terminal:

$ npm run start:dev
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] start:dev
> nest start --watch --preserveWatchOutput

[2:00:24 PM] Starting compilation in watch mode...

[2:01:01 PM] Found 0 errors. Watching for file changes.

.......................................................................................
.......................................................................................

{"level":30,"ctx":"InstanceLoader","msg":"AppModule dependencies initialized"}
{"level":30,"ctx":"DBLogger","query":"SELECT * FROM current_schema()"}
{"level":30,"ctx":"DBLogger","msg":"No classes were found using the provided glob pattern:  "dist/src/server/migration/*{.ts,.js}""}
{"level":30,"ctx":"DBLogger","query":"CREATE EXTENSION IF NOT EXISTS "uuid-ossp""}
{"level":30,"ctx":"DBLogger","query":"SELECT version();"}
{"level":30,"ctx":"DBLogger","query":"SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'"}
{"level":30,"ctx":"DBLogger","query":"SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC","parameters":[]}
{"level":30,"ctx":"DBLogger","msg":"No migrations are pending"}
{"level":30,"ctx":"InstanceLoader","msg":"TypeOrmCoreModule dependencies initialized"}

.......................................................................................
.......................................................................................

{"level":30,"ctx":"NestApplication","msg":"Nest application successfully started"}

I have build by runningnpm run build. Then run npm run typeorm -- migration:run

npm run typeorm -- migration:run
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] typeorm
> typeorm-ts-node-esm -d ./ormconfig.ts "migration:run"

query: SELECT * FROM current_schema()
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

ormconfig.ts code:

import * as dotenv from 'dotenv';
import { DataSource } from 'typeorm';

dotenv.config();

const connection = new DataSource({
  type: 'postgres' as const,
  host: 'localhost',
  port: 5432,
  username: 'postgres',
  password: 'mango',
  database: 'loyalty',
  entities: ['src/server/entity/*.{ts,js}'],
  migrations: ['src/server/migration/*.{ts,js}'],
  extra: {
    ssl: false,
  },
});

export default connection;

app.module.ts

@Module({
    imports: [
        TypeOrmModule.forRootAsync({
          imports: [ConfigModule],
          inject: [ConfigService],
          useFactory: (configService: ConfigService) => {
            return {
              type: 'postgres',
              entities: [],
              synchronize: false,
              migrations: ['dist/src/server/migration/*{.ts,.js}'],
              migrationsTableName: 'migrations',
              migrationsRun: true,
            };
          },
        }),
    ],
    controllers: [],
    providers: [],
})
export class AppModule {
    constructor(private connection: Connection) {}
}

File structure:

project
|--------> dist
              |--------> src
                         |--------> server
                                         |---------> migration
|--------> src
     |--------> server
                     |---------> migration

Any suggestion will be highly appreciable. Thanks in advance.

Update: I also run this project inside Docker container, and still same issue.

2

Answers


  1. I think you should research/search before asking the question

    try this answer

    Login or Signup to reply.
  2. The solution: https://github.com/typeorm/typeorm/issues/9766

    It seems the glob dependency from [email protected] is not working correctly with Windows.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search