From 0d0a913466ee57082cae2e34196bd4592e2aee76 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 23 Jan 2025 09:39:02 +0100 Subject: [PATCH 1/6] create database only with office tables --- .../db/changelog/db.changelog-master.yaml | 76 ------------------- .../hsadminng/hs/migration/CsvDataImport.java | 4 + 2 files changed, 4 insertions(+), 76 deletions(-) diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index 2eb8908c..325c3c3e 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -51,37 +51,6 @@ databaseChangeLog: - include: file: db/changelog/1-rbac/1080-rbac-global.sql - - include: - file: db/changelog/2-rbactest/200-rbactest-schema.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/201-rbactest-customer/2010-rbactest-customer.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/202-rbactest-package/2020-rbactest-package.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/202-rbactest-package/2023-rbactest-package-rbac.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/203-rbactest-domain/2030-rbactest-domain.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/203-rbactest-domain/2033-rbactest-domain-rbac.sql - context: "!without-test-data" - - include: - file: db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql - context: "!without-test-data" - - include: file: db/changelog/5-hs-office/500-hs-office-schema.sql - include: @@ -167,51 +136,6 @@ databaseChangeLog: file: db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql context: "!without-test-data" - - include: - file: db/changelog/6-hs-booking/600-hs-booking-schema.sql - context: "!only-office" - - include: - file: db/changelog/6-hs-booking/610-booking-debitor/6100-hs-booking-debitor.sql - context: "!only-office" - - include: - file: db/changelog/6-hs-booking/620-booking-project/6200-hs-booking-project.sql - context: "!only-office" - - include: - file: db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql - context: "!only-office" - - include: - file: db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql - context: "!only-office and !without-test-data" - - include: - file: db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql - context: "!only-office" - - include: - file: db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql - context: "!only-office" - - include: - file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql - context: "!only-office and !without-test-data" - - - include: - file: db/changelog/7-hs-hosting/700-hs-hosting-schema.sql - context: "!only-office" - - include: - file: db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql - context: "!only-office" - - include: - file: db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql - context: "!only-office" - - include: - file: db/changelog/7-hs-hosting/701-hosting-asset/7016-hs-hosting-asset-migration.sql - context: "!only-office" - - include: - file: db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql - context: "!only-office and !without-test-data" - - - include: - file: db/changelog/9-hs-global/9000-statistics.sql - context: "!only-office" - - include: file: db/changelog/9-hs-global/9100-hs-integration-schema.sql - include: diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java index 811f3752..dd007c17 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java @@ -252,12 +252,14 @@ public class CsvDataImport extends ContextBasedTest { jpaAttempt.transacted(() -> { context(rbacSuperuser); // TODO.perf: could we instead skip creating test-data based on an env var? + /* em.createNativeQuery("delete from hs_hosting.asset where true").executeUpdate(); em.createNativeQuery("delete from hs_hosting.asset_ex where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.item where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.item_ex where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.project where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.project_ex where true").executeUpdate(); + */ em.createNativeQuery("delete from hs_office.coopassettx where true").executeUpdate(); em.createNativeQuery("delete from hs_office.coopassettx_legacy_id where true").executeUpdate(); em.createNativeQuery("delete from hs_office.coopsharetx where true").executeUpdate(); @@ -293,9 +295,11 @@ public class CsvDataImport extends ContextBasedTest { protected void deleteFromTestTables() { jpaAttempt.transacted(() -> { context(rbacSuperuser); + /* em.createNativeQuery("delete from rbactest.domain where true").executeUpdate(); em.createNativeQuery("delete from rbactest.package where true").executeUpdate(); em.createNativeQuery("delete from rbactest.customer where true").executeUpdate(); + */ }).assertSuccessful(); } -- 2.39.5 From e8e3b24fb958a882a4c2ae4ff4a557d8ab6b2e14 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Wed, 29 Jan 2025 09:24:35 +0100 Subject: [PATCH 2/6] fix name of changeset for mlmmj --- .../db/changelog/9-hs-global/9130-integration-mlmmj.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql index a7ab0d9e..22e814f0 100644 --- a/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql +++ b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql @@ -2,7 +2,7 @@ --liquibase formatted sql -- ============================================================================ ---changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--// +--changeset timotheus.pokorra:hs-global-integration-mlmmj endDelimiter:--// CREATE OR REPLACE VIEW hs_integration.subscription AS SELECT DISTINCT relation.mark as subscription, -- 2.39.5 From 27e4ba2f9e2ac15de9e80805a49bcda487004037 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 29 Jan 2025 16:51:02 +0100 Subject: [PATCH 3/6] automatically generate a new reference-SQL-dump --- .../0-base/009-check-environment.sql | 1 + .../9-hs-global/9130-integration-mlmmj.sql | 2 +- .../9999-liquibase-migration-test.sql | 14 ++ .../db/changelog/db.changelog-master.yaml | 4 + ...LiquibaseCompatibilityIntegrationTest.java | 175 +++++++++++------- ...prod-only-office-schema-with-test-data.sql | 109 +++++------ 6 files changed, 185 insertions(+), 120 deletions(-) create mode 100644 src/main/resources/db/changelog/9-hs-global/9999-liquibase-migration-test.sql diff --git a/src/main/resources/db/changelog/0-base/009-check-environment.sql b/src/main/resources/db/changelog/0-base/009-check-environment.sql index 8ee97f3b..09306308 100644 --- a/src/main/resources/db/changelog/0-base/009-check-environment.sql +++ b/src/main/resources/db/changelog/0-base/009-check-environment.sql @@ -1,5 +1,6 @@ --liquibase formatted sql +-- FIXME: check if we really need the restricted user -- ============================================================================ -- NUMERIC-HASH-FUNCTIONS diff --git a/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql index a7ab0d9e..22e814f0 100644 --- a/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql +++ b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql @@ -2,7 +2,7 @@ --liquibase formatted sql -- ============================================================================ ---changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--// +--changeset timotheus.pokorra:hs-global-integration-mlmmj endDelimiter:--// CREATE OR REPLACE VIEW hs_integration.subscription AS SELECT DISTINCT relation.mark as subscription, diff --git a/src/main/resources/db/changelog/9-hs-global/9999-liquibase-migration-test.sql b/src/main/resources/db/changelog/9-hs-global/9999-liquibase-migration-test.sql new file mode 100644 index 00000000..91ddcd1a --- /dev/null +++ b/src/main/resources/db/changelog/9-hs-global/9999-liquibase-migration-test.sql @@ -0,0 +1,14 @@ + +--liquibase formatted sql + +-- ============================================================================ +--changeset michael.hoennig:hs-global-liquibase-migration-test endDelimiter:--// +CREATE OR REPLACE VIEW hs_integration.subscription AS + SELECT DISTINCT + relation.mark as subscription, + contact.emailaddresses->>'main' as email + FROM hs_office.contact AS contact + JOIN hs_office.relation AS relation ON relation.contactuuid = contact.uuid AND relation.type = 'SUBSCRIBER' + ORDER BY subscription, email; + +--// diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index 2eb8908c..4cbc8cf4 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -220,3 +220,7 @@ databaseChangeLog: file: db/changelog/9-hs-global/9120-integration-znuny.sql - include: file: db/changelog/9-hs-global/9130-integration-mlmmj.sql + + - include: + file: db/changelog/9-hs-global/9999-liquibase-migration-test.sql + context: liquibase-migration-test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java index 30ab0505..811ddbc7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java @@ -1,10 +1,7 @@ package net.hostsharing.hsadminng.hs.migration; import liquibase.Liquibase; -import liquibase.exception.LiquibaseException; -import net.hostsharing.hsadminng.context.Context; -import net.hostsharing.hsadminng.rbac.test.JpaAttempt; -import org.junit.jupiter.api.BeforeEach; +import lombok.SneakyThrows; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -13,86 +10,58 @@ import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.jdbc.Sql; +import org.testcontainers.containers.JdbcDatabaseContainer; +import org.testcontainers.jdbc.ContainerDatabaseDriver; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; import javax.sql.DataSource; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.commons.io.FileUtils.readFileToString; +import static org.apache.commons.io.FileUtils.write; +import static org.apache.commons.io.FileUtils.writeStringToFile; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_CLASS; -// TODO.impl: The reference-SQL-dump-generation needs to be automated // BLOG: Liquibase-migration-test (not before the reference-SQL-dump-generation is simplified) // HOWTO: generate the prod-reference-SQL-dump during a prod-release /** - * Tests, if the Liquibase scripts can be applied to a database ionitialized with schemas + * Tests, if the Liquibase scripts can be applied to a database which is already populated with schemas * and test-data from a previous version. * - *

The test needs a dump, ideally from the version of the lastest prod-release:

+ *

The test works as follows:

* *
    - *
  1. clean the database:
    - * pg-sql-reset - *
  2. - * - *
  3. restote the database from latest dump
    - *
    
    - *      docker exec -i hsadmin-ng-postgres psql -U postgres postgres \
    - *          
    - *
  4. - * - *
  5. run the missing migrations:
    - * gw bootRun --args='--spring.profiles.active=only-office' - *
  6. - * - *
  7. create the reference-schema SQL-file with some initializations:
  8. - *
    
    - * cat >src/test/resources/db/prod-only-office-schema-with-test-data.sql <
    - * - * - *
  9. add the dump to that reference-schema SQL-file:

    - *
    docker exec -i hsadmin-ng-postgres /usr/bin/pg_dump \
    - * --column-inserts --disable-dollar-quoting -U postgres postgres \
    - * >>src/test/resources/db/prod-only-office-schema-with-test-data.sql
    - * 
    - *
  10. + *
  11. the database is initialized by `db/prod-only-office-schema-with-test-data.sql` from the test-resources
  12. + *
  13. the current Liquibase-migrations (only-office but with-test-data) are performed
  14. + *
  15. a new dump is written to `db/prod-only-office-schema-with-test-data.sql` in the build-directory
  16. + *
  17. an extra Liquibase-changeset (liquibase-migration-test) is applied
  18. + *
  19. it's asserted that the extra changeset got applied
  20. *
* - *

The generated dump has to be committed to git and will be used in future test-runs - * until it gets replaced at the next release.

+ *

During a release, the generated dump has to be committed to git and will be used in future test-runs + * until it gets replaced with a new dump at the next release.

*/ @Tag("officeIntegrationTest") @DataJpaTest(properties = { + "spring.datasource.url=jdbc:tc:postgresql:15.5-bookworm:///liquibaseMigrationTestTC", "spring.liquibase.enabled=false" // @Sql should go first, Liquibase will be initialized programmatically }) @DirtiesContext @ActiveProfiles("liquibase-migration-test") -@Import({ Context.class, JpaAttempt.class, LiquibaseConfig.class }) +@Import(LiquibaseConfig.class) @Sql(value = "/db/prod-only-office-schema-with-test-data.sql", executionPhase = BEFORE_TEST_CLASS) -public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { +public class LiquibaseCompatibilityIntegrationTest { - private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-hosting-SCHEMA"; + private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-global-liquibase-migration-test"; private static int initialChangeSetCount = 0; @Autowired @@ -101,20 +70,80 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { @Autowired private Liquibase liquibase; - @BeforeEach - public void setup() throws Exception { - assertThatDatabaseIsInitialized(); - runLiquibaseMigrations(); - } + @PersistenceContext + private EntityManager em; @Test - void test() { + void migrationWorksBasedOnAPreviouslyPopulatedSchema() { + // check the initial status from the @Sql-annotation + assertThatDatabaseIsInitializedWithLatestProdSchemasAndTestDataBySqlAnnotation(); + + // run the current migrations and dump the result to the build-directory + runLiquibaseMigrationsWithContexts("only-office", "with-test-data"); + dumpTo(new File("build/db/prod-only-office-schema-with-test-data.sql")); + + // then add another migration and test if it was applied + runLiquibaseMigrationsWithContexts("liquibase-migration-test"); final var liquibaseScripts = singleColumnSqlQuery("SELECT id FROM public.databasechangelog"); assertThat(liquibaseScripts).hasSizeGreaterThan(initialChangeSetCount); assertThat(liquibaseScripts).contains(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION); } - private void assertThatDatabaseIsInitialized() { + @SneakyThrows + private void dumpTo(final File targetFileName) { + makeDir(targetFileName.getParentFile()); + + final var jdbcDatabaseContainer = getJdbcDatabaseContainer(); + + final var sqlDumpFile = new File(targetFileName.getParent(), "." + targetFileName.getName()); + final var pb = new ProcessBuilder( + "pg_dump", "--column-inserts", "--disable-dollar-quoting", + "--host=" + getJdbcDatabaseContainer().getHost(), + "--port=" + jdbcDatabaseContainer.getFirstMappedPort(), + "--username=" + getJdbcDatabaseContainer().getUsername() , + "--dbname=" + jdbcDatabaseContainer.getDatabaseName(), + "--file=" + sqlDumpFile.getCanonicalPath() + ); + pb.environment().put("PGPASSWORD", getJdbcDatabaseContainer().getPassword()); + + final var process = pb.start(); + int exitCode = process.waitFor(); + final var stderr = new BufferedReader(new InputStreamReader(process.getErrorStream())) + .lines().collect(Collectors.joining("\n")); + assertThat(exitCode).describedAs(stderr).isEqualTo(0); + + final var header = """ + -- ================================================================================= + -- Generated reference-SQL-dump (hopefully of latest prod-release). + -- See: net.hostsharing.hsadminng.hs.migration.LiquibaseCompatibilityIntegrationTest + -- --------------------------------------------------------------------------------- + + -- + -- Explicit pre-initialization because we cannot use `pg_dump --create ...` + -- because the database is already created by Testcontainers. + -- + + CREATE ROLE postgres; + + CREATE ROLE admin; + GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO admin; + CREATE ROLE restricted; + GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO restricted; + + """; + writeStringToFile(targetFileName, header, UTF_8, false); // false = overwrite + + write(targetFileName, readFileToString(sqlDumpFile, UTF_8), UTF_8, true); + + assertThat(sqlDumpFile.delete()).describedAs(sqlDumpFile + " cannot be deleted"); + } + + private void makeDir(final File dir) { + assertThat(!dir.exists() || dir.isDirectory()).describedAs(dir + " does exist, but is not a directory").isTrue(); + assertThat(dir.isDirectory() || dir.mkdirs()).describedAs(dir + " cannot be created").isTrue(); + } + + private void assertThatDatabaseIsInitializedWithLatestProdSchemasAndTestDataBySqlAnnotation() { final var schemas = singleColumnSqlQuery("SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'"); assertThat(schemas).containsExactly("databasechangelog", "databasechangeloglock"); @@ -124,8 +153,11 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { initialChangeSetCount = liquibaseScripts.size(); } - private void runLiquibaseMigrations() throws LiquibaseException { - liquibase.update(new liquibase.Contexts(), new liquibase.LabelExpression()); + @SneakyThrows + private void runLiquibaseMigrationsWithContexts(final String... contexts) { + liquibase.update( + new liquibase.Contexts(contexts), + new liquibase.LabelExpression()); } private List singleColumnSqlQuery(final String sql) { @@ -133,4 +165,15 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { final var rows = (List) em.createNativeQuery(sql).getResultList(); return rows.stream().map(Objects::toString).toList(); } + + @SneakyThrows + private static JdbcDatabaseContainer getJdbcDatabaseContainer() { + final var getContainerMethod = ContainerDatabaseDriver.class.getDeclaredMethod("getContainer", String.class); + getContainerMethod.setAccessible(true); + + @SuppressWarnings("rawtypes") + final var container = (JdbcDatabaseContainer) getContainerMethod.invoke(null, + "jdbc:tc:postgresql:15.5-bookworm:///liquibaseMigrationTestTC"); + return container; + } } diff --git a/src/test/resources/db/prod-only-office-schema-with-test-data.sql b/src/test/resources/db/prod-only-office-schema-with-test-data.sql index cddf2c0d..7a76bc8b 100644 --- a/src/test/resources/db/prod-only-office-schema-with-test-data.sql +++ b/src/test/resources/db/prod-only-office-schema-with-test-data.sql @@ -20,7 +20,7 @@ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO restricted; -- -- Dumped from database version 15.5 (Debian 15.5-1.pgdg120+1) --- Dumped by pg_dump version 15.5 (Debian 15.5-1.pgdg120+1) +-- Dumped by pg_dump version 16.6 (Ubuntu 16.6-0ubuntu0.24.04.1) SET statement_timeout = 0; SET lock_timeout = 0; @@ -8477,7 +8477,7 @@ CREATE VIEW base.tx_journal_v AS ORDER BY txc.txtimestamp; -ALTER TABLE base.tx_journal_v OWNER TO postgres; +ALTER VIEW base.tx_journal_v OWNER TO postgres; -- -- Name: partner_legacy_id; Type: TABLE; Schema: hs_office; Owner: postgres @@ -8588,7 +8588,7 @@ UNION JOIN hs_office.person per ON ((per.uuid = relation.holderuuid))); -ALTER TABLE hs_integration.contact OWNER TO postgres; +ALTER VIEW hs_integration.contact OWNER TO postgres; -- -- Name: subscription; Type: VIEW; Schema: hs_integration; Owner: postgres @@ -8602,7 +8602,7 @@ CREATE VIEW hs_integration.subscription AS ORDER BY relation.mark, (contact.emailaddresses ->> 'main'::text); -ALTER TABLE hs_integration.subscription OWNER TO postgres; +ALTER VIEW hs_integration.subscription OWNER TO postgres; -- -- Name: ticket_customer_company; Type: VIEW; Schema: hs_integration; Owner: postgres @@ -8621,7 +8621,7 @@ CREATE VIEW hs_integration.ticket_customer_company AS ORDER BY (partner.partnernumber)::text; -ALTER TABLE hs_integration.ticket_customer_company OWNER TO postgres; +ALTER VIEW hs_integration.ticket_customer_company OWNER TO postgres; -- -- Name: ticket_customer_user; Type: VIEW; Schema: hs_integration; Owner: postgres @@ -8660,7 +8660,7 @@ CREATE VIEW hs_integration.ticket_customer_user AS GROUP BY c.contact_uuid; -ALTER TABLE hs_integration.ticket_customer_user OWNER TO postgres; +ALTER VIEW hs_integration.ticket_customer_user OWNER TO postgres; -- -- Name: time_customer; Type: VIEW; Schema: hs_integration; Owner: postgres @@ -8675,7 +8675,7 @@ CREATE VIEW hs_integration.time_customer AS JOIN hs_office.debitor debitor ON (((debitor.debitorreluuid = drel.uuid) AND (debitor.debitornumbersuffix = '00'::bpchar)))); -ALTER TABLE hs_integration.time_customer OWNER TO postgres; +ALTER VIEW hs_integration.time_customer OWNER TO postgres; -- -- Name: bankaccount_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -8687,7 +8687,7 @@ CREATE VIEW hs_office.bankaccount_iv AS FROM hs_office.bankaccount target; -ALTER TABLE hs_office.bankaccount_iv OWNER TO postgres; +ALTER VIEW hs_office.bankaccount_iv OWNER TO postgres; -- -- Name: grant; Type: TABLE; Schema: rbac; Owner: postgres @@ -8766,7 +8766,7 @@ CREATE VIEW hs_office.bankaccount_rv AS ORDER BY target.iban; -ALTER TABLE hs_office.bankaccount_rv OWNER TO postgres; +ALTER VIEW hs_office.bankaccount_rv OWNER TO postgres; -- -- Name: contact_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -8778,7 +8778,7 @@ CREATE VIEW hs_office.contact_iv AS FROM hs_office.contact target; -ALTER TABLE hs_office.contact_iv OWNER TO postgres; +ALTER VIEW hs_office.contact_iv OWNER TO postgres; -- -- Name: contact_legacy_id; Type: TABLE; Schema: hs_office; Owner: postgres @@ -8805,7 +8805,7 @@ CREATE SEQUENCE hs_office.contact_legacy_id_seq CACHE 1; -ALTER TABLE hs_office.contact_legacy_id_seq OWNER TO postgres; +ALTER SEQUENCE hs_office.contact_legacy_id_seq OWNER TO postgres; -- -- Name: contact_legacy_id_seq; Type: SEQUENCE OWNED BY; Schema: hs_office; Owner: postgres @@ -8862,7 +8862,7 @@ CREATE VIEW hs_office.contact_rv AS ORDER BY target.caption; -ALTER TABLE hs_office.contact_rv OWNER TO postgres; +ALTER VIEW hs_office.contact_rv OWNER TO postgres; -- -- Name: coopassettx_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -8874,7 +8874,7 @@ CREATE VIEW hs_office.coopassettx_iv AS FROM hs_office.coopassettx target; -ALTER TABLE hs_office.coopassettx_iv OWNER TO postgres; +ALTER VIEW hs_office.coopassettx_iv OWNER TO postgres; -- -- Name: coopassettx_legacy_id; Type: TABLE; Schema: hs_office; Owner: postgres @@ -8901,7 +8901,7 @@ CREATE SEQUENCE hs_office.coopassettx_legacy_id_seq CACHE 1; -ALTER TABLE hs_office.coopassettx_legacy_id_seq OWNER TO postgres; +ALTER SEQUENCE hs_office.coopassettx_legacy_id_seq OWNER TO postgres; -- -- Name: coopassettx_legacy_id_seq; Type: SEQUENCE OWNED BY; Schema: hs_office; Owner: postgres @@ -8962,7 +8962,7 @@ CREATE VIEW hs_office.coopassettx_rv AS ORDER BY target.reference; -ALTER TABLE hs_office.coopassettx_rv OWNER TO postgres; +ALTER VIEW hs_office.coopassettx_rv OWNER TO postgres; -- -- Name: coopsharetx_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -8974,7 +8974,7 @@ CREATE VIEW hs_office.coopsharetx_iv AS FROM hs_office.coopsharetx target; -ALTER TABLE hs_office.coopsharetx_iv OWNER TO postgres; +ALTER VIEW hs_office.coopsharetx_iv OWNER TO postgres; -- -- Name: coopsharetx_legacy_id; Type: TABLE; Schema: hs_office; Owner: postgres @@ -9001,7 +9001,7 @@ CREATE SEQUENCE hs_office.coopsharetx_legacy_id_seq CACHE 1; -ALTER TABLE hs_office.coopsharetx_legacy_id_seq OWNER TO postgres; +ALTER SEQUENCE hs_office.coopsharetx_legacy_id_seq OWNER TO postgres; -- -- Name: coopsharetx_legacy_id_seq; Type: SEQUENCE OWNED BY; Schema: hs_office; Owner: postgres @@ -9061,7 +9061,7 @@ CREATE VIEW hs_office.coopsharetx_rv AS ORDER BY target.reference; -ALTER TABLE hs_office.coopsharetx_rv OWNER TO postgres; +ALTER VIEW hs_office.coopsharetx_rv OWNER TO postgres; -- -- Name: debitor_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9077,7 +9077,7 @@ CREATE VIEW hs_office.debitor_iv AS FROM hs_office.debitor debitor; -ALTER TABLE hs_office.debitor_iv OWNER TO postgres; +ALTER VIEW hs_office.debitor_iv OWNER TO postgres; -- -- Name: debitor_rv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9132,7 +9132,7 @@ CREATE VIEW hs_office.debitor_rv AS ORDER BY target.defaultprefix; -ALTER TABLE hs_office.debitor_rv OWNER TO postgres; +ALTER VIEW hs_office.debitor_rv OWNER TO postgres; -- -- Name: membership_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9145,7 +9145,7 @@ CREATE VIEW hs_office.membership_iv AS JOIN hs_office.partner p ON ((p.uuid = m.partneruuid))); -ALTER TABLE hs_office.membership_iv OWNER TO postgres; +ALTER VIEW hs_office.membership_iv OWNER TO postgres; -- -- Name: membership_rv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9196,7 +9196,7 @@ CREATE VIEW hs_office.membership_rv AS ORDER BY target.validity; -ALTER TABLE hs_office.membership_rv OWNER TO postgres; +ALTER VIEW hs_office.membership_rv OWNER TO postgres; -- -- Name: partner_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9208,7 +9208,7 @@ CREATE VIEW hs_office.partner_iv AS FROM hs_office.partner target; -ALTER TABLE hs_office.partner_iv OWNER TO postgres; +ALTER VIEW hs_office.partner_iv OWNER TO postgres; -- -- Name: partner_details_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9222,7 +9222,7 @@ CREATE VIEW hs_office.partner_details_iv AS JOIN hs_office.partner_iv partner_iv ON ((partner_iv.uuid = partner.uuid))); -ALTER TABLE hs_office.partner_details_iv OWNER TO postgres; +ALTER VIEW hs_office.partner_details_iv OWNER TO postgres; -- -- Name: partner_details_rv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9274,7 +9274,7 @@ CREATE VIEW hs_office.partner_details_rv AS ORDER BY target.uuid; -ALTER TABLE hs_office.partner_details_rv OWNER TO postgres; +ALTER VIEW hs_office.partner_details_rv OWNER TO postgres; -- -- Name: partner_legacy_id_seq; Type: SEQUENCE; Schema: hs_office; Owner: postgres @@ -9289,7 +9289,7 @@ CREATE SEQUENCE hs_office.partner_legacy_id_seq CACHE 1; -ALTER TABLE hs_office.partner_legacy_id_seq OWNER TO postgres; +ALTER SEQUENCE hs_office.partner_legacy_id_seq OWNER TO postgres; -- -- Name: partner_legacy_id_seq; Type: SEQUENCE OWNED BY; Schema: hs_office; Owner: postgres @@ -9345,7 +9345,7 @@ CREATE VIEW hs_office.partner_rv AS ORDER BY ('P-'::text || target.partnernumber); -ALTER TABLE hs_office.partner_rv OWNER TO postgres; +ALTER VIEW hs_office.partner_rv OWNER TO postgres; -- -- Name: person_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9357,7 +9357,7 @@ CREATE VIEW hs_office.person_iv AS FROM hs_office.person target; -ALTER TABLE hs_office.person_iv OWNER TO postgres; +ALTER VIEW hs_office.person_iv OWNER TO postgres; -- -- Name: person_rv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9409,7 +9409,7 @@ CREATE VIEW hs_office.person_rv AS ORDER BY (concat(target.tradename, target.familyname, target.givenname)); -ALTER TABLE hs_office.person_rv OWNER TO postgres; +ALTER VIEW hs_office.person_rv OWNER TO postgres; -- -- Name: relation_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9425,7 +9425,7 @@ CREATE VIEW hs_office.relation_iv AS FROM hs_office.relation target; -ALTER TABLE hs_office.relation_iv OWNER TO postgres; +ALTER VIEW hs_office.relation_iv OWNER TO postgres; -- -- Name: relation_rv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9478,7 +9478,7 @@ CREATE VIEW hs_office.relation_rv AS WHERE (p.uuid = target.holderuuid)); -ALTER TABLE hs_office.relation_rv OWNER TO postgres; +ALTER VIEW hs_office.relation_rv OWNER TO postgres; -- -- Name: sepamandate_iv; Type: VIEW; Schema: hs_office; Owner: postgres @@ -9491,7 +9491,7 @@ CREATE VIEW hs_office.sepamandate_iv AS JOIN hs_office.bankaccount ba ON ((ba.uuid = sm.bankaccountuuid))); -ALTER TABLE hs_office.sepamandate_iv OWNER TO postgres; +ALTER VIEW hs_office.sepamandate_iv OWNER TO postgres; -- -- Name: sepamandate_legacy_id; Type: TABLE; Schema: hs_office; Owner: postgres @@ -9518,7 +9518,7 @@ CREATE SEQUENCE hs_office.sepamandate_legacy_id_seq CACHE 1; -ALTER TABLE hs_office.sepamandate_legacy_id_seq OWNER TO postgres; +ALTER SEQUENCE hs_office.sepamandate_legacy_id_seq OWNER TO postgres; -- -- Name: sepamandate_legacy_id_seq; Type: SEQUENCE OWNED BY; Schema: hs_office; Owner: postgres @@ -9576,7 +9576,7 @@ CREATE VIEW hs_office.sepamandate_rv AS ORDER BY target.validity; -ALTER TABLE hs_office.sepamandate_rv OWNER TO postgres; +ALTER VIEW hs_office.sepamandate_rv OWNER TO postgres; -- -- Name: databasechangelog; Type: TABLE; Schema: public; Owner: postgres @@ -9638,7 +9638,7 @@ CREATE VIEW rbac.global_iv AS FROM rbac.global target; -ALTER TABLE rbac.global_iv OWNER TO postgres; +ALTER VIEW rbac.global_iv OWNER TO postgres; -- -- Name: role; Type: TABLE; Schema: rbac; Owner: postgres @@ -9701,7 +9701,7 @@ CREATE VIEW rbac.grant_ev AS ORDER BY x.ascendingidname, x.descendingidname; -ALTER TABLE rbac.grant_ev OWNER TO postgres; +ALTER VIEW rbac.grant_ev OWNER TO postgres; -- -- Name: grant_rv; Type: VIEW; Schema: rbac; Owner: postgres @@ -9738,7 +9738,7 @@ CREATE VIEW rbac.grant_rv AS ORDER BY (((((g.objecttable)::text || '#'::text) || (g.objectidname)::text) || ':'::text) || g.roletype); -ALTER TABLE rbac.grant_rv OWNER TO postgres; +ALTER VIEW rbac.grant_rv OWNER TO postgres; -- -- Name: object_serialid_seq; Type: SEQUENCE; Schema: rbac; Owner: postgres @@ -9753,7 +9753,7 @@ CREATE SEQUENCE rbac.object_serialid_seq CACHE 1; -ALTER TABLE rbac.object_serialid_seq OWNER TO postgres; +ALTER SEQUENCE rbac.object_serialid_seq OWNER TO postgres; -- -- Name: object_serialid_seq; Type: SEQUENCE OWNED BY; Schema: rbac; Owner: postgres @@ -9783,7 +9783,7 @@ CREATE VIEW rbac.role_rv AS ORDER BY (((((unordered.objecttable)::text || '#'::text) || (unordered.objectidname)::text) || ':'::text) || unordered.roletype); -ALTER TABLE rbac.role_rv OWNER TO postgres; +ALTER VIEW rbac.role_rv OWNER TO postgres; -- -- Name: own_granted_permissions_rv; Type: VIEW; Schema: rbac; Owner: postgres @@ -9803,7 +9803,7 @@ CREATE VIEW rbac.own_granted_permissions_rv AS JOIN rbac.object o ON ((o.uuid = p.objectuuid))); -ALTER TABLE rbac.own_granted_permissions_rv OWNER TO postgres; +ALTER VIEW rbac.own_granted_permissions_rv OWNER TO postgres; -- -- Name: role_ev; Type: VIEW; Schema: rbac; Owner: postgres @@ -9826,7 +9826,7 @@ CREATE VIEW rbac.role_ev AS ORDER BY (((((unordered.objecttable)::text || '#'::text) || (unordered.objectidname)::text) || ':'::text) || unordered.roletype); -ALTER TABLE rbac.role_ev OWNER TO postgres; +ALTER VIEW rbac.role_ev OWNER TO postgres; -- -- Name: statistics_v; Type: VIEW; Schema: rbac; Owner: postgres @@ -9868,7 +9868,7 @@ CREATE VIEW rbac.statistics_v AS ORDER BY totals.no; -ALTER TABLE rbac.statistics_v OWNER TO postgres; +ALTER VIEW rbac.statistics_v OWNER TO postgres; -- -- Name: subject_ev; Type: VIEW; Schema: rbac; Owner: postgres @@ -9889,7 +9889,7 @@ CREATE VIEW rbac.subject_ev AS ORDER BY unordered.name; -ALTER TABLE rbac.subject_ev OWNER TO postgres; +ALTER VIEW rbac.subject_ev OWNER TO postgres; -- -- Name: subject_rv; Type: VIEW; Schema: rbac; Owner: postgres @@ -9911,7 +9911,7 @@ CREATE VIEW rbac.subject_rv AS ORDER BY unordered.name; -ALTER TABLE rbac.subject_rv OWNER TO postgres; +ALTER VIEW rbac.subject_rv OWNER TO postgres; -- -- Name: customer_iv; Type: VIEW; Schema: rbactest; Owner: postgres @@ -9923,7 +9923,7 @@ CREATE VIEW rbactest.customer_iv AS FROM rbactest.customer target; -ALTER TABLE rbactest.customer_iv OWNER TO postgres; +ALTER VIEW rbactest.customer_iv OWNER TO postgres; -- -- Name: customer_rv; Type: VIEW; Schema: rbactest; Owner: postgres @@ -9972,7 +9972,7 @@ CREATE VIEW rbactest.customer_rv AS ORDER BY target.reference; -ALTER TABLE rbactest.customer_rv OWNER TO postgres; +ALTER VIEW rbactest.customer_rv OWNER TO postgres; -- -- Name: domain_iv; Type: VIEW; Schema: rbactest; Owner: postgres @@ -9984,7 +9984,7 @@ CREATE VIEW rbactest.domain_iv AS FROM rbactest.domain target; -ALTER TABLE rbactest.domain_iv OWNER TO postgres; +ALTER VIEW rbactest.domain_iv OWNER TO postgres; -- -- Name: domain_rv; Type: VIEW; Schema: rbactest; Owner: postgres @@ -10032,7 +10032,7 @@ CREATE VIEW rbactest.domain_rv AS ORDER BY target.name; -ALTER TABLE rbactest.domain_rv OWNER TO postgres; +ALTER VIEW rbactest.domain_rv OWNER TO postgres; -- -- Name: package_iv; Type: VIEW; Schema: rbactest; Owner: postgres @@ -10044,7 +10044,7 @@ CREATE VIEW rbactest.package_iv AS FROM rbactest.package target; -ALTER TABLE rbactest.package_iv OWNER TO postgres; +ALTER VIEW rbactest.package_iv OWNER TO postgres; -- -- Name: package_rv; Type: VIEW; Schema: rbactest; Owner: postgres @@ -10093,7 +10093,7 @@ CREATE VIEW rbactest.package_rv AS ORDER BY target.name; -ALTER TABLE rbactest.package_rv OWNER TO postgres; +ALTER VIEW rbactest.package_rv OWNER TO postgres; -- -- Name: contact_legacy_id contact_id; Type: DEFAULT; Schema: hs_office; Owner: postgres @@ -12239,7 +12239,6 @@ INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, ordere INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('table-columns-function', 'michael.hoennig', 'db/changelog/0-base/007-table-columns.sql', '2025-01-27 15:34:15.169893', 8, 'EXECUTED', '9:bb868191fbe9c3ba4ac1f8bdc6a75f8c', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('RAISE-FUNCTIONS', 'michael.hoennig', 'db/changelog/0-base/008-raise-functions.sql', '2025-01-27 15:34:15.20423', 9, 'EXECUTED', '9:3ceaffba52919b6bfc90a902a944a616', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('ASSERT-FUNCTIONS', 'michael.hoennig', 'db/changelog/0-base/008-raise-functions.sql', '2025-01-27 15:34:15.229573', 10, 'EXECUTED', '9:a0ed7624c59909966e06875f59cfeccb', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); -INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('hash', 'michael.hoennig', 'db/changelog/0-base/009-check-environment.sql', '2025-01-27 15:34:15.243118', 11, 'EXECUTED', '9:96dd61dd12110d7d9973565ee6bd7230', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('context-DEFINE', 'michael.hoennig', 'db/changelog/0-base/010-context.sql', '2025-01-27 15:34:15.267304', 12, 'EXECUTED', '9:a8d195345229a2cd835f398b086ee21c', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('context-CURRENT-TASK', 'michael.hoennig', 'db/changelog/0-base/010-context.sql', '2025-01-27 15:34:15.283419', 13, 'EXECUTED', '9:4919efeac14bf86c57bed35de501a2b2', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('context-CURRENT-REQUEST', 'michael.hoennig', 'db/changelog/0-base/010-context.sql', '2025-01-27 15:34:15.306228', 14, 'EXECUTED', '9:d1c3bcc3a5b3468daa69e8ed0b324ea5', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); @@ -12272,7 +12271,6 @@ INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, ordere INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-base-QUERY-ACCESSIBLE-OBJECT-UUIDS', 'michael.hoennig', 'db/changelog/1-rbac/1050-rbac-base.sql', '2025-01-27 15:34:15.904223', 41, 'EXECUTED', '9:458e3f137c8fdeb9862e5d0e95b0094f', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-base-QUERY-GRANTED-PERMISSIONS', 'michael.hoennig', 'db/changelog/1-rbac/1050-rbac-base.sql', '2025-01-27 15:34:15.920227', 42, 'EXECUTED', '9:05bcbf6d56c95c400042f100c38637f0', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-base-QUERY-SUBJECTS-WITH-PERMISSION-FOR-OBJECT', 'michael.hoennig', 'db/changelog/1-rbac/1050-rbac-base.sql', '2025-01-27 15:34:15.934367', 43, 'EXECUTED', '9:ebd6a7182547ddcdb9217838c53e7d68', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); -INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-base-PGSQL-ROLES', 'michael.hoennig', 'db/changelog/1-rbac/1050-rbac-base.sql', '2025-01-27 15:34:15.94921', 44, 'EXECUTED', '9:0bbb758c0cecff303ca3ad6a3a64c4a8', 'sql', '', NULL, '4.29.2', '!external-db', NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-user-grant-GRANT-ROLE-TO-USER', 'michael.hoennig', 'db/changelog/1-rbac/1051-rbac-subject-grant.sql', '2025-01-27 15:34:15.973936', 45, 'EXECUTED', '9:7d0785b50901582050221d58ab11b1e2', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-user-grant-REVOKE-ROLE-FROM-USER', 'michael.hoennig', 'db/changelog/1-rbac/1051-rbac-subject-grant.sql', '2025-01-27 15:34:15.992179', 46, 'EXECUTED', '9:ce6e0a7157afbfdb482a432e2b6e3f43', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-user-grant-REVOKE-PERMISSION-FROM-ROLE', 'michael.hoennig', 'db/changelog/1-rbac/1051-rbac-subject-grant.sql', '2025-01-27 15:34:16.005262', 47, 'EXECUTED', '9:cab4dd9c2a2b8a2a746dfbf1f17946cb', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); @@ -12310,7 +12308,6 @@ INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, ordere INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-global-ADMIN-ROLE', 'michael.hoennig', 'db/changelog/1-rbac/1080-rbac-global.sql', '2025-01-27 15:34:16.519765', 79, 'EXECUTED', '9:b8ce7d33d7b7469614010953ee05ab83', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-global-GUEST-ROLE', 'michael.hoennig', 'db/changelog/1-rbac/1080-rbac-global.sql', '2025-01-27 15:34:16.531131', 80, 'EXECUTED', '9:f5f124a1d50c7b3b9816b554fbd12d11', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-global-ADMIN-USERS', 'michael.hoennig', 'db/changelog/1-rbac/1080-rbac-global.sql', '2025-01-27 15:34:16.550896', 81, 'EXECUTED', '9:defcefd72b25de449be69d3e3df7134b', 'sql', '', NULL, '4.29.2', '!without-test-data', NULL, '7988454941'); -INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-global-TEST', 'michael.hoennig', 'db/changelog/1-rbac/1080-rbac-global.sql', '2025-01-27 15:34:16.559083', 82, 'EXECUTED', '9:8e3fd77650d35f24e56b99ae54ba77f1', 'sql', '', NULL, '4.29.2', '!without-test-data', NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbactest-SCHEMA', 'michael.hoennig', 'db/changelog/2-rbactest/200-rbactest-schema.sql', '2025-01-27 15:34:16.567832', 83, 'EXECUTED', '9:d3ac51d27712286855b340c8a8966231', 'sql', '', NULL, '4.29.2', '!without-test-data', NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('test-customer-MAIN-TABLE', 'michael.hoennig', 'db/changelog/2-rbactest/201-rbactest-customer/2010-rbactest-customer.sql', '2025-01-27 15:34:16.601918', 84, 'EXECUTED', '9:c99c30902fec715c651b38cb2208aab4', 'sql', '', NULL, '4.29.2', '!without-test-data', NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbactest-customer-rbac-OBJECT', 'RbacObjectGenerator', 'db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql', '2025-01-27 15:34:16.614128', 85, 'EXECUTED', '9:fc4c1dd970025e35cb8f01ad15e979f9', 'sql', '', NULL, '4.29.2', '!without-test-data', NULL, '7988454941'); @@ -12515,6 +12512,10 @@ INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, ordere INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('hs-global-integration-kimai', 'timotheus.pokorra', 'db/changelog/9-hs-global/9110-integration-kimai.sql', '2025-01-27 15:34:20.362135', 284, 'EXECUTED', '9:56e481a555f86b471b74aaceacc4b520', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('hs-global-integration-znuny', 'timotheus.pokorra', 'db/changelog/9-hs-global/9120-integration-znuny.sql', '2025-01-27 15:34:20.413436', 285, 'EXECUTED', '9:48685a4882797575f8bb8c83d5fc9380', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('hs-global-integration-znuny', 'timotheus.pokorra', 'db/changelog/9-hs-global/9130-integration-mlmmj.sql', '2025-01-27 15:34:20.432305', 286, 'EXECUTED', '9:df6c8a724cfdd0c0aa013ba996655ed1', 'sql', '', NULL, '4.29.2', NULL, NULL, '7988454941'); +INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('hash', 'michael.hoennig', 'db/changelog/0-base/009-check-environment.sql', '2025-01-29 16:04:51.601962', 287, 'RERAN', '9:034a82679cf5cf1be4b9729c55621158', 'sql', '', NULL, '4.29.2', NULL, NULL, '8163091421'); +INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-base-PGSQL-ROLES', 'michael.hoennig', 'db/changelog/1-rbac/1050-rbac-base.sql', '2025-01-29 16:04:51.636353', 288, 'RERAN', '9:a50fd61a191459e25fb01f5fc079f3e7', 'sql', '', NULL, '4.29.2', '!external-db', NULL, '8163091421'); +INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('rbac-global-TEST', 'michael.hoennig', 'db/changelog/1-rbac/1080-rbac-global.sql', '2025-01-29 16:04:51.686383', 289, 'RERAN', '9:8e3fd77650d35f24e56b99ae54ba77f1', 'sql', '', NULL, '4.29.2', '!without-test-data', NULL, '8163091421'); +INSERT INTO public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) VALUES ('hs-global-integration-mlmmj', 'timotheus.pokorra', 'db/changelog/9-hs-global/9130-integration-mlmmj.sql', '2025-01-29 16:04:51.747314', 290, 'EXECUTED', '9:df6c8a724cfdd0c0aa013ba996655ed1', 'sql', '', NULL, '4.29.2', NULL, NULL, '8163091421'); -- @@ -17063,6 +17064,7 @@ GRANT ALL ON TABLE hs_office.sepamandate_rv TO restricted; -- GRANT ALL ON TABLE public.databasechangelog TO restricted; +GRANT ALL ON TABLE public.databasechangelog TO admin; -- @@ -17070,6 +17072,7 @@ GRANT ALL ON TABLE public.databasechangelog TO restricted; -- GRANT ALL ON TABLE public.databasechangeloglock TO restricted; +GRANT ALL ON TABLE public.databasechangeloglock TO admin; -- -- 2.39.5 From dbb162e0d1c9c1f56c8ae5a05b8e9721fea75125 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 29 Jan 2025 16:56:34 +0100 Subject: [PATCH 4/6] Revert "create database only with office tables" This reverts commit 0d0a913466ee57082cae2e34196bd4592e2aee76. --- .../db/changelog/db.changelog-master.yaml | 76 +++++++++++++++++++ .../hsadminng/hs/migration/CsvDataImport.java | 4 - 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index fc67bf3b..4cbc8cf4 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -51,6 +51,37 @@ databaseChangeLog: - include: file: db/changelog/1-rbac/1080-rbac-global.sql + - include: + file: db/changelog/2-rbactest/200-rbactest-schema.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/201-rbactest-customer/2010-rbactest-customer.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/202-rbactest-package/2020-rbactest-package.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/202-rbactest-package/2023-rbactest-package-rbac.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/203-rbactest-domain/2030-rbactest-domain.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/203-rbactest-domain/2033-rbactest-domain-rbac.sql + context: "!without-test-data" + - include: + file: db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql + context: "!without-test-data" + - include: file: db/changelog/5-hs-office/500-hs-office-schema.sql - include: @@ -136,6 +167,51 @@ databaseChangeLog: file: db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql context: "!without-test-data" + - include: + file: db/changelog/6-hs-booking/600-hs-booking-schema.sql + context: "!only-office" + - include: + file: db/changelog/6-hs-booking/610-booking-debitor/6100-hs-booking-debitor.sql + context: "!only-office" + - include: + file: db/changelog/6-hs-booking/620-booking-project/6200-hs-booking-project.sql + context: "!only-office" + - include: + file: db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql + context: "!only-office" + - include: + file: db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql + context: "!only-office and !without-test-data" + - include: + file: db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql + context: "!only-office" + - include: + file: db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql + context: "!only-office" + - include: + file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql + context: "!only-office and !without-test-data" + + - include: + file: db/changelog/7-hs-hosting/700-hs-hosting-schema.sql + context: "!only-office" + - include: + file: db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql + context: "!only-office" + - include: + file: db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql + context: "!only-office" + - include: + file: db/changelog/7-hs-hosting/701-hosting-asset/7016-hs-hosting-asset-migration.sql + context: "!only-office" + - include: + file: db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql + context: "!only-office and !without-test-data" + + - include: + file: db/changelog/9-hs-global/9000-statistics.sql + context: "!only-office" + - include: file: db/changelog/9-hs-global/9100-hs-integration-schema.sql - include: diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java index dd007c17..811f3752 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/CsvDataImport.java @@ -252,14 +252,12 @@ public class CsvDataImport extends ContextBasedTest { jpaAttempt.transacted(() -> { context(rbacSuperuser); // TODO.perf: could we instead skip creating test-data based on an env var? - /* em.createNativeQuery("delete from hs_hosting.asset where true").executeUpdate(); em.createNativeQuery("delete from hs_hosting.asset_ex where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.item where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.item_ex where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.project where true").executeUpdate(); em.createNativeQuery("delete from hs_booking.project_ex where true").executeUpdate(); - */ em.createNativeQuery("delete from hs_office.coopassettx where true").executeUpdate(); em.createNativeQuery("delete from hs_office.coopassettx_legacy_id where true").executeUpdate(); em.createNativeQuery("delete from hs_office.coopsharetx where true").executeUpdate(); @@ -295,11 +293,9 @@ public class CsvDataImport extends ContextBasedTest { protected void deleteFromTestTables() { jpaAttempt.transacted(() -> { context(rbacSuperuser); - /* em.createNativeQuery("delete from rbactest.domain where true").executeUpdate(); em.createNativeQuery("delete from rbactest.package where true").executeUpdate(); em.createNativeQuery("delete from rbactest.customer where true").executeUpdate(); - */ }).assertSuccessful(); } -- 2.39.5 From 5b85a9463eaa9e2c1b1826f6952e478ff2bb4778 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 29 Jan 2025 17:08:46 +0100 Subject: [PATCH 5/6] refactoring --- ...LiquibaseCompatibilityIntegrationTest.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java index 811ddbc7..d3cbb817 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java @@ -62,7 +62,6 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TE public class LiquibaseCompatibilityIntegrationTest { private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-global-liquibase-migration-test"; - private static int initialChangeSetCount = 0; @Autowired private DataSource dataSource; @@ -76,14 +75,29 @@ public class LiquibaseCompatibilityIntegrationTest { @Test void migrationWorksBasedOnAPreviouslyPopulatedSchema() { // check the initial status from the @Sql-annotation - assertThatDatabaseIsInitializedWithLatestProdSchemasAndTestDataBySqlAnnotation(); + final var initialChangeSetCount = assertProdReferenceStatusAfterRestore(); // run the current migrations and dump the result to the build-directory runLiquibaseMigrationsWithContexts("only-office", "with-test-data"); dumpTo(new File("build/db/prod-only-office-schema-with-test-data.sql")); - // then add another migration and test if it was applied + // then add another migration and assert if it was applied runLiquibaseMigrationsWithContexts("liquibase-migration-test"); + assertThatCurrentMigrationsGotApplied(initialChangeSetCount); + } + + private int assertProdReferenceStatusAfterRestore() { + final var schemas = singleColumnSqlQuery("SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'"); + assertThat(schemas).containsExactly("databasechangelog", "databasechangeloglock"); + + final var liquibaseScripts1 = singleColumnSqlQuery("SELECT * FROM public.databasechangelog"); + assertThat(liquibaseScripts1).hasSizeGreaterThan(285); + assertThat(liquibaseScripts1).doesNotContain(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION); + final var initialChangeSetCount = liquibaseScripts1.size(); + return initialChangeSetCount; + } + + private void assertThatCurrentMigrationsGotApplied(final int initialChangeSetCount) { final var liquibaseScripts = singleColumnSqlQuery("SELECT id FROM public.databasechangelog"); assertThat(liquibaseScripts).hasSizeGreaterThan(initialChangeSetCount); assertThat(liquibaseScripts).contains(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION); @@ -143,16 +157,6 @@ public class LiquibaseCompatibilityIntegrationTest { assertThat(dir.isDirectory() || dir.mkdirs()).describedAs(dir + " cannot be created").isTrue(); } - private void assertThatDatabaseIsInitializedWithLatestProdSchemasAndTestDataBySqlAnnotation() { - final var schemas = singleColumnSqlQuery("SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'"); - assertThat(schemas).containsExactly("databasechangelog", "databasechangeloglock"); - - final var liquibaseScripts = singleColumnSqlQuery("SELECT * FROM public.databasechangelog"); - assertThat(liquibaseScripts).hasSizeGreaterThan(285); - assertThat(liquibaseScripts).doesNotContain(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION); - initialChangeSetCount = liquibaseScripts.size(); - } - @SneakyThrows private void runLiquibaseMigrationsWithContexts(final String... contexts) { liquibase.update( -- 2.39.5 From fd94a12946abf1ccec5ce1d44b64293730f2ff53 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 30 Jan 2025 09:34:28 +0100 Subject: [PATCH 6/6] cleanup --- .../migration/LiquibaseCompatibilityIntegrationTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java index d3cbb817..64841f6e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/LiquibaseCompatibilityIntegrationTest.java @@ -112,13 +112,13 @@ public class LiquibaseCompatibilityIntegrationTest { final var sqlDumpFile = new File(targetFileName.getParent(), "." + targetFileName.getName()); final var pb = new ProcessBuilder( "pg_dump", "--column-inserts", "--disable-dollar-quoting", - "--host=" + getJdbcDatabaseContainer().getHost(), + "--host=" + jdbcDatabaseContainer.getHost(), "--port=" + jdbcDatabaseContainer.getFirstMappedPort(), - "--username=" + getJdbcDatabaseContainer().getUsername() , + "--username=" + jdbcDatabaseContainer.getUsername() , "--dbname=" + jdbcDatabaseContainer.getDatabaseName(), "--file=" + sqlDumpFile.getCanonicalPath() ); - pb.environment().put("PGPASSWORD", getJdbcDatabaseContainer().getPassword()); + pb.environment().put("PGPASSWORD", jdbcDatabaseContainer.getPassword()); final var process = pb.start(); int exitCode = process.waitFor(); @@ -138,11 +138,8 @@ public class LiquibaseCompatibilityIntegrationTest { -- CREATE ROLE postgres; - CREATE ROLE admin; - GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO admin; CREATE ROLE restricted; - GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO restricted; """; writeStringToFile(targetFileName, header, UTF_8, false); // false = overwrite -- 2.39.5