Skip to content

Commit

Permalink
Adjust Flyway test to avoid using public schema
Browse files Browse the repository at this point in the history
The public schema is gone in recent PostgreSQL versions so let's not use
it anymore.
  • Loading branch information
gsmet committed Oct 30, 2024
1 parent 2bce110 commit 68c3a11
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public String returnInitSql() {
@GET
@Path("init-sql-result")
public Integer returnInitSqlResult() {
return (Integer) entityManager.createNativeQuery("SELECT f_my_constant()")
return (Integer) entityManager.createNativeQuery("SELECT TEST_SCHEMA.f_my_constant()")
.getSingleResult();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ quarkus.flyway.placeholders.foo=bar
quarkus.flyway.placeholders.title=REPLACED
quarkus.flyway.placeholder-prefix=#[
quarkus.flyway.placeholder-suffix=]
quarkus.flyway.init-sql=CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;CREATE OR REPLACE FUNCTION f_my_constant() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 100; END $func$;
quarkus.flyway.init-sql=CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;CREATE OR REPLACE FUNCTION TEST_SCHEMA.f_my_constant() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 100; END $func$;
quarkus.hibernate-orm.database.generation=validate

# second Agroal config
Expand All @@ -33,4 +33,4 @@ quarkus.flyway.second-datasource.locations=db/location3
quarkus.flyway.second-datasource.sql-migration-prefix=V
quarkus.flyway.second-datasource.migrate-at-start=true
quarkus.flyway.second-datasource.placeholders.mambo=poa

quarkus.flyway.second-datasource.init-sql=CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CREATE TABLE multiple_flyway_test

CREATE TABLE TEST_SCHEMA.multiple_flyway_test
(
id INT,
name VARCHAR(255)
);
INSERT INTO multiple_flyway_test(id, name)
INSERT INTO TEST_SCHEMA.multiple_flyway_test(id, name)
VALUES (1, 'Multiple flyway datasources should work seamlessly in JVM and native mode');
Original file line number Diff line number Diff line change
@@ -1 +1 @@
select count(1) from multiple_flyway_test;
select count(1) from TEST_SCHEMA.multiple_flyway_test;
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public void testPlaceholdersPrefixSuffix() {
}

@Test
@DisplayName("Returns whether the init-sql is CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;CREATE OR REPLACE FUNCTION f_my_constant() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 100; END $func$; or not")
@DisplayName("Returns whether the init-sql is CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;CREATE OR REPLACE FUNCTION TEST_SCHEMA.f_my_constant() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 100; END $func$; or not")
public void testReturnInitSql() {
when().get("/flyway/init-sql").then().body(is(
"CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;CREATE OR REPLACE FUNCTION f_my_constant() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 100; END $func$;"));
"CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;CREATE OR REPLACE FUNCTION TEST_SCHEMA.f_my_constant() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 100; END $func$;"));
}

@Test
Expand Down

0 comments on commit 68c3a11

Please sign in to comment.