What is the recommended workflow using liquibase and git?

We recently started using Liquibase. This has not happened yet, but we imagined what would happen if two developers make changes to the change log file in the general Git repository.

How to resolve or avoid a merge conflict? To expand this question, something:

What is the recommended workflow using Liquibase in conjunction with Git?

Example scenario:
- Michael changes the column in the client table.
- Jacob changes the column in the table "account".
Thus, both developers added <changeSet>changelog.xml changelog to the same file.

EDIT:

As already noted, the script is not so exciting. Suppose Jacob was the last one to push his code. He must pull out first. Gets a warning to resolve merge conflicts. He solves the conflict by preserving both parts of the code, namely Michael and him. Updating the database with Liquibase does not cause problems.

Extended example scenario:
-Michael changes the column name "name" of the table "client" to "first_name", commits and pushes.
-Jacob changes the column name "name" of the table "client" to "last_name" and commits.
-Jacob gets a merge conflict when retrieving Michael code.
-Jakob and Michael discussed the conflict and agreed that it should be the "last_name" that Jacob commits and pushes.
-Mishal pulls out the resolved conflict and starts the Liquibase update. It receives an error message:column "name" does not exist

+6
source share
4 answers

, , . Git , changeSets .

Liquibase changeSets id/author/filename, , Jacob changeSet, , , Michaels changeSet . changeSet, Liquibase dev changeSet , , - . changeSets.

, , . , . , changeSets , . changeSet, , . Git, .

, , .

, . (, ), changeSets, changeSet, . , "" changeSet. , , .

, liquibase changeLogSync, changeSet . changeSet , liquibase rollbackCount X, , changeSet, liquibase update

/ , changeSets, - <preConditions onFail="MARK_RAN"><changeSetExecuted id=....></preConditions>. changeSet changeSet, , changeSet , changeSets. first_name, , last_name changeSet .

+4

, Liquibase, . , Liquibase . JIRA, , . , ; 1.22, , , Liquibase update.xml script, . update.xml , , , .

, src/main/liquibase:

β”œβ”€β”€ install                        
β”‚   β”œβ”€β”€ projectauthor.xml          
β”‚   β”œβ”€β”€ project_obspriorities.xml  
β”‚   β”œβ”€β”€ project_priorities.xml     
β”‚   β”œβ”€β”€ project_udv.xml            
β”‚   β”œβ”€β”€ project.xml                
β”‚   β”œβ”€β”€ roles.xml                  
β”‚   β”œβ”€β”€ scan.xml                   
β”‚   β”œβ”€β”€ (the other table definitions in the system go here)
β”‚
β”œβ”€β”€ install.xml                 <-- this reads all the files in ./install
β”‚
β”œβ”€β”€ local.properties            <--
β”œβ”€β”€ prod.properties             <--  these are database credentials (boo, hiss)  
β”œβ”€β”€ staging.properties          <-- 
β”œβ”€β”€ test.properties             <--  
β”‚
β”œβ”€β”€ update.xml                  <-- reads each version/master.xml file     
β”‚
β”œβ”€β”€ v1.16
β”‚   β”œβ”€β”€ 2013-06-06_EVL-2240.xml
β”‚   β”œβ”€β”€ 2013-07-01_EVL-2286-remove-invalid-name-characters.xml
β”‚   β”œβ”€β”€ 2013-07-02_defer-coauthor-projectauthor-unique-constraint.xml
β”‚   └── master.xml
β”œβ”€β”€ v1.17
β”‚   β”œβ”€β”€ 2013-07-19_EVL-2295.xml
β”‚   β”œβ”€β”€ 2013-09-11_EVL-2370_otf-mosaicking.xml
β”‚   └── master.xml
β”œβ”€β”€ v1.18
β”‚   β”œβ”€β”€ 2014-05-05_EVL-2326-remove-prerequisite-construct.xml
β”‚   β”œβ”€β”€ 2014-06-03_EVL-2750_fix-p-band-polarizations.xml
β”‚   └── master.xml

install.xml - :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

    <include file="src/main/liquibase/project/install/projectauthor.xml"/>
    <include file="src/main/liquibase/project/install/project_obspriorities.xml"/>
    ...
</databaseChangeLog>

update.xml - :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
    <include file="src/main/liquibase/project/v1.18/master.xml"/>
</databaseChangeLog>

, , , install/*. xml , , .

, . Subversion .

+5

, , " , " last_name ", ".

( ). .

- - > first_name AND first_name- > last_name.

0

TL; DR: /path/to/changelogfile.xml merge=union .gitattributes.

. liquibase:

  1. includeAll includeAll .
  2. include , .

- : (1) includeAll , , , , , . . , . , : , , , . (2) , . : !

, . , . . liquibase - , , . , . , , , , . , , .gitattributes git- ( ) :

/path/to/changelogfile.xml merge=union

-. , - . , ( ). , . . , , , .

Please note that your Git portal may not support the merge strategy, and you still get merge conflicts in retrieval requests (also called merge requests). But, nevertheless, when you see this and try to unite or relocate to resolve conflicts, the conflict is already resolved. I know that GitLab supports this. Not sure about Github or BitBucket.

0
source

Source: https://habr.com/ru/post/1546282/


All Articles