- App\Message\MailSyncRequested (optionnel folderPath) - App\MessageHandler\MailSyncRequestedHandler delegue a MailSyncService::syncFolder ou syncAll - messenger.yaml : transport async via Doctrine DSN, retry 3x exponentiel, failure transport - en test : transport in-memory (sync immediat) - migration Version20260519220000 : cree messenger_messages table (idempotente, IF NOT EXISTS) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Cree la table messenger_messages pour le transport async Symfony Messenger.
|
|
*/
|
|
final class Version20260519220000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Cree la table messenger_messages pour le transport async Doctrine de Symfony Messenger.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE IF NOT EXISTS messenger_messages (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
body TEXT NOT NULL,
|
|
headers TEXT NOT NULL,
|
|
queue_name VARCHAR(190) NOT NULL,
|
|
created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,
|
|
available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,
|
|
delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL
|
|
)
|
|
SQL);
|
|
|
|
$this->addSql('CREATE INDEX IF NOT EXISTS IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
|
|
$this->addSql('CREATE INDEX IF NOT EXISTS IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
|
|
$this->addSql('CREATE INDEX IF NOT EXISTS IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
|
|
|
|
$this->addSql(<<<'SQL'
|
|
CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
PERFORM pg_notify('messenger_messages', NEW.queue_name::text);
|
|
RETURN NEW;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
SQL);
|
|
|
|
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
|
|
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('DROP TABLE IF EXISTS messenger_messages');
|
|
$this->addSql('DROP FUNCTION IF EXISTS notify_messenger_messages()');
|
|
}
|
|
}
|