You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that if you change the order of constraints when setting up the table Typeorm will fail to correctly detect uniqueness of columns.
The problematic part is this (part of the User.ts model):
The OneToOne relation requires unique constraint on the userMetaId column.
However if we create ["id", "userMetaId"] constraint and then ["userMetaId"], Typeorm will catch only the first one
and decide that the constraint is composite so the column is not unique.
This means that if we edit the initial migration and change order of constraints so that ("userMetaId") precede the other one, everything will works fine.
My Environment
Dependency
Version
Operating System
MacOS Catalina 10.15.7
Node.js version
12.7.0
Typescript version
3.9.7
TypeORM version
0.2.37
Additional Context
Relevant Database Driver(s)
DB Type
Reproducible
aurora-data-api
no
aurora-data-api-pg
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
yes
react-native
no
sap
no
sqlite
no
sqlite-abstract
no
sqljs
no
sqlserver
no
Are you willing to resolve this issue by submitting a Pull Request?
✅ Yes, I have the time, and I know how to start.
✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
✖️ No, I don’t have the time, but I can support (using donations) development.
✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Description
Expected Behavior
Typeorm should detect the unique constraint for column was already created and skip its creation.
Actual Behavior
Typeorm does not detect the constraint is present and tries to create it again:
Steps to Reproduce
npm install
docker-compose -f ./docker-compose.yml up --abort-on-container-exit
npm run migrate:up
npm run migrate:generate NewMigration
npm run migrate:up
will fail (on the new migration).The failure message will be:
The problem is that if you change the order of constraints when setting up the table Typeorm will fail to correctly detect uniqueness of columns.
The problematic part is this (part of the
User.ts
model):The OneToOne relation requires unique constraint on the
userMetaId
column.However if we create
["id", "userMetaId"]
constraint and then["userMetaId"]
, Typeorm will catch only the first oneand decide that the constraint is composite so the column is not unique.
This means that if we edit the initial migration and change order of constraints so that ("userMetaId") precede the other one, everything will works fine.
My Environment
Additional Context
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
PR for this issue: #8157
The text was updated successfully, but these errors were encountered: