# Shopware 5.3.0 Datenbank fehler \>\>1062 Duplicate entry '1' for key 'PRIMARY' \<\<

**URL:** <https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253>\
**Category:** Administration\
**Created:** [2. August 2017 um 12:22 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253 "2017-08-02T12:22:21Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sascha\_Zoundhouse](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@Sascha\_Zoundhouse](https://forum.shopware.com/u/Sascha_Zoundhouse)\
**Post date:** [2. August 2017 um 12:22 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/1 "2017-08-02T12:22:21Z")

</div>

Error

Hallo, beim Update auf 5.3.0 bekomme ich bei der Datenbank Migration folgende fehler:

&nbsp;

\*\*\_Received the following error message:  
Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1’ for key ‘PRIMARY’

Please try to fix this error and restart the update.\_\*\*

**_Response_**

```
**_{"valid":false,"errorMsg":"Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY' "}_**

```

&nbsp;

Zuvor musste ich schon eine Tabelle löschen wegen:

&nbsp;

_Error  
Received the following error message:  
Could not apply migration (Migrations\_Migration907). Error: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘s\_order\_basket\_signatures’ already exists_

_Please try to fix this error and restart the update.  
Response_

_{“valid”:false,“errorMsg”:"Could not apply migration (Migrations\_Migration907). Error: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘s\_order\_basket\_signatures’ already exists "}_

&nbsp;

Die update vorher liefen immer ohne probleme.  
Woran liegt es jetzt?

Weiß jemand wie ich den fehler “**_{“valid”:false,“errorMsg”:"Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1’ for key ‘PRIMARY’ "}_**” lösen kann?

&nbsp;

Liebe Grüße und danke schon einmal.

---

<div class="post-metadata">

**Author:** ![site-concept](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@site-concept](https://forum.shopware.com/u/site-concept)\
**Post date:** [3. August 2017 um 12:16 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/2 "2017-08-03T12:16:27Z")

</div>

Bei uns gibt es den gleichen Fehler.  
Von 5.2.18 auf 5.3 tritt der Fehler auf. Und von 5.2.27 auf 5.3 ebenfalls.  
Vielleicht hat shopware ein Idee?

---

<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:** [3. August 2017 um 12:22 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/3 "2017-08-03T12:22:46Z")

</div>

Naja die Tabelle&nbsp;s\_order\_basket\_signatures gibt es in 5.2 noch garnicht. Du solltest mal schauen, warum die bei dir schon da ist.  
Gab es vorher mal ein fehlgeschlagenes Update? Oftmals wird ein Backup nicht korrekt eingespielt und neue Tabellen bleiben bestehen, die müssen bei einem Backup sauebr gelöscht werden. Backups daher immer in leere Datenbanken einspielen.

---

<div class="post-metadata">

**Author:** ![site-concept](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@site-concept](https://forum.shopware.com/u/site-concept)\
**Post date:** [3. August 2017 um 12:47 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/4 "2017-08-03T12:47:29Z")

</div>

Also Bei uns existiert die Tabelle, obwohl wir kein Update vorher auasgeführt haben.  
Gibt es eine Übersicht, welche Tabelle neu sind in 5.3?  
Dann könnte ich die vorher löschen

&nbsp;

---

<div class="post-metadata">

**Author:** ![site-concept](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@site-concept](https://forum.shopware.com/u/site-concept)\
**Post date:** [3. August 2017 um 12:58 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/5 "2017-08-03T12:58:34Z")

</div>

Ich kann es selber beantworten.

Wahrscheinlich ist das Update vorher schief gelaufen.

Nachdem ich folgende Tabellen gelöscht haben, läuft es fehlerfrei durch:

&nbsp;

s\_core\_auth\_config  
s\_customer\_search\_index  
s\_customer\_streams  
s\_customer\_streams\_attributes  
s\_customer\_streams\_mapping  
s\_emotion\_preset\_translations  
s\_emotion\_presets  
s\_order\_basket\_signatures  
s\_search\_custom\_facet  
s\_search\_custom\_sorting

---

<div class="post-metadata">

**Author:** ![zimo](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zimo](https://forum.shopware.com/u/zimo)\
**Post date:** [11. August 2017 um 17:43 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/6 "2017-08-11T17:43:54Z")

</div>

Hänge an ähnlichem Problem fest

Error

Received the following error message:  
Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1’ for key ‘PRIMARY’

Please try to fix this error and restart the update.

Response

```
 {"valid":false,"errorMsg":"Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY' "}
```

---

<div class="post-metadata">

**Author:** ![dogado\_shops](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dogado\_shops](https://forum.shopware.com/u/dogado_shops)\
**Post date:** [11. August 2017 um 21:11 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/7 "2017-08-11T21:11:03Z")

</div>

Upgrade Hinweise beachtet (besonders Punkt 2) ?

> **[Shopware Dokumentation](https://docs.shopware.com/de)**

VG

---

<div class="post-metadata">

**Author:** ![zimo](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zimo](https://forum.shopware.com/u/zimo)\
**Post date:** [12. August 2017 um 05:45 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/8 "2017-08-12T05:45:04Z")

</div>

Plugins waren alle aktuell.

---

<div class="post-metadata">

**Author:** ![zimo](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zimo](https://forum.shopware.com/u/zimo)\
**Post date:** [15. August 2017 um 12:44 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/9 "2017-08-15T12:44:56Z")

</div>

Hat jemand eine Idee? Die Datenbank hat nun scheinbar einen Fehler weg, mir fehlt aber das Wissen den zu finden.

Heute beim nächsten Versuch:

> Error
> 
> Received the following error message:  
> Could not apply migration (Migrations\_Migration907). Error: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‚s\_order\_basket\_signatures‘ already exists&nbsp;
> 
> Please try to fix this error and restart the update.
> 
> Response
> 
> {„valid“:false,„errorMsg“:"Could not apply migration (Migrations\_Migration907). Error: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‚s\_order\_basket\_signatures‘ already exists "}

---

<div class="post-metadata">

**Author:** ![zimo](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zimo](https://forum.shopware.com/u/zimo)\
**Post date:** [17. August 2017 um 08:29 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/10 "2017-08-17T08:29:02Z")

</div>

So alle Tabellen bereinigt und das Update ist durchgelaufen.

---

<div class="post-metadata">

**Author:** ![SohoJo](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SohoJo](https://forum.shopware.com/u/SohoJo)\
**Post date:** [25. August 2017 um 16:22 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/11 "2017-08-25T16:22:16Z")

</div>

Hi Allerseits,

ich klinke mich hier mal ein weil wir das gleiche Problem haben.

Unser CE Update von 5.2.27 auf 5.3 bleibt bei der DB Migration hängen:

> Received the following error message: Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‚1‘ for key ‚PRIMARY‘ Please try to fix this error and restart the update. Response {„valid“:false,„errorMsg“:"Could not apply migration (Migrations\_Migration917). Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‚1‘ for key ‚PRIMARY‘ "}

Das Löschen der o.g. Tabellen habe ich auch versucht, hat aber leider nicht gebracht.  
Plugins waren alle als aktuell und als kompatibel gekennzeichnet  
Vielleicht weiß jemand was?

Vielen Dank schon mal und viele Grüße!

Sascha

&nbsp;

---

<div class="post-metadata">

**Author:** ![SohoJo](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SohoJo](https://forum.shopware.com/u/SohoJo)\
**Post date:** [29. August 2017 um 16:19 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/12 "2017-08-29T16:19:17Z")

</div>

So, geschafft!&nbsp; ![Foot-in-Mouth](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/bedbc37f276faa6d086ddea9cd70cb0550bbd56e.png "Foot-in-Mouth")&nbsp;

Ich schreib mal auf wie, falls jemand gerade an einem ähnlichen Problem rumbastelt.

Die Ursache war ein vorab fehlgeschlagenes Update nach welchem wir ein Datenbankbackup eingespielt hatten  
Das haben wir aber leider getan haben ohne die Datenbank vorher zu leeren.&nbsp;

Als Resultat sind darin ein paar der Einträge des missglückten Updates übriggeblieben, woran sich das erneute Update dann aufgerieben hat.

Wir mussten nun also folgende Tabellen löschen:

_s\_order\_basket\_signatures  
s\_search\_custom\_sorting &nbsp;&nbsp;  
s\_customer\_streams  
s\_customer\_streams\_mapping  
s\_customer\_search\_index_

Dann hat das Update noch mehrere \*_1060 Duplicate column name_\* Fehler ausgeworfen.  
z.B.&nbsp;  
_Could not apply migration (Migrations\_Migration938). Error: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘emotion\_translations’&nbsp;_  
Diese Tabellen darf man nicht löschen noch kann man&nbsp;einfach die Einträge darin entfernen.

Hier mussten wir im &nbsp;update-assets Ordner (_…/files/update/update-assets/migrations_) in den entsprechenden migrations .php Dateien den jeweiligen Eintrag herausnehmen

Für alle Dummies wie mich; die Liste mit den migrations gibt’s hier.  
[https://github.com/shopware/shopware/tree/5.3/\_sql/migrations](https://github.com/shopware/shopware/tree/5.3/_sql/migrations)

Danach lief das Update einwandfrei durch.

&nbsp;

Gute Geschäfte allerseits!  
Sascha  
&nbsp;

---

<div class="post-metadata">

**Author:** ![hfits](https://avatars.discourse-cdn.com/v4/letter/h/9de053/32.png) [@hfits](https://forum.shopware.com/u/hfits)\
**Post date:** [31. August 2017 um 03:57 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/13 "2017-08-31T03:57:13Z")

</div>

Hallo,

vielen Dank für die gute Vorarbeit!  
Mit Hilfe folgender SQL-Befehle konnte das Update durchgeführt werden:

DROP TABLE `\< name_der_datenbank \>`.`s_order_basket_signatures`  
DROP TABLE `\< name_der_datenbank \>`.`s_core_auth_config`  
DROP TABLE `\< name_der_datenbank \>`.`s_search_custom_sorting`  
DROP TABLE `\< name_der_datenbank \>`.`s_customer_streams_mapping`  
DROP TABLE `\< name_der_datenbank \>`.`s_customer_streams_attributes`  
DROP TABLE `\< name_der_datenbank \>`.`s_customer_streams`  
ALTER TABLE `\< name_der_datenbank \>`.`s_emotion_presets` DROP COLUMN `emotion_translations`

Hoffentlich hilft es Anderen genauso!

&nbsp;

Gruß

&nbsp;

EDITH sagt:

da fehlt noch die Tabelle:

DROP TABLE `\< name_der_datenbank \>`.‘s\_customer\_search\_index’

---

<div class="post-metadata">

**Author:** ![Domagical](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@Domagical](https://forum.shopware.com/u/Domagical)\
**Post date:** [11. Oktober 2017 um 10:38 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/14 "2017-10-11T10:38:02Z")

</div>

Hallo,

&nbsp;

ich hatte Shopware 5.3 RC installiert. Leider hat das Update nicht richtig funktioniert. Anschließend habe ich leider die Datenbank nicht vollständig geleert udn dann wieder ein altes Backup eingespielt.

Jetzt würde ich gerne auf 5.3.3 updaten bekomme aber viele Fehlermeldungen wegen bereits existierende Dateien usw.

Gibt es ein Tool, dass alle Änderungen die durch das Update auf 5.3RC in der Datenbank rückgägig macht, sodass ich mit dem aktuellen Datenbankstand auf 5.3.3 aktualsieren kann?

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Domagical](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@Domagical](https://forum.shopware.com/u/Domagical)\
**Post date:** [23. Oktober 2017 um 06:04 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/15 "2017-10-23T06:04:11Z")

</div>

Gibt es irgendwie eine Möglichkeit jetzt sauber auf 5.3 upzugraden nach dem beschriebenen Szenario im Post zuvor? Wäre um jeden Tipp dankbar.

---

<div class="post-metadata">

**Author:** ![Branky](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@Branky](https://forum.shopware.com/u/Branky)\
**Post date:** [15. November 2017 um 13:45 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/16 "2017-11-15T13:45:48Z")

</div>

Hallo,  
ich hatte nach einem mißglückten Update die gleichen Probleme. Leider konnte ich einige Tabellen nicht löschen, da ein Foreign Key hinterlegt war. Geholfen hat dann der Befehl  
SET FOREIGN\_KEY\_CHECKS = 0; DROP TABLE Tabellenname;&nbsp; in den SQL Befehlen. Vielleicht hilft das ja nochmal jemanden…

---

<div class="post-metadata">

**Author:** ![dobrock](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@dobrock](https://forum.shopware.com/u/dobrock)\
**Post date:** [29. Mai 2018 um 17:02 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/17 "2018-05-29T17:02:56Z")

</div>

> [@SohoJo schrieb:](https://forum.shopware.com/profile/22091/SohoJo "SohoJo")
> 
> Hier mussten wir im &nbsp;update-assets Ordner (_…/files/update/update-assets/migrations_) in den entsprechenden migrations .php Dateien den jeweiligen Eintrag herausnehmen

Hallo an die Expertenrunde!

Ich habe heute 8 Stunden mit dem Update (5.2.9 auf 5.4.3) gekämpft. Leider konnte mir keiner der Foreneinträge wirklich weiterhelfen. Morgen früh stellt der Hoster alles wieder her und ich probiere es noch einmal.&nbsp;

Die Meldungen mit den Tabellen habe ich verstanden. Alle Tabellen entsprechend gelöscht, bis die Migrationsmeldungen kamen. Hier bin ich nicht mehr weiter gekommen.

Ich habe nach der Anleitung von SohoJo die jeweiligen Migrationsdateien gefunden. Doppelte Einträge o.Ä. konnte ich dort aber nicht finden. Ich habe auch probiert, in der Tabelle s\_schema\_version den Fehlerhaften Eintrag auf NULL zu setzen, bzw. die angezeigte Fehlermeldung zu beheben. Hat alles nichts geholfen.&nbsp;

![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/a/ab3d6b3e3cdfef82ca49333d8423cc1598c80568.jpeg)

An solchen Migrations-Fehlermeldungen hänge ich immer fest.&nbsp;

Hat jemand noch eine Anleitung oder Erklärung für Begriffsstutzige, die mir weiter helfen kann?

Danke und Grüße

---

<div class="post-metadata">

**Author:** ![dobrock](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@dobrock](https://forum.shopware.com/u/dobrock)\
**Post date:** [31. Mai 2018 um 07:44 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/18 "2018-05-31T07:44:31Z")

</div>

Hat niemand eine Idee?

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [31. Mai 2018 um 08:20 UTC](https://forum.shopware.com/t/shopware-5-3-0-datenbank-fehler-1062-duplicate-entry-1-for-key-primary/47253/19 "2018-05-31T08:20:25Z")

</div>

Der Hoster hat beim Wiederherstellen nicht alle vorhandenen Tabellen entfernt. Jetzt hast du in einer älteren Version Tabellen die erst später hinzu kommen. Dadurch auch der Migrationsfehler
