Skip to content

Commit

Permalink
Allows to use specific datasource credentials for Liquibase
Browse files Browse the repository at this point in the history
Fixes #31214
  • Loading branch information
appiepollo14 committed Mar 30, 2024
1 parent cbe25cc commit 18a3664
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 30 deletions.
17 changes: 0 additions & 17 deletions integration-tests/liquibase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-h2</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
Expand Down Expand Up @@ -84,19 +80,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-liquibase-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class LiquibaseFunctionalityResource {
LiquibaseFactory liquibaseFactory;

@Inject
@LiquibaseDataSource("it")
@LiquibaseDataSource("second")
LiquibaseFactory liquibaseSecondFactory;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ quarkus.datasource.username=sa
quarkus.datasource.password=sa
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

# PostGreSQL second datasource
quarkus.datasource."it".db-kind=postgresql
quarkus.datasource."it".devservices.init-script-path=db/second/initdb.sql
# Second datasource
quarkus.datasource.second.db-kind=h2
quarkus.datasource.second.username=sa
quarkus.datasource.second.password=sa
quarkus.datasource.second.jdbc.url=jdbc:h2:mem:second;INIT=RUNSCRIPT FROM 'src/main/resources/db/second/initdb.sql'

# Liquibase config properties
quarkus.liquibase.change-log=db/changeLog.xml
Expand All @@ -16,13 +18,13 @@ quarkus.liquibase.database-change-log-lock-table-name=changelog_lock
quarkus.liquibase.database-change-log-table-name=changelog

# Config for second datasource with different user / password
quarkus.liquibase."it".username=usr
quarkus.liquibase."it".password=pass
quarkus.liquibase."it".change-log=db/second/changeLog.xml
quarkus.liquibase."it".clean-at-start=false
quarkus.liquibase."it".migrate-at-start=false
quarkus.liquibase.second.username=usr
quarkus.liquibase.second.password=pass
quarkus.liquibase.second.change-log=db/second/changeLog.xml
quarkus.liquibase.second.clean-at-start=false
quarkus.liquibase.second.migrate-at-start=false
quarkus.hibernate-orm.validation.enabled=false
quarkus.hibernate-orm.datasource=it
quarkus.hibernate-orm.datasource=second

# Debug logging
#quarkus.log.console.level=DEBUG
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE USER usr with login password 'pass';
GRANT ALL ON DATABASE it TO usr;
CREATE USER IF NOT EXISTS usr PASSWORD 'pass' ADMIN;
GRANT ALL ON SCHEMA PUBLIC TO usr;
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void testLiquibaseUsingDedicatedUsernameAndPassword() {
"create-quarkus-table,insert-into-quarkus-table"));

when().get("/liquibase/created-by").then().body(is(
"usr"));
"USR"));
}

static void doTestLiquibaseQuarkusFunctionality(boolean isIncludeAllExpectedToWork) {
Expand Down

0 comments on commit 18a3664

Please sign in to comment.