mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Ability to disable FOREIGN KEY CONSTRAINT when using Doctrine generate migration #6282
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TangMonk on GitHub (Aug 12, 2019).
Originally assigned to: @Ocramius on GitHub.
Feature Request
Summary
Guaranteed constraints require additional computing resources. The application server is easier to scale horizontally than the database server, so the constraints should be placed in the business logic.
I often change/add some field in Entity and using
bin/console make:migrationto generate migrations, that's convenience just like in Rails or Django. But I do not need Foreign Key Constraint when I using Doctrine Relationships(ManyToOne, OneToMany...).I have to delete lines contained Foreign Key Constraint in generated migrations. But When I doing some changes with Entity, and run
bin/console make:migration, It will add Foreign Key Constraint again, it is annoying.In django model ForeignKey you can set
db_constraint=False, so migration would not generate Foreign Key constraint@Ocramius commented on GitHub (Aug 12, 2019):
If you don't want foreign keys, you can use a custom DB platform that disables foreign key support.
Besides that, migrations are to be checked one by one anyway, before being committed.
@slince commented on GitHub (Jan 29, 2023):
@Ocramius
this way is no longer working in the lastest version.
@Ocramius commented on GitHub (Jan 29, 2023):
Time to learn about respecting foreign keys 😁
Disabling FKs during a migration can still be done on some platforms (notably MySQL).