Description
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-mysqlaurora-postgresbetter-sqlite3cockroachdbcordovaexpomongodbmysqlnativescriptoraclepostgresreact-nativesapspannersqlitesqlite-abstractsqljssqlserver
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 commentedon May 30, 2023
See #10090 I think it's the same.
pleerock commentedon Jun 20, 2023
Must be fixed by #10041