Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/bundle/Core/Resources/config/doctrine_migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,26 @@ services:
tags:
- { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG }

Ibexa\Bundle\RepositoryInstaller\Migration\RenameSchemaTo5_0Migration:
autowire: true
public: false
arguments:
$connection: '@ibexa.persistence.connection'
tags:
- { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG }

Ibexa\Bundle\RepositoryInstaller\Migration\ImportDataMigration:
autowire: true
public: false
arguments:
$connection: '@ibexa.persistence.connection'
tags:
- { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG }

Ibexa\Bundle\RepositoryInstaller\Migration\FixLegacyIdentifiersMigration:
autowire: true
public: false
arguments:
$connection: '@ibexa.persistence.connection'
tags:
- { name: !php/const Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationTag::TAG }
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\RepositoryInstaller\Migration;

use DateTimeImmutable;
use Doctrine\DBAL\Schema\Schema;
use Ibexa\Contracts\DoctrineMigrations\Migrations\AbstractSqlMigration;
use Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationInterface;
use Ibexa\DoctrineMigrations\Migration\SqlPlatform;

/**
* Fixes 3 stale legacy identifier values ("ez_lock"/"ezstring") left over from before the
* 5.0 renames, on the tables RenameSchemaTo5_0Migration renames them onto. Split out of that
* migration (rather than guarded by its schema-presence check) because this is a data fix,
* not a schema change: an install that built its schema via schema.yaml directly already has
* the renamed tables (so RenameSchemaTo5_0Migration skips), but its actual row data may still
* hold the old identifier strings, since schema.yaml only defines structure, not content.
* Runs unconditionally -- each UPDATE is a no-op via its own WHERE clause once already fixed,
* and by running strictly after RenameSchemaTo5_0Migration (same target version, later
* creation date), the tables it touches are always at their final names by the time this
* runs, whether the rename happened moments earlier in this same run or already existed.
*/
final class FixLegacyIdentifiersMigration extends AbstractSqlMigration implements IbexaMigrationInterface
{
public function getDescription(): string
{
return 'Fixes stale "ez_lock"/"ezstring" legacy identifier values left over from the 5.0 renames';
}

public static function getTargetVersion(): string
{
return '5.0.0';
}

public static function getCreationDate(): DateTimeImmutable
{
return new DateTimeImmutable('2026-07-20 00:00:01');
}

public function up(Schema $schema): void
{
$this->abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE);

if ($this->isMySQL()) {
$this->addSqlFile(__DIR__ . '/sql/fix-legacy-identifiers-mysql.sql');
} elseif ($this->isPostgreSQL()) {
$this->addSqlFile(__DIR__ . '/sql/fix-legacy-identifiers-postgresql.sql');
} elseif ($this->isSqlite()) {
$this->addSqlFile(__DIR__ . '/sql/fix-legacy-identifiers-sqlite.sql');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function up(Schema $schema): void
// migration creates): an install that built its schema via schema.yaml (rather than
// through this migration) never has "ezcontentobject" -- it already has
// "ibexa_content" directly.
if ($schema->hasTable('ezcontentobject')) {
if ($schema->hasTable('ibexa_content')) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\RepositoryInstaller\Migration;

use DateTimeImmutable;
use Doctrine\DBAL\Schema\Schema;
use Ibexa\Contracts\DoctrineMigrations\Migrations\AbstractSqlMigration;
use Ibexa\Contracts\DoctrineMigrations\Migrations\IbexaMigrationInterface;
use Ibexa\DoctrineMigrations\Migration\SqlPlatform;

/**
* Renames the legacy eZ Publish-style core database schema (ez*) to the Ibexa naming
* scheme (ibexa_*) introduced in 5.0. This is the incremental diff on top of
* InstallSchemaMigration's 4.6.0 baseline; a fresh 6.0 install runs both in sequence,
* while an existing 4.6 install only needs this one to reach the 5.0/6.0 shape.
*/
final class RenameSchemaTo5_0Migration extends AbstractSqlMigration implements IbexaMigrationInterface

Check warning on line 23 in src/bundle/RepositoryInstaller/Migration/RenameSchemaTo5_0Migration.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename class "RenameSchemaTo5_0Migration" to match the regular expression ^[A-Z][a-zA-Z0-9]*$.

See more on https://sonarcloud.io/project/issues?id=ibexa_core&issues=AZ-T9EMUb32_ZYe1s9Vj&open=AZ-T9EMUb32_ZYe1s9Vj&pullRequest=787
{
public function getDescription(): string
{
return 'Renames the legacy core database schema to the Ibexa naming scheme (introduced in 5.0)';
}

public static function getTargetVersion(): string
{
return '5.0.0';
}

public static function getCreationDate(): DateTimeImmutable
{
return new DateTimeImmutable('2026-07-20 00:00:00');
}

public function up(Schema $schema): void
{
$this->abortIfUnsupportedPlatform(SqlPlatform::MYSQL, SqlPlatform::POSTGRESQL, SqlPlatform::SQLITE);

if ($schema->hasTable('ibexa_content')) {
return;
}

if ($this->isMySQL()) {
$this->addSqlFile(__DIR__ . '/sql/rename-schema-to-5-0-mysql.sql');
} elseif ($this->isPostgreSQL()) {
$this->addSqlFile(__DIR__ . '/sql/rename-schema-to-5-0-postgresql.sql');
} elseif ($this->isSqlite()) {
$this->addSqlFile(__DIR__ . '/sql/rename-schema-to-5-0-sqlite.sql');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
*/
final class SchemaBuilderEventSchemaProvider implements SchemaProvider
{
private SchemaBuilderInterface $schemaBuilder;

public function __construct(SchemaBuilderInterface $schemaBuilder)
public function __construct(private readonly SchemaBuilderInterface $schemaBuilder)
{
$this->schemaBuilder = $schemaBuilder;
}

public function createSchema(): Schema
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
UPDATE ibexa_object_state_group SET identifier = 'ibexa_lock' WHERE identifier = 'ez_lock';
-- ibexa:sql-statement-separator
UPDATE ibexa_content_type_field_definition SET data_type_string = 'ibexa_string' WHERE data_type_string = 'ezstring';
-- ibexa:sql-statement-separator
UPDATE ibexa_content_field SET data_type_string = 'ibexa_string' WHERE data_type_string = 'ezstring';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
UPDATE ibexa_object_state_group SET identifier = 'ibexa_lock' WHERE identifier = 'ez_lock';
-- ibexa:sql-statement-separator
UPDATE ibexa_content_type_field_definition SET data_type_string = 'ibexa_string' WHERE data_type_string = 'ezstring';
-- ibexa:sql-statement-separator
UPDATE ibexa_content_field SET data_type_string = 'ibexa_string' WHERE data_type_string = 'ezstring';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
UPDATE ibexa_object_state_group SET identifier = 'ibexa_lock' WHERE identifier = 'ez_lock';
-- ibexa:sql-statement-separator
UPDATE ibexa_content_type_field_definition SET data_type_string = 'ibexa_string' WHERE data_type_string = 'ezstring';
-- ibexa:sql-statement-separator
UPDATE ibexa_content_field SET data_type_string = 'ibexa_string' WHERE data_type_string = 'ezstring';
Loading
Loading