From d6517ec753cc27699ad71637a87c7e9734dcc724 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Fri, 6 Oct 2017 12:44:06 +0200
Subject: [PATCH] fix: brick patch -> database id field considered

---
 patches/uniqueIds.php     | 16 +++++++++++++++-
 src/QUI/Bricks/Events.php |  2 ++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/patches/uniqueIds.php b/patches/uniqueIds.php
index 8b83912..0a1ab6a 100644
--- a/patches/uniqueIds.php
+++ b/patches/uniqueIds.php
@@ -6,13 +6,27 @@
 
 // workaround for older patch
 $Bricks = QUI\Bricks\Manager::init();
+
+// database table
+$columns = QUI::getDataBase()->table()->getColumns($Bricks->getUIDTable());
+$columns = array_flip($columns);
+
+if (isset($columns['id'])) {
+    QUI::getDataBase()->table()->deleteColumn(
+        $Bricks->getUIDTable(),
+        'id'
+    );
+
+    QUI::getPackage('quiqqer/bricks')->setup();
+}
+
 $result = QUI::getDataBase()->fetch(array(
     'count' => 'count',
     'from'  => $Bricks->getUIDTable(),
 ));
 
 // if unique ids already exist, the pages no longer have to be passed through
-if (false && isset($result[0]) && isset($result[0]['count']) && $result[0]['count']) {
+if (isset($result[0]) && isset($result[0]['count']) && $result[0]['count']) {
     echo 'Already executed'.PHP_EOL;
 
     return;
diff --git a/src/QUI/Bricks/Events.php b/src/QUI/Bricks/Events.php
index 9e2cc20..f09520d 100644
--- a/src/QUI/Bricks/Events.php
+++ b/src/QUI/Bricks/Events.php
@@ -219,5 +219,7 @@ public static function onPackageSetup(QUI\Package\Package $Package)
         if ($Package->getName() !== 'quiqqer/bricks') {
             return;
         }
+
+        shell_exec('php '.OPT_DIR.'quiqqer/bricks/patches/uniqueIds.php');
     }
 }
-- 
GitLab