database:liquibase
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| database:liquibase [2019/07/09 13:54] – skipidar | database:liquibase [2023/11/01 07:13] (current) – ↷ Page moved from business_process_management:camunda:database:liquibase to database:liquibase skipidar | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| </ | </ | ||
| - | == how it works== | + | === how it works=== |
| Liquibase stores all metadata in 2 tables: | Liquibase stores all metadata in 2 tables: | ||
| < | < | ||
| Line 16: | Line 16: | ||
| - | ==Syntax of the call== | + | ===Syntax of the call=== |
| + | |||
| + | == H2 == | ||
| * There is the syntax of the liquibase call. | * There is the syntax of the liquibase call. | ||
| * The Driver name: org.h2.Driver | * The Driver name: org.h2.Driver | ||
| Line 23: | Line 26: | ||
| liquibase --driver=org.h2.Driver --classpath=" | liquibase --driver=org.h2.Driver --classpath=" | ||
| </ | </ | ||
| + | |||
| + | == Postgres == | ||
| + | < | ||
| + | wget -O liquibase.tar.gz https:// | ||
| + | tar -xzvf liquibase.tar.gz | ||
| + | |||
| + | |||
| + | |||
| + | wget -O postgresql-jdbc4.jar https:// | ||
| + | |||
| + | chmod +x postgresql-jdbc4.jar | ||
| + | |||
| + | ./liquibase --driver=org.postgresql.Driver --classpath="/ | ||
| + | </ | ||
| + | |||
| + | |||
| == Example changeset== | == Example changeset== | ||
| Line 42: | Line 61: | ||
| </ | </ | ||
| - | < | + | < |
| <sqlFile dbms=" | <sqlFile dbms=" | ||
| encoding=" | encoding=" | ||
| Line 82: | Line 101: | ||
| https:// | https:// | ||
| </ | </ | ||
| + | |||
| + | |||
| + | == Debug == | ||
| + | < | ||
| + | # create a tunnel to the STAGE ssh jump server and the postgres db on STAGE | ||
| + | sudo ssh -i / | ||
| + | |||
| + | # connect the postgres database | ||
| + | psql -h localhost -p 9000 -U MyAdmin --dbname my_db | ||
| + | |||
| + | # PSQL password: | ||
| + | thepassword | ||
| + | |||
| + | # list schemas | ||
| + | select schema_name | ||
| + | from information_schema.schemata; | ||
| + | |||
| + | # list tables | ||
| + | \dt *.* | ||
| + | |||
| + | # show the liquibase history | ||
| + | SELECT * FROM databasechangelog; | ||
| + | |||
| + | # remove the liquibase history | ||
| + | DELETE FROM databasechangelog; | ||
| + | |||
| + | |||
| + | |||
| + | # MANUAL creation of the schema. DONT DO THAT | ||
| + | CREATE SCHEMA my_db; | ||
| + | |||
| + | # MANUAL REMOVAL of the schema. DONT DO THAT!!!!!!!!!!!!!!!!!!! | ||
| + | DROP SCHEMA my_db CASCADE; | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | === With Spring Boot === | ||
| + | |||
| + | |||
| + | == INit the DB at start == | ||
| + | |||
| + | To init the table - you only need the core **org.liquibase: | ||
| + | |||
| + | build.gradle | ||
| + | <sxh perl> | ||
| + | dependencies { | ||
| + | // liquibase | ||
| + | compile ' | ||
| + | |||
| + | // get the to the classpath which is needed but not loaded with " | ||
| + | compile group: ' | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | application.properties | ||
| + | <sxh perl> | ||
| + | # https:// | ||
| + | spring.datasource.driver-class-name=org.postgresql.Driver | ||
| + | spring.datasource.username=postgres | ||
| + | spring.datasource.password=postgres | ||
| + | spring.datasource.host=localhost | ||
| + | spring.datasource.port=5432 | ||
| + | spring.datasource.database=postgres | ||
| + | spring.datasource.url=jdbc: | ||
| + | |||
| + | |||
| + | |||
| + | # Liquibase without prefix | ||
| + | # | ||
| + | spring.liquibase.enabled=true | ||
| + | spring.liquibase.change-log=classpath:/ | ||
| + | spring.liquibase.default-schema=public | ||
| + | spring.liquibase.user=postgres | ||
| + | spring.liquibase.password=postgres | ||
| + | |||
| + | # will be taken from spring.* | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | </ | ||
| + | |||
| + | resources/ | ||
| + | < | ||
| + | databaseChangeLog: | ||
| + | - includeAll: | ||
| + | path: db/ | ||
| + | </ | ||
| + | |||
| + | resources/ | ||
| + | < | ||
| + | <?xml version=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <column name=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | | ||
| + | ... | ||
| + | </ | ||
| + | |||
database/liquibase.1562680455.txt.gz · Last modified: (external edit)
