From 0cae097b3b46e7682aec8c89b6b691090a7c30cb 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 | 66 +++++++++++++++++++ .../config/services/doctrine_migrations.yaml | 8 +++ 2 files changed, 74 insertions(+) create mode 100644 src/bundle/Migration/InstallSchemaMigration.php create mode 100644 src/bundle/Resources/config/services/doctrine_migrations.yaml diff --git a/src/bundle/Migration/InstallSchemaMigration.php b/src/bundle/Migration/InstallSchemaMigration.php new file mode 100644 index 0000000..a07b3b8 --- /dev/null +++ b/src/bundle/Migration/InstallSchemaMigration.php @@ -0,0 +1,66 @@ +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))'); + + } + } +} diff --git a/src/bundle/Resources/config/services/doctrine_migrations.yaml b/src/bundle/Resources/config/services/doctrine_migrations.yaml new file mode 100644 index 0000000..c3d21c9 --- /dev/null +++ b/src/bundle/Resources/config/services/doctrine_migrations.yaml @@ -0,0 +1,8 @@ +services: + Ibexa\Bundle\Messenger\Migration\InstallSchemaMigration: + autowire: true + public: false + arguments: + $connection: '@ibexa.persistence.connection' + tags: + - { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG } From 128b3177a164dcdd9f6f9444fd695b0bcd14dd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 20 Jul 2026 17:00:08 +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 | 9 ++++++++- src/bundle/Migration/InstallSchemaMigration.php | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 327c4fd..b7d97a8 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,12 @@ "keywords": [ "ibexa-dxp" ], + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/ibexa/doctrine-migrations.git" + } + ], "require": { "php": ">=8.3", "ibexa/core": "~5.0.x-dev", @@ -16,7 +22,8 @@ "symfony/http-foundation": "^7.4", "symfony/http-kernel": "^7.4", "symfony/messenger": "^7.4", - "symfony/yaml": "^7.4" + "symfony/yaml": "^7.4", + "ibexa/doctrine-migrations": "dev-feat/doctrine-migrations-5.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 0d7309071ffa27c5696d517360d886f090e018e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Tue, 21 Jul 2026 17:12:17 +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 | 3 ++ .../sql/install-schema-postgresql.sql | 15 ++++++++ .../Migration/sql/install-schema-sqlite.sql | 12 +++++++ 4 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 src/bundle/Migration/sql/install-schema-mysql.sql create mode 100644 src/bundle/Migration/sql/install-schema-postgresql.sql create mode 100644 src/bundle/Migration/sql/install-schema-sqlite.sql 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 new file mode 100644 index 0000000..190bd95 --- /dev/null +++ b/src/bundle/Migration/sql/install-schema-mysql.sql @@ -0,0 +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 +-- 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 new file mode 100644 index 0000000..5f8155a --- /dev/null +++ b/src/bundle/Migration/sql/install-schema-postgresql.sql @@ -0,0 +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)) +-- 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) +-- ibexa:sql-statement-separator +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)' +-- ibexa:sql-statement-separator +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)) diff --git a/src/bundle/Migration/sql/install-schema-sqlite.sql b/src/bundle/Migration/sql/install-schema-sqlite.sql new file mode 100644 index 0000000..2e98f38 --- /dev/null +++ b/src/bundle/Migration/sql/install-schema-sqlite.sql @@ -0,0 +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) +-- 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) +-- 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)) From 62f6a2c7d79f47da3bac10d21d349cfb06e4685b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 22 Jul 2026 11:13:58 +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 3d25eea13b17fc8e6052c9c1ca913fae8528d4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 22 Jul 2026 12:10:51 +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 76838f3fb0ef9299ca62448aa98be01a48694457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 23 Jul 2026 16:49:12 +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 ca5d33c0c50c189e160892dbe6afc31604d41558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 23 Jul 2026 18:36:32 +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 69becaed6efe9d6d872edace9bb47c76b5bbf2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 Jul 2026 17:21:56 +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 b7d97a8..510c7ed 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": "~5.0.x-dev", From feffa3ac6e553530e3876c3b914bf4d880fdebd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 Jul 2026 17:46:12 +0200 Subject: [PATCH 09/10] IBX-11939: Corrected ibexa_messenger_messages index declaration in schema.yaml schema.yaml declared 3 separate, explicitly-named single-column indexes (created_at/available_at/delivered_at), 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, so a legacy SchemaBuilderEvent install now produces a schema consistent with what Symfony's own transport expects, instead of a permanently-diverging one. 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 af45428fcb668ece9f7292ba0fb39762106d11b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 Jul 2026 17:46:29 +0200 Subject: [PATCH 10/10] IBX-11939: Added migration to fix already-installed ibexa_messenger_messages indexes Correcting schema.yaml alone (previous commit) 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, so a brand-new Doctrine-Migrations install never creates the wrong shape in the first place. - 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 - so it's a no-op on fresh installs (baseline already got it right) and a real fix on anything installed before this correction (whichever install path it went through). Verified against a real SQLite connection: fresh install produces 0 pending statements from the fix migration; a table seeded with the old wrong shape produces exactly 4 statements (3 drops + 1 create) and becomes correct; re-running the fix migration afterwards is a no-op (idempotent). --- .../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 }