mirror of
https://gitlab01.pm.org.ru/tnt/liquibase/liquibase-maven.git
synced 2026-02-27 23:10:07 +08:00
Compare commits
No commits in common. "cf65fb13e364207640a4c23c3ddee22b78cb89f0" and "dc562e705fa82b29d9ed3ef89a8e4276ac0953f0" have entirely different histories.
cf65fb13e3
...
dc562e705f
39
README.md
39
README.md
@ -49,7 +49,7 @@ mvn liquibase:update -Denv=cleanup.views
|
||||
### 2. liquibase diff.tables script
|
||||
|
||||
```shell
|
||||
mvn liquibase:diff -Denv=diff.tables -X > diff.tables/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
|
||||
mvn liquibase:diff -Denv=cleanup.tables -X > diff.tables/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
|
||||
```
|
||||
|
||||
```shell
|
||||
@ -66,40 +66,5 @@ mv diff.tables/changelog-dir/diff-changelog/*.sql diff.tables/changelog-dir/u
|
||||
```
|
||||
|
||||
```shell
|
||||
mvn liquibase:update -Denv=diff.tables -X > diff.tables/liquibase_log/liquibase_log_update-$(date +%Y%m%d%H%M%S).log
|
||||
```
|
||||
|
||||
```shell
|
||||
mvn liquibase:history -Denv=diff.tables > diff.tables/liquibase_log/liquibase_log_history-$(date +%Y%m%d%H%M%S).log
|
||||
```
|
||||
|
||||
### 3. liquibase diff.views script
|
||||
|
||||
```shell
|
||||
mvn liquibase:diff -Denv=diff.views -X > diff.views/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
|
||||
```
|
||||
|
||||
```shell
|
||||
sed -i 's/JSONB DEFAULT \x7B\x7D/\jsonb DEFAULT \x27\x7B\x7D\x27/g' changelog-dir/diff-changelog/*.sql
|
||||
sed -i 's/JSONB DEFAULT \[\]/\jsonb DEFAULT \x27\[\]\x27/g' changelog-dir/diff-changelog/*.sql
|
||||
sed -i 's/\x220001-01-01T00:00:00+00:00\x22/\x27\[\x220001-01-01T00:00:00+00:00\x22\]\x27/g' changelog-dir/diff-changelog/*.sql
|
||||
sed -i 's/JSONB DEFAULT \x7B\x7D/\jsonb DEFAULT \x27\x7B\x7D\x27\x3A\x3Ajsonb/g' changelog-dir/diff-changelog/*.sql
|
||||
sed -i 's/JSONB DEFAULT \[\]/\jsonb DEFAULT \x27\[\]\x27\x3A\x3Ajsonb/g' changelog-dir/diff-changelog/*.sql
|
||||
sed -i 's/\x3F/\x3F\x3F/g' changelog-dir/diff-changelog/*.sql
|
||||
```
|
||||
|
||||
```shell
|
||||
mv diff.views/changelog-dir/diff-changelog/*.sql diff.views/changelog-dir/update-changelog/
|
||||
```
|
||||
|
||||
```shell
|
||||
mvn liquibase:update -Denv=diff.views -X > diff.views/liquibase_log/liquibase_log_update-$(date +%Y%m%d%H%M%S).log
|
||||
```
|
||||
|
||||
```shell
|
||||
mvn liquibase:history -Denv=diff.views > diff.views/liquibase_log/liquibase_log_history-$(date +%Y%m%d%H%M%S).log
|
||||
```
|
||||
|
||||
```shell
|
||||
rm -rf diff.views/changelog-dir/update-changelog/*.sql
|
||||
```
|
||||
```
|
||||
@ -1,13 +0,0 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
|
||||
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
|
||||
|
||||
<includeAll path="cleanup.views/changelog-dir/cleanup_all_views"/>
|
||||
</databaseChangeLog>
|
||||
@ -1,10 +0,0 @@
|
||||
do $$ declare
|
||||
r record;
|
||||
begin
|
||||
for r in (select table_name from information_schema.tables where table_type = 'VIEW' and table_schema = 'public' and table_name != 'pg_stat_statements' and table_name != 'pg_stat_statements_info') loop
|
||||
execute 'drop view if exists public.' || quote_ident(r.table_name) || ' cascade';
|
||||
end loop;
|
||||
end $$;
|
||||
|
||||
DROP TABLE IF EXISTS liquibase.datachangelog_views;
|
||||
DROP TABLE IF EXISTS liquibase.datachangeloglock_views;
|
||||
@ -1,24 +0,0 @@
|
||||
url=jdbc:postgresql://10.2.5.46:5432/db01
|
||||
username=dbuser01
|
||||
password=QWEasd759
|
||||
driver=org.postgresql.Driver
|
||||
|
||||
|
||||
referenceUrl=jdbc:postgresql://10.2.5.47:5432/db01
|
||||
referenceUsername=dbuser01
|
||||
referencePassword=QWEasd759
|
||||
driver=org.postgresql.Driver
|
||||
|
||||
changeLogFile=cleanup.views/changelog-dir/changelog-master.xml
|
||||
liquibaseSchemaName=liquibase
|
||||
defaultSchemaName=public
|
||||
|
||||
|
||||
databaseChangeLogTableName=databasechangelog_cleanup
|
||||
databaseChangeLogLockTableName=databasechangeloglock_cleanup
|
||||
|
||||
diifTypes=views
|
||||
diffExcludeObjects=view:pg_stat_statements,view:pg_stat_statements_info
|
||||
|
||||
|
||||
|
||||
7
dev/liquibase.properties
Normal file
7
dev/liquibase.properties
Normal file
@ -0,0 +1,7 @@
|
||||
# username=dbuser01
|
||||
# password=QWEasd759
|
||||
# url=jdbc:postgresql://10.2.5.47:5432/db01
|
||||
# driver=org.postgresql.Driver
|
||||
# classpath=/opt/liquibase/postgresql-42.6.0.jar
|
||||
# changeLogFile=master.xml
|
||||
# liquibaseSchemaName=liquibase
|
||||
@ -1,15 +0,0 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
|
||||
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
|
||||
|
||||
<includeAll path="diff.tables/changelog-dir/function_before_create_tables"/>
|
||||
<includeAll path="diff.tables/changelog-dir/update-changelog"/>
|
||||
<includeAll path="diff.tables/changelog-dir/functions_after_create_tables"/>
|
||||
</databaseChangeLog>
|
||||
@ -1,24 +0,0 @@
|
||||
url=jdbc:postgresql://10.2.5.46:5432/db01
|
||||
username=dbuser01
|
||||
password=QWEasd759
|
||||
driver=org.postgresql.Driver
|
||||
|
||||
|
||||
referenceUrl=jdbc:postgresql://10.2.5.47:5432/db01
|
||||
referenceUsername=dbuser01
|
||||
referencePassword=QWEasd759
|
||||
driver=org.postgresql.Driver
|
||||
|
||||
changeLogFile=diff.views/changelog-dir/changelog-master.xml
|
||||
liquibaseSchemaName=liquibase
|
||||
defaultSchemaName=public
|
||||
|
||||
|
||||
databaseChangeLogTableName=databasechangelog_tables
|
||||
databaseChangeLogLockTableName=databasechangeloglock_tables
|
||||
|
||||
diifTypes=tables,columns,foreignkeys,primarykeys,uniqueconstraints
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
|
||||
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
|
||||
|
||||
|
||||
<includeAll path="diff.views/changelog-dir/drop_liquibase_tables"/>
|
||||
<includeAll path="diff.views/changelog-dir/function_before_create_views"/>
|
||||
<includeAll path="diff.views/changelog-dir/update-changelog"/>
|
||||
<includeAll path="diff.views/changelog-dir/functions_after_create_views"/>
|
||||
|
||||
|
||||
</databaseChangeLog>
|
||||
@ -1,2 +0,0 @@
|
||||
DROP TABLE IF EXISTS liquibase.datachangelog_cleanup;
|
||||
DROP TABLE IF EXISTS liquibase.datachangeloglock_cleanup;
|
||||
@ -1,24 +0,0 @@
|
||||
url=jdbc:postgresql://10.2.5.46:5432/db01
|
||||
username=dbuser01
|
||||
password=QWEasd759
|
||||
driver=org.postgresql.Driver
|
||||
|
||||
|
||||
referenceUrl=jdbc:postgresql://10.2.5.47:5432/db01
|
||||
referenceUsername=dbuser01
|
||||
referencePassword=QWEasd759
|
||||
driver=org.postgresql.Driver
|
||||
|
||||
changeLogFile=diff.views/changelog-dir/changelog-master.xml
|
||||
liquibaseSchemaName=liquibase
|
||||
defaultSchemaName=public
|
||||
|
||||
|
||||
databaseChangeLogTableName=databasechangelog_views
|
||||
databaseChangeLogLockTableName=databasechangeloglock_views
|
||||
|
||||
diifTypes=views
|
||||
diffExcludeObjects=view:pg_stat_statements,view:pg_stat_statements_info
|
||||
|
||||
|
||||
|
||||
127
pom.xml
127
pom.xml
@ -33,116 +33,83 @@
|
||||
<plugin>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-maven-plugin</artifactId>
|
||||
<version>${liquibase.version}</version>
|
||||
<version>4.17.0</version>
|
||||
<configuration>
|
||||
<propertyFile>${profile.propertyFile}</propertyFile>
|
||||
<changeLogFile>${profile.changeLogFile}</changeLogFile>
|
||||
<outputChangeLogFile>${profile.outputChangeLogFile}</outputChangeLogFile>
|
||||
<diffChangeLogFile>${profile.diffChangeLogFile}</diffChangeLogFile>
|
||||
<changeLogFile>prod/master.xml</changeLogFile>
|
||||
<driver>org.postgresql.Driver</driver>
|
||||
<username>dbuser01</username>
|
||||
<password>QWEasd759</password>
|
||||
<url>jdbc:postgresql://10.2.5.46:5432/db01</url>
|
||||
<referenceDriver>org.postgresql.Driver</referenceDriver>
|
||||
<referenceUrl>jdbc:postgresql://10.2.5.47:5432/db01</referenceUrl>
|
||||
<referenceUsername>dbuser01</referenceUsername>
|
||||
<referencePassword>QWEasd759</referencePassword>
|
||||
<goal>diff</goal>
|
||||
<dataDir>prod/data</dataDir>
|
||||
<driver>${profile.driver}</driver>
|
||||
<url>${profile.url}</url>
|
||||
<defaultSchemaName>${profile.defaultSchemaName}</defaultSchemaName>
|
||||
<changelogSchemaName>${profile.changelogSchemaName}</changelogSchemaName>
|
||||
<referenceDriver>${profile.drireferenceDriverver}</referenceDriver>
|
||||
<referenceUrl>${profile.referenceUrl}</referenceUrl>
|
||||
<referenceDefaultSchemaName>${profile.referenceDefaultSchemaName}</referenceDefaultSchemaName>
|
||||
<goal>${goal}</goal>
|
||||
<verbose>${profile.verbose}</verbose>
|
||||
<logging>${profile.logging}</logging>
|
||||
<verbose>true</verbose>
|
||||
<!-- <logging>debug</logging> -->
|
||||
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<!-- cleanup.views settings, -Denv=cleanup.views -->
|
||||
<profile>
|
||||
<id>cleanup.views</id>
|
||||
</project>
|
||||
<!-- <profiles> -->
|
||||
<!-- Development settings, -Denv=dev -->
|
||||
<!-- <profile>
|
||||
<id>dev</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>cleanup.views</value>
|
||||
<value>dev</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<profile.propertyFile>cleanup.views/liquibase.properties</profile.propertyFile>
|
||||
<changeLogFile>cleanup.views/changelog-dir/changelog-master.xml</changeLogFile>
|
||||
<outputChangeLogFile>cleanup.views/changelog-dir/changelog-master.xml</outputChangeLogFile>
|
||||
<diffChangeLogFile>cleanup.views/changelog-dir/diff.views.changelog/liquibase-diifChangeLog-${CI_JOB_NAME}_${CI_PIPLINE_ID}</diffChangeLogFile>
|
||||
<dataDir>cleanup.views/data</dataDir>
|
||||
<profile.propertyFile>dev/liquibase.properties</profile.propertyFile>
|
||||
<changeLogFile>dev/master.xml</changeLogFile>
|
||||
<driver>org.postgresql.Driver</driver>
|
||||
<username>dbuser01</username>
|
||||
<password>QWEasd759</password>
|
||||
<url>jdbc:postgresql://10.2.5.47:5432/db01</url>
|
||||
<defaultSchemaName>public</defaultSchemaName>
|
||||
<changelogSchemaName>liquibase</changelogSchemaName>
|
||||
<referenceDriver>org.postgresql.Driver</referenceDriver>
|
||||
<referenceUrl>jdbc:postgresql://10.2.5.46:5432/db01</referenceUrl>
|
||||
<referenceDefaultSchemaName>public</referenceDefaultSchemaName>
|
||||
<referenceUsername>dbuser01</referenceUsername>
|
||||
<referencePassword>QWEasd759</referencePassword>
|
||||
<goal>diff</goal>
|
||||
<dataDir>dev/data</dataDir>
|
||||
<verbose>true</verbose>
|
||||
<logging>debug</logging>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
|
||||
<!-- diff.tables settings, -Denv=diff.tables -->
|
||||
<profile>
|
||||
<id>diff.tables</id>
|
||||
</profile> -->
|
||||
<!-- Production settings, -Denv=prod -->
|
||||
<!-- <profile>
|
||||
<id>prod</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>diff.tables</value>
|
||||
<value>prod</value>
|
||||
</property>
|
||||
</activation>
|
||||
<activation>
|
||||
<configuration>
|
||||
<properties>
|
||||
<profile.propertyFile>diff.tables/liquibase.properties</profile.propertyFile>
|
||||
<changeLogFile>diff.tables/changelog-dir/changelog-master.xml</changeLogFile>
|
||||
<outputChangeLogFile>diff.tables/changelog-dir/changelog-master.xml</outputChangeLogFile>
|
||||
<diffChangeLogFile>diff.tables/changelog-dir/diff.changelog/liquibase-diifChangeLog-${CI_JOB_NAME}_${CI_PIPLINE_ID}</diffChangeLogFile>
|
||||
<dataDir>diff.tables/data</dataDir>
|
||||
<profile.propertyFile>prod/liquibase.properties</profile.propertyFile>
|
||||
<changeLogFile>dprod/master.xml</changeLogFile>
|
||||
<driver>org.postgresql.Driver</driver>
|
||||
<url>jdbc:postgresql://10.2.5.47:5432/db01</url>
|
||||
<defaultSchemaName>public</defaultSchemaName>
|
||||
<changelogSchemaName>liquibase</changelogSchemaName>
|
||||
<username>dbuser01</username>
|
||||
<password>QWEasd759</password>
|
||||
<url>jdbc:postgresql://10.2.5.46:5432/db01</url>
|
||||
<referenceDriver>org.postgresql.Driver</referenceDriver>
|
||||
<referenceUrl>jdbc:postgresql://10.2.5.46:5432/db01</referenceUrl>
|
||||
<referenceDefaultSchemaName>public</referenceDefaultSchemaName>
|
||||
<referenceUrl>jdbc:postgresql://10.2.5.47:5432/db01</referenceUrl>
|
||||
<referenceUsername>dbuser01</referenceUsername>
|
||||
<referencePassword>QWEasd759</referencePassword>
|
||||
<goal>diff</goal>
|
||||
<dataDir>prod/data</dataDir>
|
||||
<verbose>true</verbose>
|
||||
<logging>debug</logging>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- diff.views settings, -Denv=diff.views -->
|
||||
<profile>
|
||||
<id>diff.views</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>diff.views</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<profile.propertyFile>diff.views/liquibase.properties</profile.propertyFile>
|
||||
<changeLogFile>diff.views/changelog-dir/changelog-master.xml</changeLogFile>
|
||||
<outputChangeLogFile>diff.views/changelog-dir/changelog-master.xml</outputChangeLogFile>
|
||||
<diffChangeLogFile>diff.views/changelog-dir/diff.changelog/liquibase-diifChangeLog-${CI_JOB_NAME}_${CI_PIPLINE_ID}</diffChangeLogFile>
|
||||
<dataDir>diff.viewss/data</dataDir>
|
||||
<driver>org.postgresql.Driver</driver>
|
||||
<url>jdbc:postgresql://10.2.5.47:5432/db01</url>
|
||||
<defaultSchemaName>public</defaultSchemaName>
|
||||
<changelogSchemaName>liquibase</changelogSchemaName>
|
||||
<referenceDriver>org.postgresql.Driver</referenceDriver>
|
||||
<referenceUrl>jdbc:postgresql://10.2.5.46:5432/db01</referenceUrl>
|
||||
<referenceDefaultSchemaName>public</referenceDefaultSchemaName>
|
||||
<goal>diff</goal>
|
||||
<verbose>true</verbose>
|
||||
<logging>debug</logging>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
</configuration>
|
||||
</activation>
|
||||
</profile>-->
|
||||
<!-- </profiles> -->
|
||||
<!-- </project> -->
|
||||
13
prod/liquibase.properties
Normal file
13
prod/liquibase.properties
Normal file
@ -0,0 +1,13 @@
|
||||
# url=jdbc:postgresql://10.2.5.46:5432/db01
|
||||
# username=dbuser01
|
||||
# password=QWEasd759
|
||||
|
||||
# driver=org.postgresql.Driver
|
||||
# classpath=/opt/liquibase/postgresql-42.6.0.jar
|
||||
# changeLogFile=master.xml
|
||||
# liquibaseSchemaName=liquibase
|
||||
# defaultSchemaName=public
|
||||
|
||||
# referenceUrl=jdbc:postgresql://10.2.5.47:5432/db01
|
||||
# referenceUsername=dbuser01
|
||||
# referencePassword=QWEasd759
|
||||
25
target/liquibase/migrate.sql
Normal file
25
target/liquibase/migrate.sql
Normal file
@ -0,0 +1,25 @@
|
||||
-- *********************************************************************
|
||||
-- Update Database Script
|
||||
-- *********************************************************************
|
||||
-- Change Log: prod/master.xml
|
||||
-- Ran at: 17.04.2024, 17:39
|
||||
-- Against: dbuser01@jdbc:postgresql://10.2.5.46:5432/db01
|
||||
-- Liquibase version: 4.17.0
|
||||
-- *********************************************************************
|
||||
|
||||
SET SEARCH_PATH TO public, "$user","public";
|
||||
|
||||
-- Lock Database
|
||||
UPDATE databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'centos7-netcore (10.2.5.28)', LOCKGRANTED = NOW() WHERE ID = 1 AND LOCKED = FALSE;
|
||||
|
||||
SET SEARCH_PATH TO public, "$user","public";
|
||||
|
||||
SET SEARCH_PATH TO public, "$user","public";
|
||||
|
||||
-- Release Database Lock
|
||||
SET SEARCH_PATH TO public, "$user","public";
|
||||
|
||||
UPDATE databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
|
||||
|
||||
SET SEARCH_PATH TO public, "$user","public";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user