Search code examples
amazon-redshiftliquibasebamboo

Liquibase - liquibaseSchemaName parameter not working with Redshift


I created a seperate schema in Redshift for my changelog tables:

CREATE SCHEMA liquibase_non_prd;

ALTER DEFAULT PRIVILEGES IN SCHEMA liquibase_non_prd GRANT ALL ON TABLES TO GROUP readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA liquibase_non_prd GRANT ALL ON TABLES TO GROUP readwrite;

Liquibase creates my log tables but not in desired schema. Instead, I see them in public.

In my db.config file I do use liquibaseSchemaName parameter to no success.

cat <<eof > liquibase.properties
driver: com.amazon.redshift.jdbc42.Driver
url: jdbc:redshift://${bamboo_secret_deploy_host}:${bamboo_secret_deploy_port}/dbname?sslmode=verify-full
username: ${bamboo_secret_redshift_non_production_deploy_username}
password: ${bamboo_secret_redshift_non_production_deploy_password}
changeLogFile: src/main/resources/db/changelog/db.config-development.yml
liquibaseSchemaName: liquibase_non_prd
contexts: !norun
databaseChangeLogTableName: chg_lg_t
databaseChangeLogLockTableName: chg_lg_lck_t
clearCheckSums: TRUE
eof

mv liquibase.properties ${bamboo_result_artifactId}-${bamboo_result_version}/src/main/resources

Am I missing something?

UPDT In my bamboo logs I found below entry:

build   05-Jul-2022 18:43:32    [INFO]   'liquibaseSchemaName' in properties file is not being used by this task.

Solution

  • Below queries ran in order fixed the issue:

    --run these ddls before first Liquibase run in target database
    CREATE SCHEMA IF NOT EXISTS liquibase_non_prd;
    
    GRANT ALL ON SCHEMA liquibase_non_prd TO GROUP readonly;
    GRANT ALL ON SCHEMA liquibase_non_prd TO GROUP readwrite;
    
    ALTER DEFAULT PRIVILEGES IN SCHEMA liquibase_non_prd GRANT ALL ON TABLES TO GROUP readonly;
    ALTER DEFAULT PRIVILEGES IN SCHEMA liquibase_non_prd GRANT ALL ON TABLES TO GROUP readwrite;
    
    
    --run these ddls after first Liquibase run in target database
    GRANT ALL ON TABLE  liquibase_non_prd.chg_lg_lck_t TO GROUP readonly;
    GRANT ALL ON TABLE  liquibase_non_prd.chg_lg_lck_t TO GROUP readwrite;
    
    GRANT ALL ON TABLE  liquibase_non_prd.chg_lg_t TO GROUP readonly;
    GRANT ALL ON TABLE  liquibase_non_prd.chg_lg_t TO GROUP readwrite;