Update 6 files

- /cleanup.views/changelog-dir/cleanup_all_views/01_cleanup-allviews.sql
- /cleanup.views/changelog-dir/changelog-master.xml
- /diff.tables/changelog-dir/changelog-master.xml
- /diff.views/changelog-dir/changelog-master.xml
- /pom.xml
- /README.md
This commit is contained in:
pashko 2024-06-17 23:07:48 +00:00
parent 28d7981f4e
commit c9237c6d50
6 changed files with 137 additions and 54 deletions

View File

@ -66,17 +66,17 @@ mv diff.tables/changelog-dir/diff-changelog/*.sql diff.tables/changelog-dir/u
```
```shell
mvn liquibase:update -X > diff.tables/liquibase_log/liquibase_log_update-$(date +%Y%m%d%H%M%S).log
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 > diff.tables/liquibase_log/liquibase_log_history-$(date +%Y%m%d%H%M%S).log
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.tables/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
mvn liquibase:diff -Denv=diff.views -X > diff.views/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
```
```shell
@ -89,13 +89,17 @@ sed -i 's/\x3F/\x3F\x3F/g' changelog-dir/diff-changelog/*.sql
```
```shell
mv diff.tables/changelog-dir/diff-changelog/*.sql diff.tables/changelog-dir/update-changelog/
mv diff.views/changelog-dir/diff-changelog/*.sql diff.views/changelog-dir/update-changelog/
```
```shell
mvn liquibase:update -X > diff.tables/liquibase_log/liquibase_log_update-$(date +%Y%m%d%H%M%S).log
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 > diff.tables/liquibase_log/liquibase_log_history-$(date +%Y%m%d%H%M%S).log
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
```

View File

@ -0,0 +1,13 @@
<?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="changelog-dir/update-changelog/"/>
</databaseChangeLog>

View File

@ -0,0 +1,7 @@
do $$ declare
r record;
begin
for r in (select tablename from pg_tables where schemaname = 'my-schema-name') loop
execute 'drop table if exists public.' || quote_ident(r.tablename) || ' cascade';
end loop;
end $$;

View File

@ -0,0 +1,13 @@
<?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="changelog-dir/update-changelog/"/>
</databaseChangeLog>

View File

@ -0,0 +1,13 @@
<?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="changelog-dir/update-changelog/"/>
</databaseChangeLog>

127
pom.xml
View File

@ -33,83 +33,116 @@
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.17.0</version>
<version>${liquibase.version}</version>
<configuration>
<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>
<propertyFile>${profile.propertyFile}</propertyFile>
<changeLogFile>${profile.changeLogFile}</changeLogFile>
<outputChangeLogFile>${profile.outputChangeLogFile}</outputChangeLogFile>
<diffChangeLogFile>${profile.diffChangeLogFile}</diffChangeLogFile>
<dataDir>prod/data</dataDir>
<verbose>true</verbose>
<!-- <logging>debug</logging> -->
<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>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</plugin>
</plugins>
</build>
</project>
<!-- <profiles> -->
<!-- Development settings, -Denv=dev -->
<!-- <profile>
<id>dev</id>
<profiles>
<!-- cleanup.views settings, -Denv=cleanup.views -->
<profile>
<id>cleanup.views</id>
<activation>
<property>
<name>env</name>
<value>dev</value>
<value>cleanup.views</value>
</property>
</activation>
<properties>
<profile.propertyFile>dev/liquibase.properties</profile.propertyFile>
<changeLogFile>dev/master.xml</changeLogFile>
<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>
<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>
<referenceUsername>dbuser01</referenceUsername>
<referencePassword>QWEasd759</referencePassword>
<referenceDefaultSchemaName>public</referenceDefaultSchemaName>
<goal>diff</goal>
<dataDir>dev/data</dataDir>
<verbose>true</verbose>
<logging>debug</logging>
</properties>
</profile> -->
<!-- Production settings, -Denv=prod -->
<!-- <profile>
<id>prod</id>
</profile>
<!-- diff.tables settings, -Denv=diff.tables -->
<profile>
<id>diff.tables</id>
<activation>
<property>
<name>env</name>
<value>prod</value>
<value>diff.tables</value>
</property>
</activation>
<activation>
<configuration>
<properties>
<profile.propertyFile>prod/liquibase.properties</profile.propertyFile>
<changeLogFile>dprod/master.xml</changeLogFile>
<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>
<driver>org.postgresql.Driver</driver>
<username>dbuser01</username>
<password>QWEasd759</password>
<url>jdbc:postgresql://10.2.5.46:5432/db01</url>
<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.47:5432/db01</referenceUrl>
<referenceUsername>dbuser01</referenceUsername>
<referencePassword>QWEasd759</referencePassword>
<referenceUrl>jdbc:postgresql://10.2.5.46:5432/db01</referenceUrl>
<referenceDefaultSchemaName>public</referenceDefaultSchemaName>
<goal>diff</goal>
<dataDir>prod/data</dataDir>
<verbose>true</verbose>
<logging>debug</logging>
</properties>
</configuration>
</activation>
</profile>-->
<!-- </profiles> -->
<!-- </project> -->
</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>