I've started a project with TypeORM and I'm having a problem. I've got the synchronize option set to true on TypeORM config, but when I run the application I receive the following error: QueryFailedError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
I've read a little bit about it but the only thing I found was someone saying that it was something related to running tests in parallel, not the same issue I've got.
It could be something related to async/await maybe, here is the database connection part:
export const databaseProviders = [
{
provide: 'DATABASE_CONNECTION',
useFactory: async () => await createConnection({
type: "postgres",
host: process.env.TYPEORM_HOST.toString(),
port: Number(process.env.PORT),
username: process.env.TYPEORM_USER.toString(),
password: process.env.TYPEORM_PASSWORD.toString(),
database: process.env.TYPEORM_DATABASE,
entities: [
__dirname + '/../**/*.entity{.ts,.js}',
],
synchronize: true,
logging: true
})
}
]
I don't intend to use this project in production, I want TypeORM to generate the table for me, that's it. Maybe I could solve this by setting synchronize to false and using migrations.
It seems to be creating, or trying to create the table 3 times.
Anyway, hope someone can help me.
