{"id":483600,"date":"2026-06-15T03:07:24","date_gmt":"2026-06-15T03:07:24","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=483600"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=483600","title":{"rendered":"Spring Boot 4, Flyway \u0438 Postgres: \u043a\u0430\u043a \u043d\u0435 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u043f\u043e \u043d\u043e\u0433\u0430\u043c"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e Flyway \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432: \u043a\u0430\u043a \u0438\u0445 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0443\u0434\u0430 \u043a\u043b\u0430\u0441\u0442\u044c \u0438 \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430<code>flyway_schema_history<\/code>. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0437\u0430\u043a\u043e\u043f\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u0433\u043b\u0443\u0431\u0436\u0435 \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 Flyway \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 Flyway. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043d\u044e\u0430\u043d\u0441\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0447\u0442\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u044f\u0442 \u0438 \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b <code>spring-boot-starter-flyway<\/code> \u0438 <code>spring-boot-starter-flyway-test<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b <code>flyway-database-postgresql<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>transactional-lock<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a\u0438\u0435 \u0431\u043e\u043d\u0443\u0441\u043d\u044b\u0435 \u0444\u0438\u0447\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c flyway \u0432 spring boot \u0441\u0435\u0440\u0432\u0438\u0441\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c \u0447\u0435\u0441\u0442\u043d\u043e: \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u043a \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 Flyway \u0438 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0437\u0430\u0432\u0438\u0441\u0448\u0435\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0435\u0439. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0430\u043c\u0435\u0440\u0442\u0432\u043e \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043c\u043e\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0443. \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u043c \u0447\u0430\u0441\u044b \u0436\u0438\u0437\u043d\u0438.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c Flyway \u0432 Spring Boot 4.x \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e! \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0444\u0438\u0447\u0438.<\/p>\n<h3>Spring Boot 4.x \u0438 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u044b<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0431\u0430\u0437\u044b. \u0420\u0430\u043d\u044c\u0448\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c <code>flyway-core<\/code> + <code>flyway-database-postgresql<\/code> (\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440). \u041d\u043e \u0432 Spring Boot 4.x \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439: \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 main\/test starters. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <code>spring-boot-starter-flyway<\/code>, \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/github.com\/spring-projects\/spring-boot\/wiki\/Spring-Boot-4.0-Migration-Guide\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0449\u0435\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SB4<\/a>:<\/p>\n<pre><code class=\"kotlin\">dependencies {    implementation(\"org.springframework.boot:spring-boot-starter-flyway\")    runtimeOnly(\"org.flywaydb:flyway-database-postgresql\")    testImplementation(\"org.springframework.boot:spring-boot-starter-flyway-test\")}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 starter\u2019\u0430, \u0442\u0430\u043c \u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u0430:<\/p>\n<pre><code>spring-boot-starter-flyway \u251c\u2500 spring-boot-starter \u251c\u2500 spring-boot-starter-jdbc \u251c\u2500 spring-boot-flyway \u2514\u2500 spring-boot-jdbc<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Auto-configuration \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u0432 classpath \u0435\u0441\u0442\u044c <code>org.flywaydb.core.Flyway<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 <code>DataSource<\/code> \u0438\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 connection details \u0434\u043b\u044f Flyway;<\/p>\n<\/li>\n<li>\n<p><code>spring.flyway.enabled<\/code> \u043d\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e Boot \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>Flyway.configure()<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \u041e\u043d \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 <code>Flyway<\/code> bean \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 <code>DataSource<\/code> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <code>DataSource<\/code>, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f Flyway;<\/p>\n<\/li>\n<li>\n<p>\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 <code>spring.flyway.*<\/code> \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437 Spring context \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f callbacks \u0438 Java migrations;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 <code>FlywayConfigurationCustomizer<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u043d\u0441 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Flyway<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Spring Boot \u0441\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>Callbacks \u0438 Java migrations \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u0430\u043a Spring beans (\u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435). \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 callback \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d flyway-database-postgresql<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 Flyway \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0431\u0430\u0437 <a href=\"https:\/\/documentation.red-gate.com\/flyway\/reference\/database-driver-reference\/postgresql-database\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 plugin modules<\/a>.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<ul>\n<li>\n<p>\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 PostgreSQL database type \u043a\u0430\u043a Flyway plugin;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 PostgreSQL parser;<\/p>\n<\/li>\n<li>\n<p>\u0437\u043d\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 PostgreSQL DDL;<\/p>\n<\/li>\n<li>\n<p>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 statements \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 PostgreSQL advisory lock \u0434\u043b\u044f <code>flyway_schema_history<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>PostgreSQLConfigurationExtension<\/code>, \u043a\u0443\u0434\u0430 Spring Boot \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 <code>spring.flyway.postgresql.*<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>PostgreSQLParser<\/code> \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f <code>CREATE INDEX CONCURRENTLY<\/code>:<\/p>\n<pre><code class=\"java\">private static final Pattern CREATE_INDEX_CONCURRENTLY_REGEX =        Pattern.compile(\"^(CREATE|DROP)( UNIQUE)? INDEX CONCURRENTLY\");protected Boolean detectCanExecuteInTransaction(String simplifiedStatement, List&lt;Token&gt; keywords) {    if (CREATE_INDEX_CONCURRENTLY_REGEX.matcher(simplifiedStatement).matches() \/* ... *\/) {        return false;    }    \/\/ ...}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c Flyway \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 SQL \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 JDBC. \u041e\u043d \u043f\u0430\u0440\u0441\u0438\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f\u044b statements \u0438 \u0441\u0442\u0440\u043e\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f PostgreSQL, \u0433\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e DDL \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u0432\u043d\u0435 transaction block.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/h3>\n<p>\u0415\u0441\u043b\u0438 <code>spring.flyway.url<\/code> \u043d\u0435 \u0437\u0430\u0434\u0430\u043d, Boot \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 <code>DataSource<\/code>. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u044b:<\/p>\n<pre><code class=\"yaml\">spring:  flyway:    url: ${DATABASE_URL}    user: ${DATABASE_USERNAME}    password: ${DATABASE_PASSWORD}    default-schema: ${DATABASE_SCHEMA}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c \u2014 <code>{vendor}<\/code> \u0432 <code>locations<\/code>:<\/p>\n<pre><code class=\"yaml\">spring:  flyway:    locations:      - classpath:db\/migration\/common      - classpath:db\/migration\/{vendor}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 <code>FlywayAutoConfiguration.LocationResolver<\/code> Spring Boot \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 vendor \u043f\u043e JDBC URL \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 <code>{vendor}<\/code> \u043d\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0430\u0437\u044b. \u0414\u043b\u044f PostgreSQL \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <code>postgresql<\/code>. \u041f\u0440\u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 database-specific SQL. \u041d\u043e \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u044d\u0442\u0438\u043c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442: \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e PostgreSQL, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043f\u043a\u0430 <code>postgresql<\/code> \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u044e\u044e \u0438\u043b\u043b\u044e\u0437\u0438\u044e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0430\u0435\u0442 spring-boot-starter-flyway-test<\/h3>\n<p>\u0412 Spring Boot 4.x \u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f companion test starter. \u0414\u043b\u044f Flyway \u044d\u0442\u043e:<\/p>\n<pre><code class=\"kotlin\">testImplementation(\"org.springframework.boot:spring-boot-starter-flyway-test\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f:<\/p>\n<pre><code>spring-boot-starter-flywayspring-boot-starter-testspring-boot-starter-jdbc-test<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u0443\u044e test-\u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Boot, JDBC test support \u0438 \u0441\u0430\u043c Flyway starter. \u042d\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 Spring Boot 4.x: \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c starter\u2019\u044b \u0442\u0435\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0442\u0430\u043a \u0436\u0438\u0432\u0435\u0442 \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 Spring Boot: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e <code>spring-boot-starter-flyway-test<\/code> \u0435\u0434\u0432\u0430 \u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h3>\u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u0435\u0439\u0441: CREATE INDEX CONCURRENTLY<\/h3>\n<p>\u0412 PostgreSQL \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u041e\u0431\u044b\u0447\u043d\u044b\u0439 <code>CREATE INDEX<\/code> \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 production-\u0442\u0430\u0431\u043b\u0438\u0446 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 PostgreSQL \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442:<\/p>\n<pre><code class=\"sql\">CREATE INDEX CONCURRENTLY idx_orders_created_at     ON orders (created_at);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/sql-createindex.html\" rel=\"noopener noreferrer nofollow\">PostgreSQL 18 \u043f\u043e <code>CREATE INDEX<\/code><\/a> \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u044b: concurrent build \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 insert\/update\/delete, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0436\u0434\u0435\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c invalid index, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0438\u0442\u044c.<\/p>\n<p><strong>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: <\/strong><code><strong>CREATE INDEX CONCURRENTLY<\/strong><\/code><strong> \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 transaction block<\/strong>.<\/p>\n<p>Flyway \u044d\u0442\u043e \u0437\u043d\u0430\u0435\u0442. \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, PostgreSQL parser \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 statement \u043a\u0430\u043a non-transactional. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c\u0441\u044f: Flyway \u0443\u0432\u0438\u0434\u0435\u043b non-transactional migration \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0435\u0435 \u0432\u043d\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.<\/p>\n<p><strong>\u041d\u043e \u0435\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 lock \u0441\u0430\u043c\u043e\u0433\u043e Flyway.<\/strong><\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0435\u0439 Flyway \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443. \u0412 PostgreSQL \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f advisory lock. \u0412 <code>flyway-database-postgresql<\/code> \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code>org.flywaydb.database.postgresql.PostgreSQLAdvisoryLockTemplate<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"java\">public &lt;T&gt; T execute(Callable&lt;T&gt; callable) {    PostgreSQLConfigurationExtension extension =            configuration.getPluginRegister().getExact(PostgreSQLConfigurationExtension.class);    if (extension.isTransactionalLock()) {        return new TransactionalExecutionTemplate(jdbcTemplate.getConnection(), true)                .execute(() -&gt; execute(callable, this::tryLockTransactional));    } else {        try {            return execute(callable, this::tryLock);        } finally {            unlock(rethrow);        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0432\u043d\u0443\u0442\u0440\u0438:<\/p>\n<pre><code class=\"java\">SELECT pg_try_advisory_xact_lock(...)--\u0438\u043b\u0438SELECT pg_try_advisory_lock(...)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u0430\u044f. PostgreSQL advisory locks \u0431\u044b\u0432\u0430\u044e\u0442 transaction-level \u0438 session-level. \u0412 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/explicit-locking.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PostgreSQL 18<\/a> \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u0430\u043a: transaction-level lock \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0430 session-level lock \u0436\u0438\u0432\u0435\u0442 \u0434\u043e \u044f\u0432\u043d\u043e\u0433\u043e unlock \u0438\u043b\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438.<\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Flyway \u0434\u043b\u044f PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 transactional lock. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439: lock \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, rollback \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u0435\u0433\u043e. \u041d\u043e \u0434\u043b\u044f <code>CREATE INDEX CONCURRENTLY<\/code> \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e lock template \u0441\u0430\u043c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0432\u043e\u043a\u0440\u0443\u0433 \u0443\u0447\u0430\u0441\u0442\u043a\u0430, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e Flyway \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u0430\u043c\u0430 SQL-\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u0430 \u043a\u0430\u043a non-transactional, \u0432\u043d\u0435\u0448\u043d\u0438\u0439 transaction-level advisory lock \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b transaction block. \u0414\u043b\u044f PostgreSQL \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b <code>CREATE INDEX CONCURRENTLY<\/code> \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0432 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 Flyway \u0435\u0441\u0442\u044c PostgreSQL-specific \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430:<\/p>\n<pre><code class=\"yaml\">spring:  flyway:    postgresql:      transactional-lock: false<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u0447\u0438\u0441\u0442\u043e\u0433\u043e Flyway \u044d\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442:<\/p>\n<pre><code>flyway.postgresql.transactional.lock=false<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Redgate \u0432 <a href=\"https:\/\/documentation.red-gate.com\/flyway\/reference\/database-driver-reference\/postgresql-database\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e PostgreSQL<\/a> \u043f\u0440\u044f\u043c\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u0435\u0439\u0441: transactional lock \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 SQL statements, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 <code>CREATE INDEX CONCURRENTLY<\/code> \u2014 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 session-level lock.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Flyway \u0432\u0441\u0435 \u0435\u0449\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 advisory lock\u2019\u043e\u043c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 transaction-level lock. <code>CREATE INDEX CONCURRENTLY<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u043e\u0435 \u0435\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e transaction block.<\/p>\n<h4>\u041d\u0443\u0436\u043d\u043e \u043b\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0442\u044c transactional-lock: false<\/h4>\n<p>\u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043e\u0442\u0432\u0435\u0442: \u043d\u0435\u0442, \u043d\u043e \u0434\u043b\u044f PostgreSQL-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 online DDL \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0435, \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 transactional lock \u0445\u043e\u0440\u043e\u0448: \u043e\u043d \u043f\u0440\u043e\u0449\u0435 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439. \u042d\u0442\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 default.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0438\u043b\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441:<\/p>\n<ul>\n<li>\n<p><code>CREATE INDEX CONCURRENTLY<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>DROP INDEX CONCURRENTLY<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 <code>REINDEX<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>VACUUM<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>ALTER SYSTEM<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 PostgreSQL \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 transaction block,<\/p>\n<\/li>\n<\/ul>\n<p>\u0442\u043e <code>spring.flyway.postgresql.transactional-lock=false<\/code> \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u0442\u0430\u043a\u043e\u0439: session-level lock \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u044f\u0432\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f. Flyway \u0434\u0435\u043b\u0430\u0435\u0442 <code>pg_advisory_unlock(...)<\/code> \u0432 <code>finally<\/code>, \u0430 PostgreSQL \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 session locks \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u043e, \u043d\u043e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0447\u0438\u0441\u0442\u043e, \u043a\u0430\u043a transaction-level lock. \u0415\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0436\u0438\u0442\u044c \u0432 pool, \u0430 unlock \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043d\u0435 \u043f\u0440\u043e\u0448\u0435\u043b, lock \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0436\u0438\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b. \u042d\u0442\u043e \u0440\u0435\u0434\u043a\u0438\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 default \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0435\u0440\u0432\u0430\u0442\u0438\u0432\u043d\u044b\u043c.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c: <code>spring.flyway.execute-in-transaction=false<\/code> \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u044b\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u0435\u043c <code>postgresql.transactional-lock=false<\/code>. \u041f\u0435\u0440\u0432\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043c, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 Flyway \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SQL migrations \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0412\u0442\u043e\u0440\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043c, \u043a\u0430\u043a Flyway \u0431\u0435\u0440\u0435\u0442 lock \u0432\u043e\u043a\u0440\u0443\u0433 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0414\u043b\u044f <code>CREATE INDEX CONCURRENTLY<\/code> \u0432\u0430\u0436\u043d\u044b \u043e\u0431\u0430 \u0443\u0440\u043e\u0432\u043d\u044f, \u0438 \u043b\u043e\u0432\u0443\u0448\u043a\u0430 \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c.<\/p>\n<h4>group, mixed \u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/h4>\n<p>\u0412\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430 \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/p>\n<p><code>spring.flyway.group=true<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 Flyway \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435 pending migrations \u0432 \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0412 <a href=\"https:\/\/documentation.red-gate.com\/flyway\/reference\/configuration\/flyway-namespace\/flyway-group-setting\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Flyway<\/a> \u044d\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0431\u0430\u0437 \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 DDL transactions. PostgreSQL \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0432 \u0446\u0435\u043b\u043e\u043c \u0438\u043c\u0435\u0435\u0442, \u043d\u043e \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 statements. \u0415\u0441\u043b\u0438 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 pending migrations \u0435\u0441\u0442\u044c <code>CREATE INDEX CONCURRENTLY<\/code>, <code>group=true<\/code> \u043f\u043e\u0447\u0442\u0438 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p><code>spring.flyway.mixed=true<\/code> \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c transactional \u0438 non-transactional statements \u0432 \u043e\u0434\u043d\u043e\u0439 migration \u0438\u043b\u0438 migration group. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>false<\/code>, \u0438 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e. \u0415\u0441\u043b\u0438 Flyway \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u043c SQL-\u0444\u0430\u0439\u043b\u0435 \u0441\u043c\u0435\u0448\u0430\u043d\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0439 DDL \u0438 <code>CREATE INDEX CONCURRENTLY<\/code>, \u043e\u043d \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438 \u0441\u043a\u0430\u0436\u0435\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c. \u042d\u0442\u043e \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e rollback \u0443 \u0442\u0430\u043a\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u0438\u043b\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: non-transactional PostgreSQL statements \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"sql\">-- V12__add_orders_status.sqlALTER TABLE orders    ADD COLUMN status VARCHAR(32);-- V13__idx_orders_status_concurrently.sqlCREATE INDEX CONCURRENTLY IF NOT EXISTS idx_orders_status    ON orders (status);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e, \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c rollback-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u0449\u0435 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0438.<\/p>\n<p><code>spring.flyway.lock-retry-count<\/code> \u2014 \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u044f\u0434\u043e\u043c \u0441 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u043e\u0439. Flyway \u0431\u0435\u0440\u0435\u0442 lock, \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0415\u0441\u043b\u0438 lock \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u043e\u043d \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u043f\u043e\u043f\u044b\u0442\u043a\u0438. \u0412 <a href=\"https:\/\/documentation.red-gate.com\/flyway\/reference\/configuration\/flyway-namespace\/flyway-lock-retry-count-setting\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Flyway<\/a> default \u2014 <code>50<\/code>, \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0438\u0434\u0443\u0442 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u043e\u043a\u043e\u043b\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u0412 Kubernetes \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0449\u0438\u043c\u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u043c\u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0430\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f: \u043e\u0434\u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0430 \u043c\u0438\u0433\u0440\u0438\u0440\u0443\u0435\u0442, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0436\u0434\u0443\u0442 lock. \u0415\u0441\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u044f\u0436\u0435\u043b\u044b\u0435, 50 \u0441\u0435\u043a\u0443\u043d\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u043b\u043e.<\/p>\n<h3>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c<\/h3>\n<p><code>FlywayProperties<\/code> \u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u0414\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<h4>baseline-on-migrate<\/h4>\n<pre><code class=\"yaml\">spring:  flyway:    baseline-on-migrate: true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <code>baseline<\/code> \u043f\u0440\u0438 <code>migrate<\/code>, \u0435\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430 \u043d\u0435\u043f\u0443\u0441\u0442\u0430\u044f, \u043d\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b history \u0435\u0449\u0435 \u043d\u0435\u0442. \u0412 <a href=\"https:\/\/documentation.red-gate.com\/flyway\/reference\/configuration\/flyway-namespace\/flyway-baseline-on-migrate-setting\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e\u0442: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0434\u043e\u0431\u043d\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f Flyway \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e production-\u0431\u0430\u0437\u0443, \u043d\u043e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 safety net, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0435 \u0442\u043e\u0439 \u0431\u0430\u0437\u044b \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>baseline<\/code> command \u2014 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0445\u0435\u043c\u044b \u043a\u0430\u043a \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443;<\/p>\n<\/li>\n<li>\n<p>baseline migration \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u043e baseline migrations \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b: <a href=\"https:\/\/habr.com\/ru\/companies\/spring_aio\/articles\/880486\/\" rel=\"noopener noreferrer nofollow\">Flyway Baseline \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0432<\/a>. \u041f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 Boot \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e <code>baseline-on-migrate<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442 baseline \u0434\u043b\u044f \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u0431\u0435\u0437 history table.<\/p>\n<h4>clean-disabled<\/h4>\n<pre><code class=\"yaml\">spring:  flyway:    clean-disabled: true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 Spring Boot default \u2014 <code>true<\/code>, \u0438 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. <code>clean<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u0445\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 Flyway. \u0412 production \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438\u0437 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u201c\u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u201d. \u0414\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u0443 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c profile, \u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c <code>clean<\/code> \u0432 \u043e\u0431\u0449\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u043b.<\/p>\n<h4>out-of-order<\/h4>\n<pre><code class=\"yaml\">spring:  flyway:    out-of-order: true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043d\u0438\u0436\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0437\u0436\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, production \u0443\u0436\u0435 \u043d\u0430 <code>V10<\/code>, \u0430 \u0438\u0437 \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0435\u0439 \u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u0438\u0435\u0445\u0430\u043b\u0430 <code>V8_1<\/code>. \u0421 <code>out-of-order=false<\/code> Flyway \u043e\u0442\u043a\u0430\u0436\u0435\u0442\u0441\u044f. \u0421 <code>true<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442.<\/p>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c\u0438 release branches, \u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043c\u0435\u043d\u0435\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435 <code>out-of-order<\/code>, \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e release-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0430 \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u201c\u043a\u0430\u043a-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u043d\u0435\u0441\u0442\u0438\u201d \u0437\u0430\u0431\u044b\u0442\u044b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h4>validate-migration-naming<\/h4>\n<pre><code class=\"yaml\">spring:  flyway:    validate-migration-naming: true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Boot \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>false<\/code>. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u044f \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>true<\/code>: \u043b\u0443\u0447\u0448\u0435 \u0443\u043f\u0430\u0441\u0442\u044c \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438\u0437-\u0437\u0430 \u0444\u0430\u0439\u043b\u0430 <code>stupid_init.sql<\/code>, \u0447\u0435\u043c \u0442\u0438\u0445\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439.<\/p>\n<h4>ignore-migration-patterns<\/h4>\n<p>Default \u0432 Boot \u2014 <code>*:future<\/code>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e future migrations \u043d\u0435 \u0432\u0430\u043b\u044f\u0442 validation. Future migration \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 history table, \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u0432\u0441\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \u0422\u0430\u043a\u043e\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 rollback \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u043e\u0434\u0430.<\/p>\n<p>Default \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u0439 \u0434\u043b\u044f rolling deployments: \u0441\u0442\u0430\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u0438\u0432 \u0431\u0430\u0437\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u0436\u0435 \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f. \u041d\u043e \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u201c\u043a\u043e\u0434 \u0438 \u0431\u0430\u0437\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u201d, \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<h4>target<\/h4>\n<pre><code class=\"yaml\">spring:  flyway:    target: \"12\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044e, \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 Flyway \u0434\u043e\u043b\u0436\u0435\u043d \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 <code>latest<\/code>. \u041d\u043e <code>target<\/code> \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0442\u0435\u0441\u0442\u0430\u0445, \u043f\u0440\u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438 \u0432 \u0440\u0435\u0434\u043a\u0438\u0445 staged rollout \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0431\u0430\u0437\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<h4>placeholders<\/h4>\n<pre><code class=\"yaml\">spring:  flyway:    placeholders:      app_schema: app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"sql\">CREATE TABLE ${app_schema}.events(...);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439, \u043d\u043e \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 runtime-\u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a, \u0442\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0444\u0430\u0439\u043b \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0441\u0445\u0435\u043c\u0443 \u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u0445. \u0414\u043b\u044f \u0438\u043c\u0435\u043d \u0441\u0445\u0435\u043c\u044b, tablespace \u0438\u043b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 environment-specific \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u2014 \u043d\u0435\u0442.<\/p>\n<h4>callbacks<\/h4>\n<p>Flyway callbacks \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a lifecycle \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c: <code>beforeMigrate<\/code>, <code>afterMigrate<\/code>, <code>afterEachMigrate<\/code>, <code>beforeClean<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 <a href=\"https:\/\/documentation.red-gate.com\/flyway\/flyway-concepts\/callbacks\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u0441\u0440\u0435\u0434\u0438 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 materialized views, housekeeping \u0432\u0440\u043e\u0434\u0435 PostgreSQL <code>VACUUM<\/code>.<\/p>\n<p>\u0412 Spring Boot \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u044c SQL callbacks \u0432 configured callback locations.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c bean \u0442\u0438\u043f\u0430 <code>org.flywaydb.core.api.callback.Callback<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 Java callback:<\/p>\n<pre><code class=\"java\">@Componentclass MigrationMetricsCallback extends BaseCallback {    @Override    public boolean supports(Event event, Context context) {        return event == Event.AFTER_MIGRATE;    }    @Override    public void handle(Event event, Context context) {        \/\/ \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043c\u0435\u0442\u0440\u0438\u043a\u0443, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Callbacks \u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043d\u043e \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442\u044c. \u0425\u043e\u0440\u043e\u0448\u0438\u0439 callback \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041f\u043b\u043e\u0445\u043e\u0439 callback \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0445\u043e\u0434\u0438\u0442 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u043b\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 Spring beans, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0430\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0443\u0436\u0435 \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u044b.<\/p>\n<h4>skip-executing-migrations<\/h4>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f:<\/p>\n<pre><code class=\"yaml\">spring:  flyway:    skip-executing-migrations: true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u043d\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 Flyway \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c schema history, \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u042d\u0442\u043e \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u0435\u043b\u044c \u0438 \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u201c\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u044f\u0436\u0435\u043b\u044b\u0435 SQL\u201d. \u042d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440: \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f history table \u043f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0440\u0435\u0434\u043a\u0438\u0445 migration adoption \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c application startup \u0435\u043c\u0443 \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u0435\u0441\u0442\u043e.<\/p>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f PostgreSQL<\/h3>\n<p>\u0414\u043b\u044f Spring Boot 4.x \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 PostgreSQL \u044f \u0431\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430:<\/p>\n<pre><code class=\"yaml\">spring:  flyway:    enabled: true    url: ${DATABASE_URL}    user: ${DATABASE_USERNAME}    password: ${DATABASE_PASSWORD}    default-schema: ${DATABASE_SCHEMA}    locations:      - classpath:db\/migration    validate-on-migrate: true    validate-migration-naming: true    clean-disabled: true    postgresql:      transactional-lock: false<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0442 online DDL \u0438 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0435, <code>transactional-lock<\/code> \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c true. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 PostgreSQL \u043a\u0430\u043a PostgreSQL, \u0430 \u043d\u0435 \u043a\u0430\u043a \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0443\u044e SQL-\u0431\u0430\u0437\u0443, \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f <code>CONCURRENTLY<\/code>, <code>VACUUM<\/code>, <code>REINDEX<\/code> \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 non-transactional statements.<\/p>\n<h3>\u0413\u043b\u0430\u0432\u043d\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p><code>CREATE INDEX CONCURRENTLY<\/code> \u2014 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 SQL. PostgreSQL \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u044d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 transaction block. Flyway \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0435\u0435 \u043a\u0430\u043a non-transactional, \u043d\u043e PostgreSQL transactional advisory lock \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>spring.flyway.postgresql.transactional-lock=false<\/code> \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 lock \u043d\u0430 session-level \u0438 \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>FlywayProperties<\/code> \u0441\u0442\u043e\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0435 \u043f\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0435, \u0430 \u043f\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435. <code>baseline-on-migrate<\/code> \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 Flyway \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0431\u0430\u0437\u0443, \u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0437\u0430\u0449\u0438\u0442\u0443 \u043e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f. <code>clean-disabled=true<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f production default. <code>group<\/code> \u0438 <code>mixed<\/code> \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0431\u0430\u0437\u044b. <code>callbacks<\/code> \u0445\u043e\u0440\u043e\u0448\u0438 \u0434\u043b\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u043d\u043e \u043d\u0435 \u0434\u043b\u044f \u0441\u043a\u0440\u044b\u0442\u043e\u0439 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Flyway \u0432 Spring Boot 4.x \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043f\u0430\u043f\u043a\u0430 <code>db\/migration<\/code>. \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 database plugin, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, lock strategy, test runtime \u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u0432\u0430\u0448\u0435\u0439 \u0421\u0423\u0411\u0414.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1047382\/\">https:\/\/habr.com\/ru\/articles\/1047382\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e Flyway \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432: \u043a\u0430\u043a \u0438\u0445 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0443\u0434\u0430 \u043a\u043b\u0430\u0441\u0442\u044c \u0438 \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430flyway_schema_history. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0437\u0430\u043a\u043e\u043f\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u0433\u043b\u0443\u0431\u0436\u0435 \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 Flyway \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 Flyway. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043d\u044e\u0430\u043d\u0441\u043e\u0432:\u0447\u0442\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u044f\u0442 \u0438 \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b spring-boot-starter-flyway \u0438 spring-boot-starter-flyway-test;\u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b flyway-database-postgresql \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b;\u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 transactional-lock \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c;\u043a\u0430\u043a\u0438\u0435 \u0431\u043e\u043d\u0443\u0441\u043d\u044b\u0435 \u0444\u0438\u0447\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c flyway \u0432 spring boot \u0441\u0435\u0440\u0432\u0438\u0441\u0435.\u041f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c \u0447\u0435\u0441\u0442\u043d\u043e: \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u043a \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 Flyway \u0438 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0437\u0430\u0432\u0438\u0441\u0448\u0435\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0435\u0439. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0430\u043c\u0435\u0440\u0442\u0432\u043e \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043c\u043e\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0443. \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u043c \u0447\u0430\u0441\u044b \u0436\u0438\u0437\u043d\u0438.\u041f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c Flyway \u0432 Spring Boot 4.x \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e! \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0444\u0438\u0447\u0438.Spring Boot 4.x \u0438 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u044b\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0431\u0430\u0437\u044b. \u0420\u0430\u043d\u044c\u0448\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c flyway-core + flyway-database-postgresql (\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440). \u041d\u043e \u0432 Spring Boot 4.x \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439: \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 main\/test starters. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 spring-boot-starter-flyway, \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u043e\u0431\u0449\u0435\u0439 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SB4:dependencies {    implementation(&#171;org.springframework.boot:spring-boot-starter-flyway&#187;)    runtimeOnly(&#171;org.flywaydb:flyway-database-postgresql&#187;)    testImplementation(&#171;org.springframework.boot:spring-boot-starter-flyway-test&#187;)}\u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 starter\u2019\u0430, \u0442\u0430\u043c \u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u0430:spring-boot-starter-flyway \u251c\u2500 spring-boot-starter \u251c\u2500 spring-boot-starter-jdbc \u251c\u2500 spring-boot-flyway \u2514\u2500 spring-boot-jdbcAuto-configuration \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445:\u0432 classpath \u0435\u0441\u0442\u044c org.flywaydb.core.Flyway;\u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 DataSource \u0438\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 connection details \u0434\u043b\u044f Flyway;spring.flyway.enabled \u043d\u0435 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d.\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e Boot \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Flyway.configure() \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \u041e\u043d \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 Flyway bean \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:\u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 DataSource \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 DataSource, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f Flyway;\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 spring.flyway.* \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a;\u0438\u0437 Spring context \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f callbacks \u0438 Java migrations;\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 FlywayConfigurationCustomizer \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u043d\u0441 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e;\u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 Flyway, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Spring Boot \u0441\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.Callbacks \u0438 Java migrations \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u0430\u043a Spring beans (\u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435). \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 callback \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d flyway-database-postgresql\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 Flyway \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0431\u0430\u0437 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 plugin modules.\u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c:\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 PostgreSQL database type \u043a\u0430\u043a Flyway plugin;\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 PostgreSQL parser;\u0437\u043d\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 PostgreSQL DDL;\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 statements \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438;\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 PostgreSQL advisory lock \u0434\u043b\u044f flyway_schema_history;\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 PostgreSQLConfigurationExtension, \u043a\u0443\u0434\u0430 Spring Boot \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 spring.flyway.postgresql.*.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 PostgreSQLParser \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f CREATE INDEX CONCURRENTLY:private static final Pattern CREATE_INDEX_CONCURRENTLY_REGEX =        Pattern.compile(&#171;^(CREATE|DROP)( UNIQUE)? INDEX CONCURRENTLY&#187;);protected Boolean detectCanExecuteInTransaction(String simplifiedStatement, List&lt;Token&gt; keywords) {    if (CREATE_INDEX_CONCURRENTLY_REGEX.matcher(simplifiedStatement).matches() \/* &#8230; *\/) {        return false;    }    \/\/ &#8230;}\u0422\u043e \u0435\u0441\u0442\u044c Flyway \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 SQL \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 JDBC. \u041e\u043d \u043f\u0430\u0440\u0441\u0438\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f\u044b statements \u0438 \u0441\u0442\u0440\u043e\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f PostgreSQL, \u0433\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e DDL \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u0432\u043d\u0435 transaction block.\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438\u0415\u0441\u043b\u0438 spring.flyway.url \u043d\u0435 \u0437\u0430\u0434\u0430\u043d, Boot \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 DataSource. \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u044b:spring:  flyway:    url: ${DATABASE_URL}    user: ${DATABASE_USERNAME}    password: ${DATABASE_PASSWORD}    default-schema: ${DATABASE_SCHEMA}\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c \u2014 {vendor} \u0432 locations:spring:  flyway:    locations:      &#8212; classpath:db\/migration\/common      &#8212; classpath:db\/migration\/{vendor}\u0412\u043d\u0443\u0442\u0440\u0438 FlywayAutoConfiguration.LocationResolver Spring Boot \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 vendor \u043f\u043e JDBC URL \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 {vendor} \u043d\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0430\u0437\u044b. \u0414\u043b\u044f PostgreSQL \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 postgresql. \u041f\u0440\u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 database-specific SQL. \u041d\u043e \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u044d\u0442\u0438\u043c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442: \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e PostgreSQL, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043f\u043a\u0430 postgresql \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u044e\u044e \u0438\u043b\u043b\u044e\u0437\u0438\u044e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u0438.\u0427\u0442\u043e \u0434\u0430\u0435\u0442 spring-boot-starter-flyway-test\u0412 Spring Boot 4.x \u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f companion test starter. \u0414\u043b\u044f Flyway \u044d\u0442\u043e:testImplementation(&#171;org.springframework.boot:spring-boot-starter-flyway-test&#187;)\u042d\u0442\u043e \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f:spring-boot-starter-flywayspring-boot-starter-testspring-boot-starter-jdbc-test\u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u0443\u044e test-\u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Boot, JDBC test support \u0438 \u0441\u0430\u043c Flyway starter. \u042d\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 Spring Boot 4.x: \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c starter\u2019\u044b \u0442\u0435\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u043c.\u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0442\u0430\u043a \u0436\u0438\u0432\u0435\u0442 \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 Spring Boot: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e spring-boot-starter-flyway-test \u0435\u0434\u0432\u0430 \u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.\u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u0435\u0439\u0441: CREATE INDEX CONCURRENTLY\u0412 PostgreSQL \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u041e\u0431\u044b\u0447\u043d\u044b\u0439 CREATE INDEX \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 production-\u0442\u0430\u0431\u043b\u0438\u0446 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 PostgreSQL \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442:CREATE INDEX CONCURRENTLY idx_orders_created_at     ON orders (created_at);\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PostgreSQL 18 \u043f\u043e CREATE INDEX \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u044b: concurrent build \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 insert\/update\/delete, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0436\u0434\u0435\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c invalid index, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0438\u0442\u044c.\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: CREATE INDEX CONCURRENTLY \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 transaction block.Flyway \u044d\u0442\u043e \u0437\u043d\u0430\u0435\u0442. \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, PostgreSQL parser \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 statement \u043a\u0430\u043a non-transactional. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c\u0441\u044f: Flyway \u0443\u0432\u0438\u0434\u0435\u043b non-transactional migration \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0435\u0435 \u0432\u043d\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.\u041d\u043e \u0435\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 lock \u0441\u0430\u043c\u043e\u0433\u043e Flyway.\u041f\u0435\u0440\u0435\u0434 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0435\u0439 Flyway \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0445\u0435\u043c\u0443. \u0412 PostgreSQL \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f advisory lock. \u0412 flyway-database-postgresql \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441:org.flywaydb.database.postgresql.PostgreSQLAdvisoryLockTemplate\u0421\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:public &lt;T&gt; T execute(Callable&lt;T&gt; callable) {    PostgreSQLConfigurationExtension extension =            configuration.getPluginRegister().getExact(PostgreSQLConfigurationExtension.class);    if (extension.isTransactionalLock()) {        return new TransactionalExecutionTemplate(jdbcTemplate.getConnection(), true)                .execute(() -&gt; execute(callable, this::tryLockTransactional));    } else {        try {            return execute(callable, this::tryLock);        } finally {            unlock(rethrow);        }    }}\u0410 \u0432\u043d\u0443\u0442\u0440\u0438:SELECT pg_try_advisory_xact_lock(&#8230;)&#8212;\u0438\u043b\u0438SELECT pg_try_advisory_lock(&#8230;)\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u0430\u044f. PostgreSQL advisory locks \u0431\u044b\u0432\u0430\u044e\u0442 transaction-level \u0438 session-level. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PostgreSQL 18 \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u0430\u043a: transaction-level lock \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0430 session-level lock \u0436\u0438\u0432\u0435\u0442 \u0434\u043e \u044f\u0432\u043d\u043e\u0433\u043e unlock \u0438\u043b\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438.\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Flyway \u0434\u043b\u044f PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 transactional lock. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439: lock \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, rollback \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u0435\u0433\u043e. \u041d\u043e \u0434\u043b\u044f CREATE INDEX CONCURRENTLY \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439.\u041f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e lock template \u0441\u0430\u043c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0432\u043e\u043a\u0440\u0443\u0433 \u0443\u0447\u0430\u0441\u0442\u043a\u0430, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e Flyway \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u0430\u043c\u0430 SQL-\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u0430 \u043a\u0430\u043a non-transactional, \u0432\u043d\u0435\u0448\u043d\u0438\u0439 transaction-level advisory lock \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b transaction block. \u0414\u043b\u044f PostgreSQL \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b CREATE INDEX CONCURRENTLY \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0432 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435.\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 Flyway \u0435\u0441\u0442\u044c PostgreSQL-specific \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430:spring:  flyway:    postgresql:      transactional-lock: false\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u0447\u0438\u0441\u0442\u043e\u0433\u043e Flyway \u044d\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442:flyway.postgresql.transactional.lock=falseRedgate \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e PostgreSQL \u043f\u0440\u044f\u043c\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u0435\u0439\u0441: transactional lock \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 SQL statements, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 CREATE INDEX CONCURRENTLY \u2014 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 session-level lock.\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Flyway \u0432\u0441\u0435 \u0435\u0449\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 advisory lock\u2019\u043e\u043c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 transaction-level lock. CREATE INDEX CONCURRENTLY \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u043e\u0435 \u0435\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e transaction block.\u041d\u0443\u0436\u043d\u043e \u043b\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0442\u044c transactional-lock: false\u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043e\u0442\u0432\u0435\u0442: \u043d\u0435\u0442, \u043d\u043e \u0434\u043b\u044f PostgreSQL-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 online DDL \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430.\u0415\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u0441\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0435, \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 transactional lock \u0445\u043e\u0440\u043e\u0448: \u043e\u043d \u043f\u0440\u043e\u0449\u0435 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439. \u042d\u0442\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 default.\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0438\u043b\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441:CREATE INDEX CONCURRENTLY;DROP INDEX CONCURRENTLY;\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 REINDEX;VACUUM;ALTER SYSTEM;\u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 PostgreSQL \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 transaction block,\u0442\u043e spring.flyway.postgresql.transactional-lock=false \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.\u041a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u0442\u0430\u043a\u043e\u0439: session-level lock \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u044f\u0432\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f. Flyway \u0434\u0435\u043b\u0430\u0435\u0442 pg_advisory_unlock(&#8230;) \u0432 finally, \u0430 PostgreSQL \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 session locks \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u043e, \u043d\u043e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0447\u0438\u0441\u0442\u043e, \u043a\u0430\u043a transaction-level lock. \u0415\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0436\u0438\u0442\u044c \u0432 pool, \u0430 unlock \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043d\u0435 \u043f\u0440\u043e\u0448\u0435\u043b, lock \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0436\u0438\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b. \u042d\u0442\u043e \u0440\u0435\u0434\u043a\u0438\u0439&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-483600","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/483600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483600"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/483600\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}