Skip to content

TypeORM drops and creates indexes and foreign keys when migrating #9979

Closed
@albalak88

Description

@albalak88

Issue description

TypeORM drops and creates indexes and foreign keys when migrating

Expected Behavior

I expect to see only changes in my entities.

Actual Behavior

Unnecessary queries like:

await queryRunner.query(ALTER TABLE `meeting_to_user` DROP FOREIGN KEY `FK_67fd4bcf288e6f67be1680f1080`); await queryRunner.query(ALTER TABLE `meeting_to_user` DROP FOREIGN KEY `FK_891897f387d5a605577427893be`); await queryRunner.query(ALTER TABLE `message_to_user` DROP FOREIGN KEY `FK_956ca24187965ed5ad5c36e1b49`); await queryRunner.query(ALTER TABLE `message_to_user` DROP FOREIGN KEY `FK_a422a0468e284bf6effb37960e0`); await queryRunner.query(ALTER TABLE `meeting_to_user` ADD CONSTRAINT `FK_67fd4bcf288e6f67be1680f1080` FOREIGN KEY (`usersId`) REFERENCES `users`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); await queryRunner.query(ALTER TABLE `meeting_to_user` ADD CONSTRAINT `FK_891897f387d5a605577427893be` FOREIGN KEY (`meetingId`) REFERENCES `appointments`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); await queryRunner.query(ALTER TABLE `message_to_user` ADD CONSTRAINT `FK_a422a0468e284bf6effb37960e0` FOREIGN KEY (`usersId`) REFERENCES `users`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); await queryRunner.query(ALTER TABLE `message_to_user` ADD CONSTRAINT `FK_956ca24187965ed5ad5c36e1b49` FOREIGN KEY (`messageId`) REFERENCES `message`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION);

Steps to reproduce

Run migration

My Environment

| TypeORM version | 0.2.45 |

Additional Context

I can see people have already experienced this, but I can see no fix!
I saw that maybe the MariaDB driver was causing this, but I'm using the MySQL one.

Relevant Database Driver(s)

  • aurora-mysql
    aurora-postgres
    better-sqlite3
    cockroachdb
    cordova
    expo
    mongodb
    mysql
    nativescript
    oracle
    postgres
    react-native
    sap
    spanner
    sqlite
    sqlite-abstract
    sqljs
    sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Activity

N-Andronopoulos

N-Andronopoulos commented on May 30, 2023

@N-Andronopoulos

See #10090 I think it's the same.

pleerock

pleerock commented on Jun 20, 2023

@pleerock
Member

Must be fixed by #10041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      TypeORM drops and creates indexes and foreign keys when migrating · Issue #9979 · typeorm/typeorm