From 945f83dd596005c8e9d5ce14ddea9b98f9f49d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 20 Jul 2026 12:16:40 +0200 Subject: [PATCH 01/10] Add Doctrine Migrations baseline for ibexa/messenger (new at 5.0) Adds InstallSchemaMigration tagged 5.0.0 (the package's introduction version, no pre-5.0 legacy state to reconcile). SQL generated via ibexa:doctrine:schema:dump-sql from the current schema.yaml and verified end-to-end against a real SQLite connection - resulting tables match a fresh dump-sql exactly. Existing schema.yaml + BuildSchemaEventSubscriber left untouched. --- .../Migration/InstallSchemaMigration.php | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php index c7bb502..a07b3b8 100644 --- a/src/bundle/Migration/InstallSchemaMigration.php +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -9,12 +9,14 @@ namespace Ibexa\Bundle\Messenger\Migration; use DateTimeImmutable; +use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Schema; -use Ibexa\Contracts\DoctrineMigrations\Migrations\AbstractSqlMigration; +use Doctrine\Migrations\AbstractMigration; use Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationInterface; -use Ibexa\DoctrineMigrations\Migration\SqlPlatform; -final class InstallSchemaMigration extends AbstractSqlMigration implements IbexaMigrationInterface +final class InstallSchemaMigration extends AbstractMigration implements IbexaMigrationInterface { public function getDescription(): string { @@ -33,19 +35,32 @@ public static function getCreationDate(): DateTimeImmutable public function up(Schema $schema): void { - $this->abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE); + if ($this->platform instanceof AbstractMySQLPlatform) { + $this->addSql('CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); - if ($schema->hasTable('ibexa_messenger_messages') - && $schema->hasTable('ibexa_messenger_lock_keys')) { - return; - } + } elseif ($this->platform instanceof PostgreSQLPlatform) { + $this->addSql('CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at)'); + $this->addSql('CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at)'); + $this->addSql('CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at)'); + $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id))'); + + } elseif ($this->platform instanceof SqlitePlatform) { + $this->addSql(<<<'SQL' +CREATE TABLE ibexa_messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) +, available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) +, delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) +) +SQL); + $this->addSql('CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at)'); + $this->addSql('CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at)'); + $this->addSql('CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at)'); + $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id))'); - if ($this->isMySQL()) { - $this->addSqlFile(__DIR__ . '/sql/install-schema-mysql.sql'); - } elseif ($this->isPostgreSQL()) { - $this->addSqlFile(__DIR__ . '/sql/install-schema-postgresql.sql'); - } elseif ($this->isSqlite()) { - $this->addSqlFile(__DIR__ . '/sql/install-schema-sqlite.sql'); } } } From 271da841994c5baa5f08b823d17bfe1605a848b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 20 Jul 2026 17:00:09 +0200 Subject: [PATCH 02/10] Fix CI: add ibexa/doctrine-migrations dependency, remove extra blank lines composer.json was missing ibexa/doctrine-migrations (require + matching VCS repository entry for its unreleased dev branch), causing "Class Doctrine\Migrations\AbstractMigration not found" across static analysis, unit tests, and browser tests - mirrors ibexa/core's own composer.json pattern exactly (same dev-branch constraint per major version). Also removes extra blank lines the generator scripts introduced (before each } elseif and the up() method's closing brace) that php-cs-fixer's no_extra_blank_lines rule flagged. --- composer.json | 2 +- src/bundle/Migration/InstallSchemaMigration.php | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index f42a36b..0950dfb 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "symfony/lock": "^7.4", "symfony/messenger": "^7.4", "symfony/yaml": "^7.4", - "ibexa/doctrine-migrations": "dev-feat/doctrine-migrations-5.0" + "ibexa/doctrine-migrations": "dev-feat/doctrine-migrations-6.0" }, "require-dev": { "dama/doctrine-test-bundle": "^8", diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php index a07b3b8..a9c9c90 100644 --- a/src/bundle/Migration/InstallSchemaMigration.php +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -38,7 +38,6 @@ public function up(Schema $schema): void if ($this->platform instanceof AbstractMySQLPlatform) { $this->addSql('CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); - } elseif ($this->platform instanceof PostgreSQLPlatform) { $this->addSql('CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at)'); @@ -48,7 +47,6 @@ public function up(Schema $schema): void $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id))'); - } elseif ($this->platform instanceof SqlitePlatform) { $this->addSql(<<<'SQL' CREATE TABLE ibexa_messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) @@ -60,7 +58,6 @@ public function up(Schema $schema): void $this->addSql('CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at)'); $this->addSql('CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at)'); $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id))'); - } } } From a29cccb850dd225a819e902fd05ea1576ec2ee68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Tue, 21 Jul 2026 17:11:57 +0200 Subject: [PATCH 03/10] IBX-11939: Adopted AbstractSqlMigration for platform-separated SQL Extends AbstractSqlMigration (added in ibexa/doctrine-migrations) instead of the plain Doctrine AbstractMigration, replacing `$this->platform instanceof ...` checks with isMySQL()/isPostgreSQL()/isSqlite(), and moving each platform Statement block out of the PHP file into its own sql/*.sql file loaded via addSqlFile(). Mechanical, content-preserving change: every migration was run before and after against all three platforms and the resulting SQL statement lists are byte-for-byte identical. --- .../Migration/InstallSchemaMigration.php | 36 +++++-------------- .../Migration/sql/install-schema-mysql.sql | 4 +-- .../sql/install-schema-postgresql.sql | 16 ++++----- .../Migration/sql/install-schema-sqlite.sql | 10 +++--- 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php index a9c9c90..cfa914e 100644 --- a/src/bundle/Migration/InstallSchemaMigration.php +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -9,14 +9,11 @@ namespace Ibexa\Bundle\Messenger\Migration; use DateTimeImmutable; -use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Schema; -use Doctrine\Migrations\AbstractMigration; +use Ibexa\Contracts\DoctrineMigrations\Migrations\AbstractSqlMigration; use Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationInterface; -final class InstallSchemaMigration extends AbstractMigration implements IbexaMigrationInterface +final class InstallSchemaMigration extends AbstractSqlMigration implements IbexaMigrationInterface { public function getDescription(): string { @@ -35,29 +32,12 @@ public static function getCreationDate(): DateTimeImmutable public function up(Schema $schema): void { - if ($this->platform instanceof AbstractMySQLPlatform) { - $this->addSql('CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); - } elseif ($this->platform instanceof PostgreSQLPlatform) { - $this->addSql('CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at)'); - $this->addSql('CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at)'); - $this->addSql('CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at)'); - $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\''); - $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\''); - $this->addSql('COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\''); - $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id))'); - } elseif ($this->platform instanceof SqlitePlatform) { - $this->addSql(<<<'SQL' -CREATE TABLE ibexa_messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) -, available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) -, delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) -) -SQL); - $this->addSql('CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at)'); - $this->addSql('CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at)'); - $this->addSql('CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at)'); - $this->addSql('CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id))'); + if ($this->isMySQL()) { + $this->addSqlFile(__DIR__ . '/sql/install-schema-mysql.sql'); + } elseif ($this->isPostgreSQL()) { + $this->addSqlFile(__DIR__ . '/sql/install-schema-postgresql.sql'); + } elseif ($this->isSqlite()) { + $this->addSqlFile(__DIR__ . '/sql/install-schema-sqlite.sql'); } } } diff --git a/src/bundle/Migration/sql/install-schema-mysql.sql b/src/bundle/Migration/sql/install-schema-mysql.sql index 6111790..190bd95 100644 --- a/src/bundle/Migration/sql/install-schema-mysql.sql +++ b/src/bundle/Migration/sql/install-schema-mysql.sql @@ -1,3 +1,3 @@ -CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', available_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', delivered_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; +CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', available_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', delivered_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB -- ibexa:sql-statement-separator -CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; +CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB diff --git a/src/bundle/Migration/sql/install-schema-postgresql.sql b/src/bundle/Migration/sql/install-schema-postgresql.sql index cfe4d95..5f8155a 100644 --- a/src/bundle/Migration/sql/install-schema-postgresql.sql +++ b/src/bundle/Migration/sql/install-schema-postgresql.sql @@ -1,15 +1,15 @@ -CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id)); +CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id)) -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at); +CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at) -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at); +CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at) -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at); +CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at) -- ibexa:sql-statement-separator -COMMENT ON COLUMN ibexa_messenger_messages.created_at IS '(DC2Type:datetime_immutable)'; +COMMENT ON COLUMN ibexa_messenger_messages.created_at IS '(DC2Type:datetime_immutable)' -- ibexa:sql-statement-separator -COMMENT ON COLUMN ibexa_messenger_messages.available_at IS '(DC2Type:datetime_immutable)'; +COMMENT ON COLUMN ibexa_messenger_messages.available_at IS '(DC2Type:datetime_immutable)' -- ibexa:sql-statement-separator -COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS '(DC2Type:datetime_immutable)'; +COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS '(DC2Type:datetime_immutable)' -- ibexa:sql-statement-separator -CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id)); +CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id)) diff --git a/src/bundle/Migration/sql/install-schema-sqlite.sql b/src/bundle/Migration/sql/install-schema-sqlite.sql index 7251ba8..2e98f38 100644 --- a/src/bundle/Migration/sql/install-schema-sqlite.sql +++ b/src/bundle/Migration/sql/install-schema-sqlite.sql @@ -1,12 +1,12 @@ CREATE TABLE ibexa_messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) , available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) -); +) -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at); +CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at) -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at); +CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at) -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at); +CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at) -- ibexa:sql-statement-separator -CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id)); +CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id)) From 3bee1054c995b8ba6b7508f1aaca4ccda8ce263b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 22 Jul 2026 11:14:20 +0200 Subject: [PATCH 04/10] IBX-11939: Aborted migration on unsupported database platform Call abortIfUnsupportedPlatform() as the first statement of up(), so installs on a database this migration doesn't build SQL for fail loudly instead of silently queuing zero statements. --- src/bundle/Migration/InstallSchemaMigration.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php index cfa914e..ca4c074 100644 --- a/src/bundle/Migration/InstallSchemaMigration.php +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\Schema; use Ibexa\Contracts\DoctrineMigrations\Migrations\AbstractSqlMigration; use Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationInterface; +use Ibexa\DoctrineMigrations\Migration\SqlPlatform; final class InstallSchemaMigration extends AbstractSqlMigration implements IbexaMigrationInterface { @@ -32,6 +33,8 @@ public static function getCreationDate(): DateTimeImmutable public function up(Schema $schema): void { + $this->abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE); + if ($this->isMySQL()) { $this->addSqlFile(__DIR__ . '/sql/install-schema-mysql.sql'); } elseif ($this->isPostgreSQL()) { From 6f1e1518784b50128f25ef2df668d9532a0f30e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 22 Jul 2026 12:11:12 +0200 Subject: [PATCH 05/10] IBX-11939: Added trailing semicolons to migration SQL files Each statement now ends with `;`, matching ibexa:doctrine:schema:dump-sql's own convention, so the files are directly executable via mysql/psql/sqlite3 CLI clients. addSqlFile() still splits on the delimiter and passes one statement per addSql() call, unaffected by the trailing terminator. --- .../Migration/sql/install-schema-mysql.sql | 4 ++-- .../Migration/sql/install-schema-postgresql.sql | 16 ++++++++-------- .../Migration/sql/install-schema-sqlite.sql | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bundle/Migration/sql/install-schema-mysql.sql b/src/bundle/Migration/sql/install-schema-mysql.sql index 190bd95..6111790 100644 --- a/src/bundle/Migration/sql/install-schema-mysql.sql +++ b/src/bundle/Migration/sql/install-schema-mysql.sql @@ -1,3 +1,3 @@ -CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', available_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', delivered_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB +CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', available_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', delivered_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; -- ibexa:sql-statement-separator -CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB +CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; diff --git a/src/bundle/Migration/sql/install-schema-postgresql.sql b/src/bundle/Migration/sql/install-schema-postgresql.sql index 5f8155a..cfe4d95 100644 --- a/src/bundle/Migration/sql/install-schema-postgresql.sql +++ b/src/bundle/Migration/sql/install-schema-postgresql.sql @@ -1,15 +1,15 @@ -CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id)) +CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id)); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at) +CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at) +CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at) +CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at); -- ibexa:sql-statement-separator -COMMENT ON COLUMN ibexa_messenger_messages.created_at IS '(DC2Type:datetime_immutable)' +COMMENT ON COLUMN ibexa_messenger_messages.created_at IS '(DC2Type:datetime_immutable)'; -- ibexa:sql-statement-separator -COMMENT ON COLUMN ibexa_messenger_messages.available_at IS '(DC2Type:datetime_immutable)' +COMMENT ON COLUMN ibexa_messenger_messages.available_at IS '(DC2Type:datetime_immutable)'; -- ibexa:sql-statement-separator -COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS '(DC2Type:datetime_immutable)' +COMMENT ON COLUMN ibexa_messenger_messages.delivered_at IS '(DC2Type:datetime_immutable)'; -- ibexa:sql-statement-separator -CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id)) +CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT NOT NULL, PRIMARY KEY(key_id)); diff --git a/src/bundle/Migration/sql/install-schema-sqlite.sql b/src/bundle/Migration/sql/install-schema-sqlite.sql index 2e98f38..7251ba8 100644 --- a/src/bundle/Migration/sql/install-schema-sqlite.sql +++ b/src/bundle/Migration/sql/install-schema-sqlite.sql @@ -1,12 +1,12 @@ CREATE TABLE ibexa_messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) , available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) -) +); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at) +CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at) +CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at) +CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at); -- ibexa:sql-statement-separator -CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id)) +CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id)); From 2a6f5c8dccc1e39766dd710d300a7cb6abc93f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 23 Jul 2026 16:49:32 +0200 Subject: [PATCH 06/10] IBX-11939: Added schema-presence guards to skip already-applied migrations Checks $schema (already the live, introspected database) before running, and skipIf()s when the tables/columns/FK targets this migration would create already exist -- so installs that built their schema the old way (SchemaBuilderEvent) can adopt Doctrine Migrations without every migration aborting or duplicating existing schema objects. --- src/bundle/Migration/InstallSchemaMigration.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php index ca4c074..ac5ecd8 100644 --- a/src/bundle/Migration/InstallSchemaMigration.php +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -35,6 +35,12 @@ public function up(Schema $schema): void { $this->abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE); + $this->skipIf( + $schema->hasTable('ibexa_messenger_messages') + && $schema->hasTable('ibexa_messenger_lock_keys'), + 'Schema already migrated: tables already exist.' + ); + if ($this->isMySQL()) { $this->addSqlFile(__DIR__ . '/sql/install-schema-mysql.sql'); } elseif ($this->isPostgreSQL()) { From 6e21fedc9a54c06ff7d6d1d84526b7c3e133579b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 23 Jul 2026 18:36:52 +0200 Subject: [PATCH 07/10] IBX-11939: Recorded schema-guarded migrations as applied, not skipped Doctrine Migrations only calls MetadataStorage::complete() (the write to doctrine_migration_versions) when a migration's up() returns normally -- never when it throws SkipMigration. So every migration using skipIf() was being silently re-evaluated on every future doctrine:migrations:migrate run instead of being permanently recorded as applied, even though its guard condition (the schema already being in place) never changes back. Replaces every `$this->skipIf($condition, $message);` with `if ($condition) { return; }`: up() now returns normally with zero queued SQL when the guard fires, so the migration is correctly recorded as executed (with a "did not result in any SQL statements" warning logged, which is expected and harmless) and never re-evaluated again. Verified end-to-end: fresh ibexa:install (schema_builder_event enabled) followed by doctrine:migrations:migrate now records all 44 tagged migrations in doctrine_migration_versions in one pass, and a second migrate run does zero work at all ("Already at the latest version"). --- src/bundle/Migration/InstallSchemaMigration.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php index ac5ecd8..c7bb502 100644 --- a/src/bundle/Migration/InstallSchemaMigration.php +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -35,11 +35,10 @@ public function up(Schema $schema): void { $this->abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE); - $this->skipIf( - $schema->hasTable('ibexa_messenger_messages') - && $schema->hasTable('ibexa_messenger_lock_keys'), - 'Schema already migrated: tables already exist.' - ); + if ($schema->hasTable('ibexa_messenger_messages') + && $schema->hasTable('ibexa_messenger_lock_keys')) { + return; + } if ($this->isMySQL()) { $this->addSqlFile(__DIR__ . '/sql/install-schema-mysql.sql'); From f11d537185f75eed971706939c5acd5ae0e644c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 Jul 2026 17:22:00 +0200 Subject: [PATCH 08/10] IBX-11939: Removed ibexa/doctrine-migrations VCS repository entry ibexa/doctrine-migrations is now published on Packagist (which mirrors all of its branches, not just tags), so the explicit VCS repository pointing composer directly at GitHub is no longer needed to resolve the dev-branch require constraint. --- composer.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/composer.json b/composer.json index 0950dfb..f1e7245 100644 --- a/composer.json +++ b/composer.json @@ -5,12 +5,6 @@ "keywords": [ "ibexa-dxp" ], - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/ibexa/doctrine-migrations.git" - } - ], "require": { "php": ">=8.3", "ibexa/core": "~6.0.x-dev", From e4202493886c8d6fbdf98d62a6a49b9f02c81e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 Jul 2026 17:47:47 +0200 Subject: [PATCH 09/10] IBX-11939: Corrected ibexa_messenger_messages index declaration in schema.yaml Propagated from feature/schema-migration-5.0. schema.yaml declared 3 separate, explicitly-named single-column indexes, but this table is Symfony's own Doctrine Messenger transport table - its real shape (as created by symfony/doctrine-messenger's own Connection::buildSchemaTable()) is ONE composite index over (queue_name, available_at, delivered_at, id). Replaced the 3-index declaration with a single named index matching that exact column set and order. Verified via ibexa:doctrine:schema:dump-sql. --- src/bundle/Resources/config/schema.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bundle/Resources/config/schema.yaml b/src/bundle/Resources/config/schema.yaml index 32f3ef0..b3fab04 100644 --- a/src/bundle/Resources/config/schema.yaml +++ b/src/bundle/Resources/config/schema.yaml @@ -1,5 +1,7 @@ tables: ibexa_messenger_messages: + indexes: + ibexa_messenger_messages_queue_available_delivered_idx: { fields: [ queue_name, available_at, delivered_at, id ] } id: id: type: bigint @@ -20,18 +22,12 @@ tables: created_at: type: datetime_immutable nullable: false - index: - name: ibexa_messenger_created_at_idx available_at: type: datetime_immutable nullable: false - index: - name: ibexa_messenger_available_at_idx delivered_at: type: datetime_immutable nullable: true - index: - name: ibexa_messenger_delivered_at_idx ibexa_messenger_lock_keys: id: From f52c2468b407d68f914180fc31c8d1789d065352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 Jul 2026 17:47:48 +0200 Subject: [PATCH 10/10] IBX-11939: Added migration to fix already-installed ibexa_messenger_messages indexes Propagated from feature/schema-migration-5.0. Correcting schema.yaml alone only fixes NEW installs going through the legacy SchemaBuilderEvent path - it does nothing for installs that already ran the old InstallSchemaMigration (guarded against re-running once the table exists) or an old legacy install that already created the wrong 3-index shape. - InstallSchemaMigration's own baseline SQL files (all 3 platforms) now create the correct single composite index directly. - New FixMessengerMessagesIndexesMigration (tagged 5.0.0, dated after the baseline) drops the 3 incorrect indexes and creates the correct composite one, guarded to skip if the correct index is already present. Verified against a real SQLite connection: a table seeded with the old wrong shape produces exactly 4 statements (3 drops + 1 create) and becomes correct. --- .../FixMessengerMessagesIndexesMigration.php | 63 +++++++++++++++++++ .../fix-messenger-messages-indexes-mysql.sql | 7 +++ ...-messenger-messages-indexes-postgresql.sql | 7 +++ .../fix-messenger-messages-indexes-sqlite.sql | 7 +++ .../Migration/sql/install-schema-mysql.sql | 2 +- .../sql/install-schema-postgresql.sql | 6 +- .../Migration/sql/install-schema-sqlite.sql | 6 +- .../config/services/doctrine_migrations.yaml | 9 +++ 8 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 src/bundle/Migration/FixMessengerMessagesIndexesMigration.php create mode 100644 src/bundle/Migration/sql/fix-messenger-messages-indexes-mysql.sql create mode 100644 src/bundle/Migration/sql/fix-messenger-messages-indexes-postgresql.sql create mode 100644 src/bundle/Migration/sql/fix-messenger-messages-indexes-sqlite.sql diff --git a/src/bundle/Migration/FixMessengerMessagesIndexesMigration.php b/src/bundle/Migration/FixMessengerMessagesIndexesMigration.php new file mode 100644 index 0000000..106dcf4 --- /dev/null +++ b/src/bundle/Migration/FixMessengerMessagesIndexesMigration.php @@ -0,0 +1,63 @@ +abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE); + + if ($schema->getTable('ibexa_messenger_messages')->hasIndex('ibexa_messenger_messages_queue_available_delivered_idx')) { + return; + } + + if ($this->isMySQL()) { + $this->addSqlFile(__DIR__ . '/sql/fix-messenger-messages-indexes-mysql.sql'); + } elseif ($this->isPostgreSQL()) { + $this->addSqlFile(__DIR__ . '/sql/fix-messenger-messages-indexes-postgresql.sql'); + } elseif ($this->isSqlite()) { + $this->addSqlFile(__DIR__ . '/sql/fix-messenger-messages-indexes-sqlite.sql'); + } + } +} diff --git a/src/bundle/Migration/sql/fix-messenger-messages-indexes-mysql.sql b/src/bundle/Migration/sql/fix-messenger-messages-indexes-mysql.sql new file mode 100644 index 0000000..4307e53 --- /dev/null +++ b/src/bundle/Migration/sql/fix-messenger-messages-indexes-mysql.sql @@ -0,0 +1,7 @@ +DROP INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages; +-- ibexa:sql-statement-separator +DROP INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages; +-- ibexa:sql-statement-separator +DROP INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages; +-- ibexa:sql-statement-separator +CREATE INDEX ibexa_messenger_messages_queue_available_delivered_idx ON ibexa_messenger_messages (queue_name, available_at, delivered_at, id); diff --git a/src/bundle/Migration/sql/fix-messenger-messages-indexes-postgresql.sql b/src/bundle/Migration/sql/fix-messenger-messages-indexes-postgresql.sql new file mode 100644 index 0000000..35db770 --- /dev/null +++ b/src/bundle/Migration/sql/fix-messenger-messages-indexes-postgresql.sql @@ -0,0 +1,7 @@ +DROP INDEX ibexa_messenger_created_at_idx; +-- ibexa:sql-statement-separator +DROP INDEX ibexa_messenger_available_at_idx; +-- ibexa:sql-statement-separator +DROP INDEX ibexa_messenger_delivered_at_idx; +-- ibexa:sql-statement-separator +CREATE INDEX ibexa_messenger_messages_queue_available_delivered_idx ON ibexa_messenger_messages (queue_name, available_at, delivered_at, id); diff --git a/src/bundle/Migration/sql/fix-messenger-messages-indexes-sqlite.sql b/src/bundle/Migration/sql/fix-messenger-messages-indexes-sqlite.sql new file mode 100644 index 0000000..35db770 --- /dev/null +++ b/src/bundle/Migration/sql/fix-messenger-messages-indexes-sqlite.sql @@ -0,0 +1,7 @@ +DROP INDEX ibexa_messenger_created_at_idx; +-- ibexa:sql-statement-separator +DROP INDEX ibexa_messenger_available_at_idx; +-- ibexa:sql-statement-separator +DROP INDEX ibexa_messenger_delivered_at_idx; +-- ibexa:sql-statement-separator +CREATE INDEX ibexa_messenger_messages_queue_available_delivered_idx ON ibexa_messenger_messages (queue_name, available_at, delivered_at, id); diff --git a/src/bundle/Migration/sql/install-schema-mysql.sql b/src/bundle/Migration/sql/install-schema-mysql.sql index 6111790..047af5b 100644 --- a/src/bundle/Migration/sql/install-schema-mysql.sql +++ b/src/bundle/Migration/sql/install-schema-mysql.sql @@ -1,3 +1,3 @@ -CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', available_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', delivered_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX ibexa_messenger_created_at_idx (created_at), INDEX ibexa_messenger_available_at_idx (available_at), INDEX ibexa_messenger_delivered_at_idx (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; +CREATE TABLE ibexa_messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', available_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', delivered_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX ibexa_messenger_messages_queue_available_delivered_idx (queue_name, available_at, delivered_at, id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; -- ibexa:sql-statement-separator CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INT UNSIGNED NOT NULL, PRIMARY KEY(key_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB; diff --git a/src/bundle/Migration/sql/install-schema-postgresql.sql b/src/bundle/Migration/sql/install-schema-postgresql.sql index cfe4d95..319804d 100644 --- a/src/bundle/Migration/sql/install-schema-postgresql.sql +++ b/src/bundle/Migration/sql/install-schema-postgresql.sql @@ -1,10 +1,6 @@ CREATE TABLE ibexa_messenger_messages (id BIGSERIAL NOT NULL, 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, PRIMARY KEY(id)); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at); --- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at); --- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at); +CREATE INDEX ibexa_messenger_messages_queue_available_delivered_idx ON ibexa_messenger_messages (queue_name, available_at, delivered_at, id); -- ibexa:sql-statement-separator COMMENT ON COLUMN ibexa_messenger_messages.created_at IS '(DC2Type:datetime_immutable)'; -- ibexa:sql-statement-separator diff --git a/src/bundle/Migration/sql/install-schema-sqlite.sql b/src/bundle/Migration/sql/install-schema-sqlite.sql index 7251ba8..ff6bbf6 100644 --- a/src/bundle/Migration/sql/install-schema-sqlite.sql +++ b/src/bundle/Migration/sql/install-schema-sqlite.sql @@ -3,10 +3,6 @@ CREATE TABLE ibexa_messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) ); -- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_created_at_idx ON ibexa_messenger_messages (created_at); --- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_available_at_idx ON ibexa_messenger_messages (available_at); --- ibexa:sql-statement-separator -CREATE INDEX ibexa_messenger_delivered_at_idx ON ibexa_messenger_messages (delivered_at); +CREATE INDEX ibexa_messenger_messages_queue_available_delivered_idx ON ibexa_messenger_messages (queue_name, available_at, delivered_at, id); -- ibexa:sql-statement-separator CREATE TABLE ibexa_messenger_lock_keys (key_id VARCHAR(64) NOT NULL, key_token VARCHAR(44) NOT NULL, key_expiration INTEGER UNSIGNED NOT NULL, PRIMARY KEY(key_id)); diff --git a/src/bundle/Resources/config/services/doctrine_migrations.yaml b/src/bundle/Resources/config/services/doctrine_migrations.yaml index c3d21c9..5be8ba0 100644 --- a/src/bundle/Resources/config/services/doctrine_migrations.yaml +++ b/src/bundle/Resources/config/services/doctrine_migrations.yaml @@ -6,3 +6,12 @@ services: $connection: '@ibexa.persistence.connection' tags: - { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG } + + Ibexa\Bundle\Messenger\Migration\FixMessengerMessagesIndexesMigration: + autowire: true + autoconfigure: false + public: false + arguments: + $connection: '@ibexa.persistence.connection' + tags: + - { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG }