From 1ae24dd2297cc164a2c33e88a9ba8168c56bc866 Mon Sep 17 00:00:00 2001 From: Armo777 Date: Thu, 29 Jan 2026 10:57:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=BC=D0=B8=D0=B3?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B5=D0=B9=20Liquibase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 11 + src/main/resources/application-dev.properties | 12 ++ .../resources/application-mysql.properties | 2 +- .../resources/application-postgres.properties | 2 +- .../resources/application-prod.properties | 1 + src/main/resources/application.properties | 21 +- .../db/changelog/db.changelog-dev-data.xml | 196 ++++++++++++++++++ .../db/changelog/db.changelog-master.xml | 15 ++ .../db/changelog/db.changelog-schema.xml | 153 ++++++++++++++ 9 files changed, 408 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/db.changelog-dev-data.xml create mode 100644 src/main/resources/db/changelog/db.changelog-master.xml create mode 100644 src/main/resources/db/changelog/db.changelog-schema.xml diff --git a/build.gradle b/build.gradle index 936ff1edb..8113feb9b 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,10 @@ ext.webjarsFontawesomeVersion = "4.7.0" ext.webjarsBootstrapVersion = "5.3.8" dependencies { + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'com.h2database:h2' + implementation 'org.liquibase:liquibase-core' + implementation 'org.springframework.boot:spring-boot-starter-liquibase' implementation 'org.springframework.boot:spring-boot-starter-cache' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' @@ -72,6 +76,13 @@ checkstyleNohttp { configFile = file('src/checkstyle/nohttp-checkstyle.xml') } +bootRun { + systemProperty "spring.profiles.active", "dev" + // отключаем AOT + dependsOn.removeAll { it.name.startsWith("processAot") } + dependsOn.removeAll { it.name.startsWith("compileAot") } +} + tasks.named("formatMain").configure { dependsOn("checkstyleMain") } tasks.named("formatMain").configure { dependsOn("checkstyleNohttp") } diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 000000000..1fe1cf788 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,12 @@ +spring.liquibase.contexts=dev +spring.liquibase.enabled=true +#spring.liquibase.run-on-startup=true +spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml + +spring.datasource.url=jdbc:h2:file:./data/testdb +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver + +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console 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..64099ddcc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,22 @@ # 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 +spring.sql.init.mode=never + +spring.profiles.active=dev + +spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver + +spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml +spring.liquibase.enabled=true +#spring.liquibase.run-on-startup=true + +logging.level.liquibase=DEBUG +logging.level.org.springframework.boot.autoconfigure.liquibase=DEBUG # Web spring.thymeleaf.mode=HTML diff --git a/src/main/resources/db/changelog/db.changelog-dev-data.xml b/src/main/resources/db/changelog/db.changelog-dev-data.xml new file mode 100644 index 000000000..accd4c2b4 --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-dev-data.xml @@ -0,0 +1,196 @@ + + + + + + + + + SELECT COUNT(*) FROM vets + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM specialties + + + + + + + + + + + + + SELECT COUNT(*) FROM vet_specialties + + + + + + + + + + + + + + + SELECT COUNT(*) FROM types + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM owners + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM pets + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM visits + + + + + + + + + + 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..21dd2b81b --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-master.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/src/main/resources/db/changelog/db.changelog-schema.xml b/src/main/resources/db/changelog/db.changelog-schema.xml new file mode 100644 index 000000000..04e657516 --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-schema.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +