java - What is the recommended workflow using Liquibase and Git? -


recently started using liquibase. didn't occurred yet imagined happen if 2 developers commits changes in change log file shared git repository.

how solve or avoid merge conflict? broaden question what:

what recommended workflow using liquibase in combination git?

example scenario:
- michael changes column in table 'customer'.
- jacob changes column in table 'account'.
both developers added <changeset> same changelog file changelog.xml.

edit :

as commented scenario isn't exciting indeed. assume jacob last 1 push code. has pull first. gets warning there merge conflicts solve. solves conflict keeping both parts of code, of michael's , his. updating database liquibase gives no problems.

advanced example scenario:
-michael changes name of column 'name' of table 'customer' in 'first_name', commits , pushes.
-jacob changes name of column 'name' of table 'customer' in 'last_name' , commits.
-jacob gets merge conflict when pulling michael's code.
-jacob , michael discussed conflict , agreed has 'last_name', jacob commits , pushes.
-michael pulls solved conflict , runs liquibase update. gets error: column "name" not exist

there edge cases need manually handled, happen infrequently. git handles merging of changes @ text level fine, merged file have both changesets in it, 1 after other.

since liquibase tracks changesets id/author/filename, fact jacob's changeset happens end before michaels' in final changeset doesn't matter. when both devs run final changeset, liquibase run other dev's changeset because theirs has been marked ran other has not. other environments, both changesets run.

your advanced case run problems because both developers making changes contradictory each other. run similar problems if both developers drop column, or add new column same name. it's not 1 developer vs. another, conflicting changesets come 2 separate feature branches being merged in. there no problem physically merged changeset itself, problem new changelog not logically correct. it's not git problem, it's logic problem.

in practice, type conflict happens because different developers , different branches working on separate areas of codebase , when there potential conflict, handle through communication , planning.

if run conflict, there several ways resolve it. handled (like in example) deleting incorrect or duplicate changesets can handled creating brand new changeset combination of both. in either case, need handle databases have ran "wrong" changeset. how best handle depends on how many systems have ran it.

if single developer, easiest run liquibase changelogsync mark new changeset ran , manually make change in database. if bad changeset ran lately, run liquibase rollbackcount x revert bad change , remove changeset , liquibase update

if there multiple conflicts and/or multiple systems have ran problem changesets, easiest approach use <preconditions onfail="mark_ran"><changesetexecuted id=....></preconditions> tags. can remove bad changeset , add new changeset runs if old changeset executed , puts database in state expected later changesets. in example, rename first_name name name last_name changeset works fine.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -