Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Migrations: unneeded foreign keys fix for InnoDB in MySQL >= 4.1.x #390

Open
meglio opened this Issue Jun 21, 2012 · 0 comments

Comments

Projects
None yet
1 participant

meglio commented Jun 21, 2012

In generated migration file I can see this:

ALTER TABLE `spin_book_inclusion` DROP FOREIGN KEY `frn_spin_book_included`;

ALTER TABLE `spin_book_inclusion` ADD CONSTRAINT `frn_spin_book_included`
    FOREIGN KEY (`uses_book_id`)
    REFERENCES `spin_books` (`id`)
    ON UPDATE CASCADE
    ON DELETE RESTRICT;

ALTER TABLE `trigger_records` DROP FOREIGN KEY `frn_trigger_data_record`;

ALTER TABLE `trigger_records` DROP `created_at`;

ALTER TABLE `trigger_records` DROP `updated_at`;

ALTER TABLE `trigger_records` ADD CONSTRAINT `frn_trigger_data_record`
    FOREIGN KEY (`record_id`)
    REFERENCES `data_records` (`id`)
    ON UPDATE CASCADE
    ON DELETE RESTRICT;

While this fix is needed for table trigger_records (because there is what to change), it looks useless for other tables with no changes needed, like spin_book_inclusion in my example.

Because of this fix, even if you have nothing to change, you will always get 2 x [number of tables] queries when you run propel-gen diff

Can it be applied only for tables that really need changes to be applied, eg foreign key dropping and recreation.

Please correct me if I'm missing something.

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