# DB Fehler in Update-Plugin

**URL:** <https://forum.shopware.com/t/db-fehler-in-update-plugin/43538>\
**Category:** Plugins\
**Tags:** offizielle-shopware-\
**Created:** [8. Februar 2017 um 18:07 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538 "2017-02-08T18:07:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DerNils](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@DerNils](https://forum.shopware.com/u/DerNils)\
**Post date:** [8. Februar 2017 um 18:07 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/1 "2017-02-08T18:07:50Z")

</div>

Moin.

Seit ein paar Tagen erhalte ich beim Login immer eine Fehlermail:

```
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'element_id' cannot be null' in /var/www/vinos/sw5/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:987
Stack trace:
#0 /var/www/vinos/sw5/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(987): PDOStatement->execute()
#1 /var/www/vinos/sw5/engine/Shopware/Bundle/PluginInstallerBundle/Service/UniqueIdGenerator/UniqueIdGenerator.php(102): Doctrine\DBAL\Connection->executeUpdate('INSERT INTO s_c...', Array)
#2 /var/www/vinos/sw5/engine/Shopware/Bundle/PluginInstallerBundle/Service/UniqueIdGenerator/UniqueIdGenerator.php(61): Shopware\Bundle\PluginInstallerBundle\Service\UniqueIdGenerator\UniqueIdGenerator->storeUniqueIdInDb('Mb6wYJLTiHAuPGO...')
#3 /var/www/vinos/sw5/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php(453): Shopware\Bundle\PluginInstallerBundle\Service\UniqueIdGenerator\UniqueIdGenerator->getUniqueId()
#4 /var/www/vinos/sw5/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php(266): Shopware_Controllers_Backend_SwagUpdate->getUnique()
#5 /var/www/vinos/sw5/engine/Library/Enlight/Controller/Action.php(159): Shopware_Controllers_Backend_SwagUpdate->popupAction()
#6 /var/www/vinos/sw5/engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('popupAction')
#7 /var/www/vinos/sw5/engine/Library/Enlight/Controller/Front.php(223): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#8 /var/www/vinos/sw5/engine/Shopware/Kernel.php(179): Enlight_Controller_Front->dispatch()
#9 /var/www/vinos/sw5/vendor/symfony/http-kernel/HttpCache/HttpCache.php(487): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /var/www/vinos/sw5/engine/Shopware/Components/HttpCache/AppCache.php(255): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#11 /var/www/vinos/sw5/vendor/symfony/http-kernel/HttpCache/HttpCache.php(258): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#12 /var/www/vinos/sw5/engine/Shopware/Components/HttpCache/AppCache.php(103): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true)
#13 /var/www/vinos/sw5/shopware.php(117): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#14 {main}

Next exception 'Doctrine\DBAL\DBALException' with message 'An exception occurred while executing 'INSERT INTO s_core_config_values (element_id, shop_id, value) VALUES (
(SELECT id FROM s_core_config_elements WHERE name LIKE 'trackingUniqueId' LIMIT 1), 1, ?
)' with params ["s:32:\"Mb6wYJLTiHAuPGOVRCkwSOTxU0st1mzM\";"]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'element_id' cannot be null' in /var/www/vinos/sw5/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:119
Stack trace:
#0 /var/www/vinos/sw5/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(996): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(PDOException), 'INSERT INTO s_c...', Array)
#1 /var/www/vinos/sw5/engine/Shopware/Bundle/PluginInstallerBundle/Service/UniqueIdGenerator/UniqueIdGenerator.php(102): Doctrine\DBAL\Connection->executeUpdate('INSERT INTO s_c...', Array)
#2 /var/www/vinos/sw5/engine/Shopware/Bundle/PluginInstallerBundle/Service/UniqueIdGenerator/UniqueIdGenerator.php(61): Shopware\Bundle\PluginInstallerBundle\Service\UniqueIdGenerator\UniqueIdGenerator->storeUniqueIdInDb('Mb6wYJLTiHAuPGO...')
#3 /var/www/vinos/sw5/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php(453): Shopware\Bundle\PluginInstallerBundle\Service\UniqueIdGenerator\UniqueIdGenerator->getUniqueId()
#4 /var/www/vinos/sw5/engine/Shopware/Plugins/Default/Backend/SwagUpdate/Controllers/Backend/SwagUpdate.php(266): Shopware_Controllers_Backend_SwagUpdate->getUnique()
#5 /var/www/vinos/sw5/engine/Library/Enlight/Controller/Action.php(159): Shopware_Controllers_Backend_SwagUpdate->popupAction()
#6 /var/www/vinos/sw5/engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('popupAction')
#7 /var/www/vinos/sw5/engine/Library/Enlight/Controller/Front.php(223): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#8 /var/www/vinos/sw5/engine/Shopware/Kernel.php(179): Enlight_Controller_Front->dispatch()
#9 /var/www/vinos/sw5/vendor/symfony/http-kernel/HttpCache/HttpCache.php(487): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /var/www/vinos/sw5/engine/Shopware/Components/HttpCache/AppCache.php(255): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#11 /var/www/vinos/sw5/vendor/symfony/http-kernel/HttpCache/HttpCache.php(258): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#12 /var/www/vinos/sw5/engine/Shopware/Components/HttpCache/AppCache.php(103): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true)
#13 /var/www/vinos/sw5/shopware.php(117): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#14 {main}

```

Das Select “SELECT id FROM s\_core\_config\_elements WHERE name LIKE ‘trackingUniqueId’” kann auch kein Ergebnis bringen, da es in der config-Tabelle keinen solchen Eintrag gibt.

Die Meldung kommt aus dem Plugin Shopware Update, wenn ich das deaktiviere bleibt der Fehler aus.

Hat jemand eine Idee?

SW 5.2.16

Danke  
Nils

---

<div class="post-metadata">

**Author:** ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)\
**Post date:** [8. Februar 2017 um 20:02 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/2 "2017-02-08T20:02:47Z")

