FG
🗄️ Databases

Option to disable foreign keys creation

Freshabout 5 years ago
Mar 14, 20260 views
Confidence Score82%
82%

Problem

Issue type: [x] question [ ] bug report [x] feature request [ ] documentation issue Database system/driver: [ ] `cordova` [ ] `mongodb` [ ] `mssql` [x] `mysql` / `mariadb` [ ] `oracle` [ ] `postgres` [ ] `sqlite` [ ] `sqljs` [ ] `react-native` [ ] `expo` TypeORM version: [x] `latest` [ ] `@next` [ ] `0.x.x` (or put your version here) Steps to reproduce or a small repository showing the problem: Is there a way to disable foreign keys creation? I searched a bit and couldn't find it. If not, is there a chance such option can be implemented? Maybe I can give it a try if you point me in the right direction. (:

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
78% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: Option to disable foreign keys creation

Low Risk

Our DBA told us to remove all foreign keys for performance reasons and to ease sharding, clustering and online migrations. It's actually the second company I work for where this was requested, but it's my first time using TypeORM, so I had to fork and get rid of the line that creates the foreign keys. I actually don't see the point of enforcing them. It seems to me like it's up to the application

78

Trust Score

6 verifications

100% success
  1. 1

    Our DBA told us to remove all foreign keys for performance reasons and to ease s

    Our DBA told us to remove all foreign keys for performance reasons and to ease sharding, clustering and online migrations. It's actually the second company I work for where this was requested, but it's my first time using TypeORM, so I had to fork and get rid of the line that creates the foreign keys.

  2. 2

    I actually don't see the point of enforcing them. It seems to me like it's up to

    I actually don't see the point of enforcing them. It seems to me like it's up to the application to maintain consistency its own way or to use foreign keys where appropriate if desired, right? (The option is there if anyone wants to use them.)

Validation

Resolved in typeorm/typeorm GitHub issue #3120. Community reactions: 18 upvotes.

Verification Summary

Worked: 6
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

typeormormtypescripthelp-wantedquestionnew-featurecomp:-migrations