From 3705824ad24e58c22613ab180d6c967254f77c34 Mon Sep 17 00:00:00 2001 From: Axel Guckelsberger Date: Mon, 6 Dec 2021 15:28:44 +0100 Subject: [PATCH] fix #4762 --- CHANGELOG-3.1.md | 1 + .../Entity/GroupApplicationEntity.php | 2 +- .../GroupsModule/Entity/GroupEntity.php | 2 +- .../EventListener/Core3UpgradeListener.php | 42 +++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/system/GroupsModule/EventListener/Core3UpgradeListener.php diff --git a/CHANGELOG-3.1.md b/CHANGELOG-3.1.md index d675027ac5..3240d6817e 100644 --- a/CHANGELOG-3.1.md +++ b/CHANGELOG-3.1.md @@ -20,6 +20,7 @@ - [Admin] Add missing numeric casts to admin module setting usages (#4709). - [Extensions] Fixed non-working extension modification actions (#4768). - [Groups] Fix some non-working translations (#4694). + - [Groups] Rename database tables for improved PostgreSQL compatibilty (#4762). - [Menu] Fixed handling of menu items without URI in custom request voter. - [Search] Add missing query string to search results pagination. - [Theme] Asset combination now defaults to `false` on installation (#4419). diff --git a/src/system/GroupsModule/Entity/GroupApplicationEntity.php b/src/system/GroupsModule/Entity/GroupApplicationEntity.php index d8afcf6220..46177792d4 100644 --- a/src/system/GroupsModule/Entity/GroupApplicationEntity.php +++ b/src/system/GroupsModule/Entity/GroupApplicationEntity.php @@ -21,7 +21,7 @@ * GroupApplication entity class. * * @ORM\Entity(repositoryClass="Zikula\GroupsModule\Entity\Repository\GroupApplicationRepository") - * @ORM\Table(name="group_applications") + * @ORM\Table(name="zikula_groups_application") */ class GroupApplicationEntity extends EntityAccess { diff --git a/src/system/GroupsModule/Entity/GroupEntity.php b/src/system/GroupsModule/Entity/GroupEntity.php index db00946705..380c85dbc7 100644 --- a/src/system/GroupsModule/Entity/GroupEntity.php +++ b/src/system/GroupsModule/Entity/GroupEntity.php @@ -24,7 +24,7 @@ * Group entity class. * * @ORM\Entity(repositoryClass="Zikula\GroupsModule\Entity\Repository\GroupRepository") - * @ORM\Table(name="`groups`") + * @ORM\Table(name="zikula_groups_group") */ class GroupEntity extends EntityAccess { diff --git a/src/system/GroupsModule/EventListener/Core3UpgradeListener.php b/src/system/GroupsModule/EventListener/Core3UpgradeListener.php new file mode 100644 index 0000000000..2f1d15cbe4 --- /dev/null +++ b/src/system/GroupsModule/EventListener/Core3UpgradeListener.php @@ -0,0 +1,42 @@ + 'upgrade' + ]; + } + + public function upgrade(CoreUpgradePreExtensionUpgrade $event): void + { + if (!version_compare($event->getCurrentCoreVersion(), '3.1.0', '<')) { + return; + } + $sm = $this->conn->getSchemaManager(); + if ($sm->tablesExist(['groups'])) { + $sql = 'RENAME TABLE `groups` TO `zikula_groups_group`, `group_applications` TO `zikula_groups_application`;'; + $this->conn->executeQuery($sql); + } + } +}