Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

79
Visualizações
Prevent TypeORM from generating constraints

I am extending a class Entity to create a history table. The history table, must not inherit the unique constraints from the base class because we need to duplicate most of the data in there. Of course, I can just copy the properties without extending the base class but will result in maintaining two classes for each history table.

There is any way, to prevent TypeORM from generating constraints for a class entity?

I am thinking about something similar to avoiding foreign key constraint creation. Maybe a class decorator (something like @IgnoreConstraints) would be nice to have for this type of situations.

//Base class with required constraint
@Entity()
@Unique(['email', 'shopId'])
export class Customer {}

// Will inherit the unique constraint 
@Entity()
export class CustomerHistory extends Customer {}

More, I am using anchan828's very useful TypeORM History library which is adding a dropUniqueIndices method to be used in a later migration but unfortunately will later result in auto-generated migrations including those constraints and schema:sync will no longer work.

Thanks!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda