Skip to content
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

Make sure mailerTransport can be NULL #383

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aschempp
Copy link
Member

While updating from Contao 4.13 and Notification Center 1.*, I got the following error because the field appears to be non-nullable in version 1

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mailerTransport' cannot be null

@aschempp aschempp added the bug label Nov 27, 2024
@aschempp aschempp requested a review from Toflar November 27, 2024 09:31
Copy link
Collaborator

@fritzmg fritzmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could check for

if ($columns['mailertransport']->getNotnull()) {
    return false;
}

in shouldRun(), then the migration will only be executed after the field has been made nullable by the regular database updates.

@@ -33,6 +33,7 @@ public function shouldRun(): bool

public function run(): MigrationResult
{
$this->connection->executeStatement("ALTER TABLE tl_nc_gateway CHANGE mailerTransport mailterTransport varchar(64) DEFAULT NULL");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->connection->executeStatement("ALTER TABLE tl_nc_gateway CHANGE mailerTransport mailterTransport varchar(64) DEFAULT NULL");
$this->connection->executeStatement("ALTER TABLE tl_nc_gateway CHANGE mailerTransport mailerTransport varchar(64) DEFAULT NULL");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants