diff --git a/src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php b/src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php index 6878bae0e..5cc64860a 100644 --- a/src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php +++ b/src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php @@ -34,11 +34,11 @@ class Migration1754897550AddFieldsToMigrationLogs extends MigrationStep public const OPTIONAL_FIELDS = [ 'entity_name' => 'VARCHAR(64) NULL', + 'entity_id' => 'BINARY(16) NULL', 'field_name' => 'VARCHAR(64) NULL', 'field_source_path' => 'VARCHAR(255) NULL', 'source_data' => 'JSON NULL', 'converted_data' => 'JSON NULL', - 'used_mapping' => 'JSON NULL', 'exception_message' => 'VARCHAR(255) NULL', 'exception_trace' => 'JSON NULL', ]; @@ -163,6 +163,16 @@ private function ensureRelations(Connection $connection, AbstractSchemaManager $ ) ); + // ensure entity_id index + if (!$this->indexExists($connection, self::MIGRATION_LOGGING_TABLE, 'idx.entity_id')) { + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` ADD INDEX `idx.entity_id` (`entity_id`);', + self::MIGRATION_LOGGING_TABLE + ) + ); + } + // ensure foreign key constraint $connection->executeStatement( \sprintf( diff --git a/src/Core/Migration/Migration1757598733AddMigrationFixesTable.php b/src/Core/Migration/Migration1757598733AddMigrationFixesTable.php index a0aa18160..8d2b23c5a 100644 --- a/src/Core/Migration/Migration1757598733AddMigrationFixesTable.php +++ b/src/Core/Migration/Migration1757598733AddMigrationFixesTable.php @@ -22,7 +22,6 @@ class Migration1757598733AddMigrationFixesTable extends MigrationStep public const FIELDS = [ 'id' => 'BINARY(16) NOT NULL', 'connection_id' => 'BINARY(16) NOT NULL', - 'main_mapping_id' => 'BINARY(16) NOT NULL', 'value' => 'JSON NOT NULL', 'path' => 'VARCHAR(255) NOT NULL', 'entity_name' => 'VARCHAR(255) NULL', @@ -49,7 +48,7 @@ public function update(Connection $connection): void %s, PRIMARY KEY (`id`), CONSTRAINT `fk.swag_migration_fix.connection_id` FOREIGN KEY (`connection_id`) REFERENCES `swag_migration_connection` (`id`) ON DELETE CASCADE, - CONSTRAINT `fk.swag_migration_fix.main_mapping_id` FOREIGN KEY (`main_mapping_id`) REFERENCES `swag_migration_mapping` (`id`) ON DELETE CASCADE + INDEX `idx.entity_id` (`entity_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ', self::MIGRATION_FIXES_TABLE, implode(', ', $columns)); diff --git a/src/Core/Migration/Migration1761903189AdjustSwagMigrationLoggingTable.php b/src/Core/Migration/Migration1761903189AdjustSwagMigrationLoggingTable.php deleted file mode 100644 index bdf714aff..000000000 --- a/src/Core/Migration/Migration1761903189AdjustSwagMigrationLoggingTable.php +++ /dev/null @@ -1,35 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationAssistant\Core\Migration; - -use Doctrine\DBAL\Connection; -use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\Migration\MigrationStep; - -/** - * @internal - */ -#[Package('fundamentals@after-sales')] -class Migration1761903189AdjustSwagMigrationLoggingTable extends MigrationStep -{ - public function getCreationTimestamp(): int - { - return 1761903189; - } - - public function update(Connection $connection): void - { - $this->dropColumnIfExists($connection, 'swag_migration_logging', 'used_mapping'); - - $this->addColumn($connection, 'swag_migration_logging', 'entity_id', 'BINARY(16)'); - - if (!$this->indexExists($connection, 'swag_migration_logging', 'idx.entity_id')) { - $connection->executeStatement('ALTER TABLE `swag_migration_logging` ADD INDEX `idx.entity_id` (`entity_id`);'); - } - } -} diff --git a/src/Core/Migration/Migration1762177450AddEntityIdAndEntityNameToFixTable.php b/src/Core/Migration/Migration1762177450AddEntityIdAndEntityNameToFixTable.php deleted file mode 100644 index 9bd805b46..000000000 --- a/src/Core/Migration/Migration1762177450AddEntityIdAndEntityNameToFixTable.php +++ /dev/null @@ -1,34 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationAssistant\Core\Migration; - -use Doctrine\DBAL\Connection; -use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\Migration\MigrationStep; - -/** - * @internal - */ -#[Package('fundamentals@after-sales')] -class Migration1762177450AddEntityIdAndEntityNameToFixTable extends MigrationStep -{ - public function getCreationTimestamp(): int - { - return 1762177450; - } - - public function update(Connection $connection): void - { - $this->addColumn($connection, 'swag_migration_fix', 'entity_id', 'BINARY(16)'); - $this->addColumn($connection, 'swag_migration_fix', 'entity_name', 'VARCHAR(255)'); - - if (!$this->indexExists($connection, 'swag_migration_fix', 'idx.entity_id')) { - $connection->executeStatement('ALTER TABLE `swag_migration_fix` ADD INDEX `idx.entity_id` (`entity_id`);'); - } - } -} diff --git a/src/Core/Migration/Migration1762436233RemoveMainMappingIdFromMigrationFix.php b/src/Core/Migration/Migration1762436233RemoveMainMappingIdFromMigrationFix.php deleted file mode 100644 index 2eb485584..000000000 --- a/src/Core/Migration/Migration1762436233RemoveMainMappingIdFromMigrationFix.php +++ /dev/null @@ -1,46 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationAssistant\Core\Migration; - -use Doctrine\DBAL\Connection; -use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\Migration\MigrationStep; - -/** - * @internal - */ -#[Package('fundamentals@after-sales')] -class Migration1762436233RemoveMainMappingIdFromMigrationFix extends MigrationStep -{ - public const TABLE_NAME = 'swag_migration_fix'; - public const COLUMN_NAME = 'main_mapping_id'; - public const FOREIGN_KEY_NAME = 'fk.swag_migration_fix.main_mapping_id'; - - public function getCreationTimestamp(): int - { - return 1762436233; - } - - /** - * @throws \Throwable - */ - public function update(Connection $connection): void - { - $this->dropForeignKeyIfExists( - $connection, - self::TABLE_NAME, - self::FOREIGN_KEY_NAME, - ); - - $this->dropColumnIfExists( - $connection, - self::TABLE_NAME, - self::COLUMN_NAME, - ); - } -} diff --git a/tests/Core/Migration/Migration1761903189AdjustSwagMigrationLoggingTableTest.php b/tests/Core/Migration/Migration1761903189AdjustSwagMigrationLoggingTableTest.php deleted file mode 100644 index a2a7b8d0a..000000000 --- a/tests/Core/Migration/Migration1761903189AdjustSwagMigrationLoggingTableTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Core\Migration; - -use PHPUnit\Framework\TestCase; -use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\Test\TestCaseBase\KernelLifecycleManager; -use Shopware\Core\Framework\Test\TestCaseBase\KernelTestBehaviour; -use SwagMigrationAssistant\Core\Migration\Migration1761903189AdjustSwagMigrationLoggingTable; -use SwagMigrationAssistant\Test\TableHelperTrait; - -/** - * @internal - */ -#[Package('after-sales')] -class Migration1761903189AdjustSwagMigrationLoggingTableTest extends TestCase -{ - use KernelTestBehaviour; - use TableHelperTrait; - - public function testUpdate(): void - { - $connection = KernelLifecycleManager::getConnection(); - - $this->dropIndex($connection, 'swag_migration_logging', 'idx.entity_id'); - static::assertFalse($this->indexExists($connection, 'swag_migration_logging', 'idx.entity_id')); - - $this->dropColumn($connection, 'swag_migration_logging', 'entity_id'); - static::assertFalse($this->columnExists($connection, 'swag_migration_logging', 'entity_id')); - - $this->addColumn($connection, 'swag_migration_logging', 'used_mapping', 'JSON'); - static::assertTrue($this->columnExists($connection, 'swag_migration_logging', 'used_mapping')); - - $migration = new Migration1761903189AdjustSwagMigrationLoggingTable(); - $migration->update($connection); - $migration->update($connection); - - static::assertTrue($this->indexExists($connection, 'swag_migration_logging', 'idx.entity_id')); - static::assertTrue($this->columnExists($connection, 'swag_migration_logging', 'entity_id')); - static::assertFalse($this->columnExists($connection, 'swag_migration_logging', 'used_mapping')); - } -} diff --git a/tests/Core/Migration/Migration1762177450AddEntityIdAndEntityNameToFixTableTest.php b/tests/Core/Migration/Migration1762177450AddEntityIdAndEntityNameToFixTableTest.php deleted file mode 100644 index 5a7def93c..000000000 --- a/tests/Core/Migration/Migration1762177450AddEntityIdAndEntityNameToFixTableTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Core\Migration; - -use PHPUnit\Framework\TestCase; -use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\Test\TestCaseBase\KernelLifecycleManager; -use SwagMigrationAssistant\Core\Migration\Migration1762177450AddEntityIdAndEntityNameToFixTable; -use SwagMigrationAssistant\Test\TableHelperTrait; - -/** - * @internal - */ -#[Package('fundamentals@after-sales')] -class Migration1762177450AddEntityIdAndEntityNameToFixTableTest extends TestCase -{ - use TableHelperTrait; - - public function testUpdate(): void - { - $connection = KernelLifecycleManager::getConnection(); - - $this->dropIndex($connection, 'swag_migration_fix', 'idx.entity_id'); - static::assertFalse($this->indexExists($connection, 'swag_migration_fix', 'idx.entity_id')); - - $this->dropColumn($connection, 'swag_migration_fix', 'entity_id'); - static::assertFalse($this->columnExists($connection, 'swag_migration_fix', 'entity_id')); - - $this->dropColumn($connection, 'swag_migration_fix', 'entity_name'); - static::assertFalse($this->columnExists($connection, 'swag_migration_fix', 'entity_name')); - - $migration = new Migration1762177450AddEntityIdAndEntityNameToFixTable(); - $migration->update($connection); - $migration->update($connection); - - static::assertTrue($this->indexExists($connection, 'swag_migration_fix', 'idx.entity_id')); - static::assertTrue($this->columnExists($connection, 'swag_migration_fix', 'entity_id')); - static::assertTrue($this->columnExists($connection, 'swag_migration_fix', 'entity_name')); - } -} diff --git a/tests/Core/Migration/Migration1762436233RemoveMainMappingIdFromMigrationFixTest.php b/tests/Core/Migration/Migration1762436233RemoveMainMappingIdFromMigrationFixTest.php deleted file mode 100644 index f771f2f6b..000000000 --- a/tests/Core/Migration/Migration1762436233RemoveMainMappingIdFromMigrationFixTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Core\Migration; - -use PHPUnit\Framework\TestCase; -use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\Test\TestCaseBase\KernelLifecycleManager; -use SwagMigrationAssistant\Core\Migration\Migration1762436233RemoveMainMappingIdFromMigrationFix; -use SwagMigrationAssistant\Test\TableHelperTrait; - -/** - * @internal - */ -#[Package('fundamentals@after-sales')] -class Migration1762436233RemoveMainMappingIdFromMigrationFixTest extends TestCase -{ - use TableHelperTrait; - - public function testUpdate(): void - { - $connection = KernelLifecycleManager::getConnection(); - - $tableName = Migration1762436233RemoveMainMappingIdFromMigrationFix::TABLE_NAME; - $columnName = Migration1762436233RemoveMainMappingIdFromMigrationFix::COLUMN_NAME; - $foreignKeyName = Migration1762436233RemoveMainMappingIdFromMigrationFix::FOREIGN_KEY_NAME; - - if (!$this->columnExists($connection, $tableName, $columnName)) { - $this->addColumn( - $connection, - $tableName, - $columnName, - 'BINARY(16)', - ); - - $this->addForeignKey( - $connection, - $tableName, - $foreignKeyName, - $columnName, - 'swag_migration_mapping', - 'id', - ); - } - - static::assertTrue($this->columnExists($connection, $tableName, $columnName)); - - $migration = new Migration1762436233RemoveMainMappingIdFromMigrationFix(); - $migration->update($connection); - $migration->update($connection); - - static::assertFalse($this->columnExists($connection, $tableName, $columnName)); - } -}