Skip to content

Wrong foreign key information loaded from schema #6168

@weckx

Description

@weckx

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[x] 0.2.5

Steps to reproduce or a small repository showing the problem:

When using MySQL/MariaDB if you have an entity with a foreign key and it is created in two different schemas (i.e. a development schema and a staging schema) on the same server, the information loaded from the schema is non-deterministic, as it can come from either schema, due to a missing clause in the query used to load the data from MySQL's information schema.

A simple way to test this is:

  1. Create an entity with a ManyToOne relation to another entity
  2. Generate the migration and synchronize to the database
  3. Change the schema for the entity
  4. Change the ManyToOne relation onUpdate and/or onDelete values
  5. Generate the migration for the new schema
  6. Apply the migration
  7. Generate a new migration. Due to the wrong information loaded the onUpdate or onDelete values might come from the wrong schema and generate an unnecessary foreign key recreation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions