You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(0.3/2014-02-11--categories.xml): let the database to autogenerate id instead of providing our own.
This change should fix 2017-01-06--top_categories.xml migration on
PostgreSQL. Prior this commit, we were inserting 'Prehistoric animals'
category with explicitly provided id=1 By doing this, we didn't update
the sequence generator. When next time we were trying to add another
category without id, the sequence generator gave us the value 1 and
migration were failing as a category with such id already exist.
See for details:
https://stackoverflow.com/questions/44744365/liquibase-postgresql-spring-jpa-id-auto-increment-issue
There were two ways to fix this: always specify id explicitly and adjust
the sequence generator manually after that or never provide an id and
let the generator do all the work for us. This change implements the
second approach because the first one would be specific to PostgreSQL
(as on MySQL we don't need to adjust generators at all).
The failure was:
MigrationFailedException: Migration failed for change set classpath:/liquibase/version/0.4/2017-01-06--top_categories.xml::add-sport-category::php-coder:
Reason: liquibase.exception.DatabaseException: ERROR: duplicate key value violates unique constraint "pk_categories"
Detail: Key (id)=(1) already exists.
[Failed SQL: INSERT INTO public.categories (name, name_ru, slug, created_at, created_by, updated_at, updated_by)
VALUES ('Sport', 'Спорт', 'sport', NOW(), (SELECT id FROM users WHERE role = 'ADMIN' ORDER by id LIMIT 1), NOW(),
(SELECT id FROM users WHERE role = 'ADMIN' ORDER by id LIMIT 1))]
Addressed to #1034
0 commit comments