Skip to content

Commit

Permalink
allow control over PostgreSQL transactional locks
Browse files Browse the repository at this point in the history
It is now possible to control the PostreSQL transactional locks, enabled by default since `flyway-core` version `9.1.2`.
This behaviour can cause issues during migrations - see flyway/flyway#3492 and flyway/flyway#3508 for more details.
The default is set to `true` to preserve the current behaviour.
  • Loading branch information
bzlat committed Oct 5, 2023
1 parent dd5ce66 commit b3349d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Used directly as the Flyway locations property. Comma-separated list of location
Custom Docker image name used as compatible substitute for default image name "postgres:14".
#### placeholders
Used as the Flyway placeholders property. Comma-separated list of key-value pairs in a form of "key=value". Defaults to empty map.
#### flyway.postgresql.transactional.lock
Boolean flag for enabling or disabling the `PostgreSQL` transactional locks, which were enabled by default in `flyway-core` version `9.1.2` and higher.
See https://github.com/flyway/flyway/issues/3492 for more details. Defaults to `true`
### Maven
Simply add the meta plugin as a dependency to jOOQ codegen maven plugin. The following example demonstrates the usage.
```xml
Expand Down Expand Up @@ -47,6 +50,8 @@ Simply add the meta plugin as a dependency to jOOQ codegen maven plugin. The fol
<value>postgres:14</value>
<key>placeholders</key>
<value>a=1,b=2</value>
<key>flyway.postgresql.transactional.lock</key>
<value>true</value>
</property>
</properties>
<includes>public.*</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class PostgresDDLDatabase extends PostgresDatabase {
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("postgres");
private static final String DEFAULT_TAG = "14";
private static final String KEY_VALUE_SEPARATOR = "=";
private static final String FLYWAY_POSTGRESQL_TRANSACTIONAL_LOCK = "flyway.postgresql.transactional.lock";

private Connection connection;
private PostgreSQLContainer<?> postgresContainer;
Expand Down Expand Up @@ -100,7 +101,12 @@ protected Connection connection() {
if (isBlank(defaultSchema)) {
defaultSchema = "public";
}

Map<String, String> flywayConfigProperties = Map.of(
FLYWAY_POSTGRESQL_TRANSACTIONAL_LOCK, getProperties().getProperty(FLYWAY_POSTGRESQL_TRANSACTIONAL_LOCK, "true"));

Flyway.configure()
.configuration(flywayConfigProperties)
.dataSource(postgresContainer.getJdbcUrl(), postgresContainer.getUsername(), postgresContainer.getPassword())
.locations(locations)
.schemas(defaultSchema)
Expand Down

0 comments on commit b3349d2

Please sign in to comment.