</div>

Du hast dein Problem ja schon gefunden, den Eintrag muss es nämlich geben.  
Mit dieser Migration wird das angelegt: [shopware/796-add-uniqueid-config-element.php at cf6591164df77de5a1c1eb4518ce722458325900 · shopware/shopware · GitHub](https://github.com/shopware/shopware/blob/cf6591164df77de5a1c1eb4518ce722458325900/_sql/migrations/796-add-uniqueid-config-element.php)

---

<div class="post-metadata">

**Author:** ![Ailurus](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@Ailurus](https://forum.shopware.com/u/Ailurus)\
**Post date:** [13. Februar 2017 um 13:34 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/3 "2017-02-13T13:34:54Z")

</div>

Hallo Moritz,

Gleichen Problem hier… wie sollen die github Daten am besten verwenden werden? Habe versucht, einen migration.php zu erstellen, aber bisher ohne Erfolg.&nbsp;

Danke Dir.

Ailurus

&nbsp;

---

<div class="post-metadata">

**Author:** ![DerNils](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@DerNils](https://forum.shopware.com/u/DerNils)\
**Post date:** [13. Februar 2017 um 13:43 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/4 "2017-02-13T13:43:32Z")

</div>

Hallo&nbsp;Ailurus,

ich habe es mir einfach gemacht und die Statements direkt in der Datenbank ausgeführt. Erst das INSERT, dann das SELECT. Wenn das SELECT ein Ergebnis (eine id) bringt, dann das UPDATE ausführen mit dieser id. Bei mir brachte das SELECT kein Ergebnis.&nbsp;

Wenn du ein bisschen SQL-Kenntnisse hast, sollte das kein Problem sein.&nbsp;

---

<div class="post-metadata">

**Author:** ![Ailurus](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@Ailurus](https://forum.shopware.com/u/Ailurus)\
**Post date:** [13. Februar 2017 um 15:03 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/5 "2017-02-13T15:03:48Z")

</div>

Hallo Nils,

Danke Dir für die Hilfe. Meine Kentnisse sind da begrentzt, aber ich werde versuchen, die s\_core\_config\_elements zu erweitern.&nbsp;

[@Moritz Naczenski]([http://forum.shopware.com/profile/14574/Moritz](http://forum.shopware.com/profile/14574/Moritz) Naczenski “Moritz Naczenski”)‍ es würde mich trotzdem interessieren, etwas mehr über&nbsp;

```
getConnection()->prepare("SELECT id FROM s_core_config_elements WHERE name = 'update-unique-id'");
        $statement->execute();
        $id = $statement->fetchColumn();
        if (!empty($id)) {
            $sql = 'UPDATE s_core_config_elements SET name="trackingUniqueId" WHERE id=' . $this->getConnection()->quote($id);
        }
        $this->addSql($sql);
    }
}

```

zu erfahren, denn die lange liste von [Migrationen](https://github.com/shopware/shopware/tree/cf6591164df77de5a1c1eb4518ce722458325900/_sql/migrations) scheint sehr hilfreich zu sein.

Ailurus

---

<div class="post-metadata">

**Author:** ![FotoHolst](https://avatars.discourse-cdn.com/v4/letter/f/e0b2c6/32.png) [@FotoHolst](https://forum.shopware.com/u/FotoHolst)\
**Post date:** [1. März 2017 um 12:03 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/6 "2017-03-01T12:03:44Z")

</div>

Moin,

ich habe das Problem auch, ab Version 5.2.18, jetzt läuft 5.2.20.

exception ‘PDOException’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘element\_id’ cannot be null’

Und noch ein weiteres, Nils schrieb zur Lösung des Problems: “Wenn du ein bisschen SQL-Kenntnisse hast, sollte das kein Problem sein”. Habe ich aber leider nicht, hat jemand einen Rat für mich?

Vielen Dank im vorraus,

Andreas

---

<div class="post-metadata">

**Author:** ![DerNils](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@DerNils](https://forum.shopware.com/u/DerNils)\
**Post date:** [1. März 2017 um 12:28 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/7 "2017-03-01T12:28:00Z")

</div>

Hallo Andreas,

wenn Du Zugriff auf die Datenbank hast, zum Beispiel über phpmyadmin, dann ruf das auf, wähle links die Datenbank Deines Shops aus und klicke dann im rechten Fensterteil oben auf SQL. Im sich öffnenden Textfeld trägst Du dies ein:

INSERT INTO s\_core\_config\_elements (form\_id, name, value, label, description, type, required, position, scope) VALUES (‘0’, ‘trackingUniqueId’, ‘s:0:"";’, ‘Unique identifier’, ‘’, ‘text’, ‘0’, ‘0’, ‘1’)

und klickst auf OK.

Anschliessend rufst Du das SQL-Fenster erneut auf und führst dies aus:

SELECT id FROM s\_core\_config\_elements WHERE name = ‘update-unique-id’

Wenn diese Abfrage KEIN Ergebnis bringt, bist Du schon fertig. Wenn Du dagegen ein Ergebnis bekommst, also eine id, dann merk Dir diese id und trage ins SQL-Fenster dieses ein:

UPDATE s\_core\_config\_elements SET name=“trackingUniqueId” WHERE id=

füge am Ende&nbsp;die vorher gemerkte id ein und führe das aus. Das wars.

Wenn Du keinen Zugriff auf die Datenbank hast, habe ich keine Idee, wie Du das lösen kannst.&nbsp;Deshalb schliesse ich mich der Bitte von&nbsp;@Ailurus‍ an, doch mal zu beschreiben, wie mit diesen migrations umzugehen ist.

---

<div class="post-metadata">

**Author:** ![Ailurus](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@Ailurus](https://forum.shopware.com/u/Ailurus)\
**Post date:** [1. März 2017 um 12:40 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/8 "2017-03-01T12:40:09Z")

</div>

Danke Nils, I hatte noch keine Zeit zu antworten.

Habe auch genau getan, mit Erfolg. Grundsätzlich den Code (oben in&nbsp;Gelb) angepasst, und das wars. In PhpMyadmin sind Beispiele schon sichtbar, sobald ‚Select‘, ‚Update‘ usw. angeklickt werden.

Ailurus

---

<div class="post-metadata">

**Author:** ![FotoHolst](https://avatars.discourse-cdn.com/v4/letter/f/e0b2c6/32.png) [@FotoHolst](https://forum.shopware.com/u/FotoHolst)\
**Post date:** [3. März 2017 um 12:55 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/9 "2017-03-03T12:55:04Z")

</div>

Danke Nils,

da werde ich mich doch mal schlau machen und es versuchen, hoffe ich mache nicht noch mehr kaputt.

Andreas

---

<div class="post-metadata">

**Author:** ![Ailurus](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@Ailurus](https://forum.shopware.com/u/Ailurus)\
**Post date:** [3. März 2017 um 13:05 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/10 "2017-03-03T13:05:45Z")

</div>

Wenn Du über PhpMyadmin oder Plesk arbeitest, mach zuerst eine Sicherung (Abbild Exportieren). Somit ist es einfach, eventuelle Fehler zu überschreiben.

Prüf noch danach, ob alle Dateien im System richtig sind: [https://forum.shopware.com/discussion/44792/abstractmigration-php-und-manager-php-fehlerhaft#latest](https://forum.shopware.com/discussion/44792/abstractmigration-php-und-manager-php-fehlerhaft#latest)

Bei mir waren noch diese zwei Dateien zu ersetzen.

Ailurus

---

<div class="post-metadata">

**Author:** ![FotoHolst](https://avatars.discourse-cdn.com/v4/letter/f/e0b2c6/32.png) [@FotoHolst](https://forum.shopware.com/u/FotoHolst)\
**Post date:** [3. März 2017 um 13:10 UTC](https://forum.shopware.com/t/db-fehler-in-update-plugin/43538/11 "2017-03-03T13:10:31Z")

</div>

Ich glaube ich suche mir lieber jemanden der das macht, bin was das angeht absoluter Anfänger. Bin schon froh soweit gekommen zu sein, an der Datenbank zu schrauben übersteigt glaube ich meinen Horizont. Zur Zeit zumindest noch, man lernt ja nie aus.

Trotzdem vielen Dank für eure Unterstützung.

Andreas
