Upgrade von 5.3 auf 5.6.x - Migration schlägt fehl
Liebe Community,
nachdem ich ein Upgrade von 4.13.x nach 5.3 erfolgreich umsetzten konnte, schlägt ein Upgrade auf 5.6.x fehl bei der DB Migration
Das ganze läuft unter PHP 8.2, DB Konfiguration wird aus "config/parameters.yaml" geladen
root composer.json
Code:
{
"type": "project",
"require": {
"contao/calendar-bundle": "^5.6",
"contao/comments-bundle": "^5.6",
"contao/conflicts": "@dev",
"contao/faq-bundle": "^5.6",
"contao/listing-bundle": "^5.6",
"contao/manager-bundle": "5.6.*",
"contao/news-bundle": "^5.6",
"contao/newsletter-bundle": "^5.6",
"alnv/catalog-manager-bundle": "^3.0",
"codefog/contao-news_categories": "^4.0",
"do-while/contao-backupdb-bundle": "^2.1",
"madeyourday/contao-rocksolid-columns": "^2.0",
"madeyourday/contao-rocksolid-custom-elements": "^2.4",
"magic77/spreeprint-bundle": "dev-upgrade_to_5@dev",
"terminal42/contao-fineuploader": "^3.5",
"terminal42/contao-url-rewrite": "^1.8",
"terminal42/notification_center": "^2.0"
},
"extra": {
"public-dir": "web",
"contao-component-dir": "assets"
},
"scripts": {
"post-install-cmd": [
"@php vendor/bin/contao-setup"
],
"post-update-cmd": [
"@php vendor/bin/contao-setup"
]
},
"config": {
"github-oauth": {
"github.com": "XYZ"
},
"allow-plugins": {
"contao-components/installer": true,
"contao/manager-plugin": true,
"contao-community-alliance/composer-plugin": true,
"php-http/discovery": true
}
},
"repositories": {
"magic77/spreeprint-bundle": {
"type": "vcs",
"url": "https://github.com/magic-77/contao-spreeprint-bundle"
}
}
}
Code:
16:11:10 CRITICAL [console] Error thrown while running command "contao:migrate --no-interaction -vvv". Message: "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'where clause'"
[
"exception" => Doctrine\DBAL\Exception\InvalidFieldNameException^ {
#message: "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'where clause'"
#code: 1054
#file: "./vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php"
#line: 69
-previous: Doctrine\DBAL\Driver\PDO\Exception^ {
#message: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'where clause'"
#code: 1054
#file: "./vendor/doctrine/dbal/src/Driver/PDO/Exception.php"
#line: 24
-previous: PDOException {
#message: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'where clause'"
#code: "42S22"
#file: "./vendor/doctrine/dbal/src/Driver/PDO/Connection.php"
#line: 71
+errorInfo: [
"42S22",
1054,
"Unknown column 'type' in 'where clause'"
]
trace: {
./vendor/doctrine/dbal/src/Driver/PDO/Connection.php:71 { …}
./vendor/doctrine/dbal/src/Connection.php:1106 { …}
./vendor/doctrine/dbal/src/Connection.php:627 { …}
./vendor/contao/core-bundle/src/Migration/Version506/LayoutTemplateMigration.php:35 { …}
./vendor/contao/core-bundle/src/Migration/MigrationCollection.php:41 { …}
./vendor/contao/core-bundle/src/Migration/MigrationCollection.php:52 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:229 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:192 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:92 { …}
./vendor/symfony/console/Command/Command.php:318 { …}
./vendor/symfony/console/Application.php:1073 { …}
./vendor/symfony/framework-bundle/Console/Application.php:125 { …}
./vendor/symfony/console/Application.php:356 { …}
./vendor/symfony/framework-bundle/Console/Application.php:79 { …}
./vendor/symfony/console/Application.php:195 { …}
./vendor/contao/manager-bundle/bin/contao-console:40 { …}
./vendor/bin/contao-console:119 { …}
}
}
-sqlState: "42S22"
trace: {
./vendor/doctrine/dbal/src/Driver/PDO/Exception.php:24 { …}
./vendor/doctrine/dbal/src/Driver/PDO/Connection.php:76 { …}
./vendor/doctrine/dbal/src/Connection.php:1106 { …}
./vendor/doctrine/dbal/src/Connection.php:627 { …}
./vendor/contao/core-bundle/src/Migration/Version506/LayoutTemplateMigration.php:35 { …}
./vendor/contao/core-bundle/src/Migration/MigrationCollection.php:41 { …}
./vendor/contao/core-bundle/src/Migration/MigrationCollection.php:52 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:229 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:192 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:92 { …}
./vendor/symfony/console/Command/Command.php:318 { …}
./vendor/symfony/console/Application.php:1073 { …}
./vendor/symfony/framework-bundle/Console/Application.php:125 { …}
./vendor/symfony/console/Application.php:356 { …}
./vendor/symfony/framework-bundle/Console/Application.php:79 { …}
./vendor/symfony/console/Application.php:195 { …}
./vendor/contao/manager-bundle/bin/contao-console:40 { …}
./vendor/bin/contao-console:119 { …}
}
}
-query: Doctrine\DBAL\Query^ {
-sql: "SELECT TRUE FROM tl_layout WHERE type='modern' AND template='layout/default' LIMIT 1"
-params: []
-types: []
}
trace: {
./vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:69 { …}
./vendor/doctrine/dbal/src/Connection.php:1976 { …}
./vendor/doctrine/dbal/src/Connection.php:1918 { …}
./vendor/doctrine/dbal/src/Connection.php:1111 { …}
./vendor/doctrine/dbal/src/Connection.php:627 { …}
./vendor/contao/core-bundle/src/Migration/Version506/LayoutTemplateMigration.php:35 { …}
./vendor/contao/core-bundle/src/Migration/MigrationCollection.php:41 { …}
./vendor/contao/core-bundle/src/Migration/MigrationCollection.php:52 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:229 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:192 { …}
./vendor/contao/core-bundle/src/Command/MigrateCommand.php:92 { …}
./vendor/symfony/console/Command/Command.php:318 { …}
./vendor/symfony/console/Application.php:1073 { …}
./vendor/symfony/framework-bundle/Console/Application.php:125 { …}
./vendor/symfony/console/Application.php:356 { …}
./vendor/symfony/framework-bundle/Console/Application.php:79 { …}
./vendor/symfony/console/Application.php:195 { …}
./vendor/contao/manager-bundle/bin/contao-console:40 { …}
./vendor/bin/contao-console:119 { …}
}
},
"command" => "contao:migrate --no-interaction -vvv",
"message" => "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'where clause'"
]
16:11:10 DEBUG [console] Command "contao:migrate --no-interaction -vvv" exited with code "1054"
[
"command" => "contao:migrate --no-interaction -vvv",
"code" => 1054
]
Daraufhin habe ich die Tabelle entsprechend angepasst
Code:
ALTER TABLE tl_layout ADD COLUMN type varchar(16) NOT NULL DEFAULT 'modern';
dann wie in der Migration gegenprüfen
Code:
SELECT TRUE FROM tl_layout WHERE type='modern' AND template='layout/default' LIMIT 1
liefert :TRUE
Das ist die Migration die es betrifft "vendor/contao/core-bundle/src/Migration/Version506/LayoutTemplateMigration.php"
Code:
<?php
declare(strict_types=1);
/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/
namespace Contao\CoreBundle\Migration\Version506;
use Contao\CoreBundle\Migration\AbstractMigration;
use Contao\CoreBundle\Migration\MigrationResult;
use Contao\CoreBundle\Twig\ContaoTwigUtil;
use Contao\CoreBundle\Twig\Loader\ContaoFilesystemLoader;
use Doctrine\DBAL\Connection;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Path;
class LayoutTemplateMigration extends AbstractMigration
{
public function __construct(
private readonly Connection $connection,
private readonly ContaoFilesystemLoader $filesystemLoader,
private readonly Filesystem $filesystem,
) {
}
public function shouldRun(): bool
{
$test = $this->connection->fetchOne("SELECT TRUE FROM tl_layout WHERE type='modern' AND template='layout/default' LIMIT 1");
return false !== $test;
}
public function run(): MigrationResult
{
$this->connection->update(
'tl_layout',
[
'template' => 'page/layout',
],
[
'type' => 'modern',
'template' => 'layout/default',
],
);
$error = false;
foreach ($this->getOldTemplatePaths() as $oldPath) {
$newPath = Path::join(Path::getDirectory($oldPath), '../page/layout.html.twig');
try {
if (!$this->filesystem->exists($targetDirectory = Path::getDirectory($newPath))) {
$this->filesystem->mkdir($targetDirectory);
}
$this->filesystem->dumpFile(
$newPath,
$this->updateTemplateContent($this->filesystem->readFile($oldPath)),
);
$this->filesystem->remove($oldPath);
} catch (IOException) {
$error = true;
}
}
return $this->createResult(!$error);
}
private function getOldTemplatePaths(): \Generator
{
foreach ($this->filesystemLoader->getInheritanceChains()['layout/default'] ?? [] as $path => $logicalName) {
if (\in_array(ContaoTwigUtil::parseContaoName($logicalName)[0], ['Contao_App', 'Contao_Global'], true)) {
yield $path;
}
}
}
private function updateTemplateContent(string $content): string
{
return str_replace(
'@Contao/layout/default.html.twig',
'@Contao/page/layout.html.twig',
$content,
);
}
}
Migration nochmal laufenlassen - der Fehler bleibt - was übersehe ich hier?
Hat jemand ne Idee?