From 7c7c6060d7f2cfd1443f4712095bef7069d3da88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BB=D0=B0=D1=88=D0=B5=D0=BD=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=A1=D1=82=D0=B0=D0=BD=D0=B8=D1=81=D0=BB=D0=B0=D0=B2?= Date: Wed, 24 Dec 2025 16:43:37 +0300 Subject: [PATCH] commit/task1 --- build.gradle | 1 + src/main/resources/application-dev.properties | 1 + .../resources/application-mysql.properties | 2 +- .../resources/application-postgres.properties | 2 +- .../resources/application-prod.properties | 1 + src/main/resources/application.properties | 10 +- .../resources/db/changelog/001-schema.xml | 172 ++++++++++ .../resources/db/changelog/002-data-dev.xml | 311 ++++++++++++++++++ .../db/changelog/db.changelog-master.xml | 13 + 9 files changed, 508 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/application-dev.properties create mode 100644 src/main/resources/application-prod.properties create mode 100644 src/main/resources/db/changelog/001-schema.xml create mode 100644 src/main/resources/db/changelog/002-data-dev.xml create mode 100644 src/main/resources/db/changelog/db.changelog-master.xml diff --git a/build.gradle b/build.gradle index e7540a9f5..1fa195e85 100644 --- a/build.gradle +++ b/build.gradle @@ -38,6 +38,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'javax.cache:cache-api' implementation 'jakarta.xml.bind:jakarta.xml.bind-api' + implementation 'org.springframework.boot:spring-boot-starter-liquibase' runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator' runtimeOnly "org.webjars:webjars-locator-lite:${webjarsLocatorLiteVersion}" runtimeOnly "org.webjars.npm:bootstrap:${webjarsBootstrapVersion}" diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 000000000..22df004ec --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1 @@ +spring.liquibase.contexts=dev diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index e23dfa605..870ba8444 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -4,4 +4,4 @@ spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic} spring.datasource.username=${MYSQL_USER:petclinic} spring.datasource.password=${MYSQL_PASS:petclinic} # SQL is written to be idempotent so this is safe -spring.sql.init.mode=always +spring.sql.init.mode=never diff --git a/src/main/resources/application-postgres.properties b/src/main/resources/application-postgres.properties index b265d7e5b..39ba0315c 100644 --- a/src/main/resources/application-postgres.properties +++ b/src/main/resources/application-postgres.properties @@ -4,4 +4,4 @@ spring.datasource.url=${POSTGRES_URL:jdbc:postgresql://localhost/petclinic} spring.datasource.username=${POSTGRES_USER:petclinic} spring.datasource.password=${POSTGRES_PASS:petclinic} # SQL is written to be idempotent so this is safe -spring.sql.init.mode=always +spring.sql.init.mode=never diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties new file mode 100644 index 000000000..c79578136 --- /dev/null +++ b/src/main/resources/application-prod.properties @@ -0,0 +1 @@ +spring.liquibase.contexts=prod diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 630c1145a..32b0b411b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,10 @@ # database init, supports mysql too -database=h2 -spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql -spring.sql.init.data-locations=classpath*:db/${database}/data.sql +#database=h2 +#spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql +#spring.sql.init.data-locations=classpath*:db/${database}/data.sql + +# --- Liquibase --- +spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml # Web spring.thymeleaf.mode=HTML @@ -21,6 +24,7 @@ management.endpoints.web.exposure.include=* logging.level.org.springframework=INFO # logging.level.org.springframework.web=DEBUG # logging.level.org.springframework.context.annotation=TRACE +logging.level.liquibase=INFO # Maximum time static resources should be cached spring.web.resources.cache.cachecontrol.max-age=12h diff --git a/src/main/resources/db/changelog/001-schema.xml b/src/main/resources/db/changelog/001-schema.xml new file mode 100644 index 000000000..062d6a762 --- /dev/null +++ b/src/main/resources/db/changelog/001-schema.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog/002-data-dev.xml b/src/main/resources/db/changelog/002-data-dev.xml new file mode 100644 index 000000000..4df0b5056 --- /dev/null +++ b/src/main/resources/db/changelog/002-data-dev.xml @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog/db.changelog-master.xml b/src/main/resources/db/changelog/db.changelog-master.xml new file mode 100644 index 000000000..af75f3697 --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-master.xml @@ -0,0 +1,13 @@ + + + + + + + +