M
M
MSAFT2019-01-25 21:36:08
PostgreSQL
MSAFT, 2019-01-25 21:36:08

Yii2 how to solve migration error?

Good evening.
I got a project on Yii2, which has a PostgreSQL database. When migrating, I get this error:

*** applying m160419_000425_add_access_rule
    > insert into {{%admin_auth_item}} ...Exception 'yii\db\IntegrityException' with message 'SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint "admin_auth_item_pkey"
DETAIL:  Key (name)=(partner_sale) already exists.
The SQL being executed was: INSERT INTO "admin_auth_item" ("name", "description", "type", "created_at", "updated_at") VALUES ('partner_sale', 'Заявки партнеров', 2, 1548441309, 1548441309)'

in /home/dmitriy/Projects/gt/vendor/yiisoft/yii2/db/Schema.php:664

How to decide? No experience with PostgreSQL yet

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
MSAFT, 2019-01-26
@MSAFT

I decided by doing the migration again, after an error I got into the database and renamed the key with the addition of a symbol, because. just when deleting again, the error popped up. Strange, but that's how it is.

A
Arthur K., 2019-01-25
@amark

it seems that the database already has data with this key, so the insert swears at "duplicate key value"

G
grinat, 2019-01-26
@grinat

You can suppress it through on conflict do nothing, but most likely it will come back to haunt you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question