Compare commits

...

4 Commits

Author SHA1 Message Date
pashko
cf65fb13e3 Update 3 files
- /cleanup.views/liquibase.properties
- /diff.tables/liquibase.properties
- /diff.views/liquibase.properties
2024-06-17 23:36:53 +00:00
pashko
b0884ade14 Update 5 files
- /diff.views/changelog-dir/drop_liquibase_tables/02_drop_liquibase_tables_ceanup.sql
- /diff.views/changelog-dir/changelog-master.xml
- /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
2024-06-17 23:26:16 +00:00
pashko
c9237c6d50 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
2024-06-17 23:07:48 +00:00
pashko
28d7981f4e Update 12 files
- /target/liquibase/migrate.sql
- /prod/liquibase.properties
- /dev/liquibase.properties
- /README.md
- /cleanup.views/changelog-dir/changelog-master.xml
- /cleanup.views/changelog-dir/cleanup_all_views/01_cleanup-allviews.sql
- /cleanup.views/liquibase.properties
- /diff.tables/changelog-dir/changelog-master.xml
- /diff.tables/liquibase.properties
- /diff.views/changelog-dir/changelog-master.xml
- /diff.views/changelog-dir/drop_liquibase_tables/02_drop_liquibase_tables_ceanup.sql
- /diff.views/liquibase.properties
2024-06-17 21:39:46 +00:00
13 changed files with 248 additions and 94 deletions

View File

@ -49,7 +49,7 @@ mvn liquibase:update -Denv=cleanup.views
### 2. liquibase diff.tables script
```shell
mvn liquibase:diff -Denv=cleanup.tables -X > diff.tables/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
mvn liquibase:diff -Denv=diff.tables -X > diff.tables/liquibase_log/liquibase_log_diff-$(date +%Y%m%d%H%M%S).log
```
```shell
@ -66,5 +66,40 @@ 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
```

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="cleanup.views/changelog-dir/cleanup_all_views"/>
</databaseChangeLog>

View File

@ -0,0 +1,10 @@
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;

View File

@ -0,0 +1,24 @@
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

View File

@ -1,7 +0,0 @@
# 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

View File

@ -0,0 +1,15 @@
<?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>

View File

@ -0,0 +1,24 @@
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

View File

@ -0,0 +1,19 @@
<?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>

View File

@ -0,0 +1,2 @@
DROP TABLE IF EXISTS liquibase.datachangelog_cleanup;
DROP TABLE IF EXISTS liquibase.datachangeloglock_cleanup;

View File

@ -0,0 +1,24 @@
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
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>

View File

@ -1,13 +0,0 @@
# 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

View File

@ -1,25 +0,0 @@
-- *********************************************************************
-- 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";