-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration doesnt work after update to 3.8.0 ( Throws an exception if addSql is used in post methods) #1440
Comments
I'd like to replace the exception with a deprecation. Even if such calls don't make any sense, we shouldn't start throwing exceptions in a minor release on code that was "fine" for years. |
HI @ko4aisheretodev.
I understand your point, but I'm afraid people might miss the warning and the fact the code is not executed when running the migration. I cannot look at the code now but maybe it's possible to
This way:
WDYT ? |
They certainly will. But it's not our job to lecture them by making hundreds of migrations fail after a minor upgrade. Those might have been written years ago by devs that have left the company since then. I don't want people to be scared of upgrading to a new minor.
Sure. Make that exception opt-in and I'm good. But it can't be the default behavior in a 3.x release. |
Yea, sure, minimal example is final class Version20201231231231 extends AbstractMigration
{
public function preUp(Schema $schema): void
{
parent::preUp($schema);
$this->addSql('SET foreign_key_checks = 0;');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$this->addSql('SET foreign_key_checks = 1;');
}
public function up(Schema $schema): void
{
$table = $schema->getTable('tbl');
$table->addForeignKeyConstraint('tbl2', ['field_id'], ['id'], [], 'a_b');
}
public function down(Schema $schema): void
{
$table = $schema->getTable('tbl');
$table->removeForeignKey('a_b');
}
public function isTransactional(): bool
{
return false;
}
} Also see that SET foreign_key_checks = 1 is not executed, but from your response, I understand that this is expected behavior (though it might not be obvious). |
I agree it's not obvious. I got the issue recently that's why I opened the issue #1431. Be aware that with such migration you never set foreign_key_checks back indeed.
I'll try to take a look bout this in the week. @derrabus (I understand this might be too long) |
Maybe something like this 3.8.x...VincentLanglet:migrations:warning-instead @derrabus @greg0ire WDYT ? And then the |
I recently faced this exception. In case it's useful for folks reading this, the following change fixed it: public function postUp(Schema $schema): void
{
// ...
- $this->addSql('ALTER TABLE ... SET NOT NULL');
+ $this->connection->executeStatement('ALTER TABLE ... SET NOT NULL');
} |
You have to know that with Didn't find new time to work on 3.8.x...VincentLanglet:migrations:warning-instead though |
Support Question
We encountered the following issue - after the execution of composer update, some of our migrations stopped working correctly.
This is related to this merge request: #1432
I might have missed this, but I expected that updating from doctrine/migrations 3.7.4 to 3.8.0 would not introduce any backward-incompatible changes.
In project, we don't have a direct dependency on doctrine/migrations, only on doctrine/doctrine-migrations-bundle. Could you please advise on how to properly version the doctrine/doctrine-migrations-bundle package to ensure that I don't get any backward-incompatible changes when running composer update?
Thank you for any response.
The text was updated successfully, but these errors were encountered: