Skip to content

Commit

Permalink
Added email gateway migration (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp authored May 6, 2024
1 parent 697cd26 commit f1de9c6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Migration/EmailGatewayMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Terminal42\NotificationCenterBundle\Migration;

use Contao\CoreBundle\Migration\AbstractMigration;
use Contao\CoreBundle\Migration\MigrationResult;
use Doctrine\DBAL\Connection;

class EmailGatewayMigration extends AbstractMigration
{
public function __construct(private readonly Connection $connection)
{
}

public function shouldRun(): bool
{
return $this->connection->fetchOne("SELECT COUNT(*) FROM tl_nc_gateway WHERE type='email'") > 0;
}

public function run(): MigrationResult
{
$this->connection->executeStatement("UPDATE tl_nc_gateway SET type='mailer' WHERE type='email'");

return $this->createResult(true);
}
}

0 comments on commit f1de9c6

Please sign in to comment.