mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-10 06:36:10 +01:00
Use proper column names
Normal updates are executed: ./vendor/bin/typo3cms upgrade:prepare ./vendor/bin/typo3cms upgrade:run all --no-interaction ./vendor/bin/typo3cms database:updateschema '*' ./vendor/bin/typo3cms database:updateschema '*' The first one will execute an database:updateschema which will run safe which only adds and doesn't rename or remove columns. Then our update wizard can use the existing columns and new columns and tables. The last step will actually rename and remove.
This commit is contained in:
parent
172c0eab37
commit
c6ad36b294
1 changed files with 42 additions and 37 deletions
|
@ -107,23 +107,23 @@ class MigrateOldLocations implements UpgradeWizardInterface
|
||||||
|
|
||||||
private function getExitingLocationUid(array $event): int
|
private function getExitingLocationUid(array $event): int
|
||||||
{
|
{
|
||||||
$oldColumns = [
|
$columns = [
|
||||||
'sys_language_uid' => 'sys_language_uid',
|
'sys_language_uid',
|
||||||
'zzz_deleted_name' => 'name',
|
'name',
|
||||||
'zzz_deleted_street' => 'street',
|
'street',
|
||||||
'zzz_deleted_district' => 'district',
|
'district',
|
||||||
'zzz_deleted_city' => 'city',
|
'city',
|
||||||
'zzz_deleted_zip' => 'zip',
|
'zip',
|
||||||
'zzz_deleted_country' => 'country',
|
'country',
|
||||||
'zzz_deleted_phone' => 'phone',
|
'phone',
|
||||||
'zzz_deleted_latitude' => 'latitude',
|
'latitude',
|
||||||
'zzz_deleted_longitude' => 'longitude',
|
'longitude',
|
||||||
];
|
];
|
||||||
$qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_location');
|
$qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_location');
|
||||||
$qb->select('uid', 'l10n_parent');
|
$qb->select('uid', 'l10n_parent');
|
||||||
$qb->from('tx_events_domain_model_location');
|
$qb->from('tx_events_domain_model_location');
|
||||||
foreach ($oldColumns as $oldName => $newName) {
|
foreach ($columns as $column) {
|
||||||
$qb->andWhere($qb->expr()->eq($newName, $qb->createNamedParameter($event[$oldName])));
|
$qb->andWhere($qb->expr()->eq($column, $qb->createNamedParameter($event[$column])));
|
||||||
}
|
}
|
||||||
|
|
||||||
$uids = $qb->execute()->fetchAssociative();
|
$uids = $qb->execute()->fetchAssociative();
|
||||||
|
@ -138,19 +138,24 @@ class MigrateOldLocations implements UpgradeWizardInterface
|
||||||
{
|
{
|
||||||
$this->logger->info('Location will be created.', ['event' => $event]);
|
$this->logger->info('Location will be created.', ['event' => $event]);
|
||||||
|
|
||||||
$record = [
|
$columnsToMap = [
|
||||||
'pid' => $event['pid'],
|
'pid',
|
||||||
'sys_language_uid' => $event['sys_language_uid'],
|
'sys_language_uid',
|
||||||
'name' => $event['zzz_deleted_name'],
|
'name',
|
||||||
'street' => $event['zzz_deleted_street'],
|
'street',
|
||||||
'district' => $event['zzz_deleted_district'],
|
'district',
|
||||||
'city' => $event['zzz_deleted_city'],
|
'city',
|
||||||
'zip' => $event['zzz_deleted_zip'],
|
'zip',
|
||||||
'country' => $event['zzz_deleted_country'],
|
'country',
|
||||||
'phone' => $event['zzz_deleted_phone'],
|
'phone',
|
||||||
'latitude' => $event['zzz_deleted_latitude'],
|
'latitude',
|
||||||
'longitude' => $event['zzz_deleted_longitude'],
|
'longitude',
|
||||||
];
|
];
|
||||||
|
$record = [];
|
||||||
|
|
||||||
|
foreach ($columnsToMap as $columnName) {
|
||||||
|
$record[$columnName] = $event[$columnName];
|
||||||
|
}
|
||||||
$recordUid = 'NEW12121';
|
$recordUid = 'NEW12121';
|
||||||
$l10nParentUid = $this->uidsForTranslation[$event['l10n_parent'] . '-0'] ?? 0;
|
$l10nParentUid = $this->uidsForTranslation[$event['l10n_parent'] . '-0'] ?? 0;
|
||||||
$dataHandler = clone $this->dataHandler;
|
$dataHandler = clone $this->dataHandler;
|
||||||
|
@ -214,23 +219,23 @@ class MigrateOldLocations implements UpgradeWizardInterface
|
||||||
|
|
||||||
private function getQueryBuilder(): QueryBuilder
|
private function getQueryBuilder(): QueryBuilder
|
||||||
{
|
{
|
||||||
$oldColumns = [
|
$columns = [
|
||||||
'zzz_deleted_name',
|
'name',
|
||||||
'zzz_deleted_street',
|
'street',
|
||||||
'zzz_deleted_district',
|
'district',
|
||||||
'zzz_deleted_city',
|
'city',
|
||||||
'zzz_deleted_zip',
|
'zip',
|
||||||
'zzz_deleted_country',
|
'country',
|
||||||
'zzz_deleted_phone',
|
'phone',
|
||||||
'zzz_deleted_latitude',
|
'latitude',
|
||||||
'zzz_deleted_longitude',
|
'longitude',
|
||||||
];
|
];
|
||||||
$qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_event');
|
$qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_event');
|
||||||
$qb->getRestrictions()->removeAll();
|
$qb->getRestrictions()->removeAll();
|
||||||
$qb->select(...$oldColumns);
|
$qb->select(...$columns);
|
||||||
$qb->addSelect('uid', 'pid', 'sys_language_uid', 'l10n_parent');
|
$qb->addSelect('uid', 'pid', 'sys_language_uid', 'l10n_parent');
|
||||||
$qb->from('tx_events_domain_model_event');
|
$qb->from('tx_events_domain_model_event');
|
||||||
foreach ($oldColumns as $columnName) {
|
foreach ($columns as $columnName) {
|
||||||
$qb->orWhere($qb->expr()->neq($columnName, $qb->createNamedParameter('')));
|
$qb->orWhere($qb->expr()->neq($columnName, $qb->createNamedParameter('')));
|
||||||
}
|
}
|
||||||
$qb->orderBy('sys_language_uid', 'ASC');
|
$qb->orderBy('sys_language_uid', 'ASC');
|
||||||
|
|
Loading…
Reference in a new issue