TypeORM with multiple schemas

Viewed 20

I am using NestJS/TypeORM with a Postgres database that has multiple schemas (eg. Public, Schema1, Schema2, etc). Some of my entities are only supposed to be created in one of the alternate schemas; eg. myTable should only be created in Schema1.

@Entity({name: 'myTable', schema: 'Schema1'})

When I generate a migration, however, it creates migration code for this table in both the public schema and Schema1; eg:

await queryRunner.query(`CREATE TABLE "myTable" ("id" SERIAL NOT NULL`);
await queryRunner.query(`CREATE TABLE "Schema1.myTable" ("id" SERIAL NOT NULL`);

So when I run the migrations I end up with duplicate tables in the public schema and Schema1. Is there any way to only generate migrations for a specific schema (eg. Schema1) that is specified in the @Entity?

0 Answers
Related