Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

78
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!