diff --git a/.github/workflows/dev-pytest.yml b/.github/workflows/dev-pytest.yml index 6454e9b9..c39b7429 100644 --- a/.github/workflows/dev-pytest.yml +++ b/.github/workflows/dev-pytest.yml @@ -43,46 +43,6 @@ jobs: - name: Test with pytest run: | pytest - - name: Setup SnowSQL - env: - SNOWSQL_MAJOR_VERSION: "1.2" - SNOWSQL_PATCH_VERSION: "28" - SNOWSQL_DOWNLOAD_DIR: "/home/runner/downloads" -# SNOWSQL_DEST: "/home/runner/.snowsql/bin" -# SNOWSQL_LOGIN_SHELL: "/home/runner/.profile" - MY_SNOWSQL_CONFIG_FILE: "/home/runner/.snowsql/config" - run: | - apt-get update -y && apt-get upgrade -y && apt-get install -y curl unzip bash - curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/${SNOWSQL_MAJOR_VERSION}/linux_x86_64/snowsql-${SNOWSQL_MAJOR_VERSION}.${SNOWSQL_PATCH_VERSION}-linux_x86_64.bash - bash snowsql-${SNOWSQL_MAJOR_VERSION}.${SNOWSQL_PATCH_VERSION}-linux_x86_64.bash - cat >$MY_SNOWSQL_CONFIG_FILE < config.toml @@ -101,15 +61,18 @@ jobs: # echo "Tested SnowCLI connection successfully!" # echo "Set default connection" # snow --config-file config.toml connection set-default "myconnection" - #- name: Test Basic Schemachange - # run: | - # schemachange --config-folder ./demo/setup/basics_demo - # schemachange --config-folder ./demo/basics - # schemachange --config-folder ./demo/teardown/basics_demo - #run: | - # snow --config-file config.toml sql -f ./demo/setup/setup_basics_demo.sql - # schemachange --config-folder ./demo/basics - # snow --config-file config.toml sql -f ./demo/teardown/teardown_basics_demo.sql + - name: Test Basic Schemachange + env: + MY_TARGET_SCHEMA: BASICS_DEMO_${{ env.SCHEMACHANGE_BUILD_ID }} + run: | + echo "Setting up ${MY_TARGET_SCHEMA}" + schemachange --config-folder ./demo/setup/basics_demo + echo "Testing Rendering to ${MY_TARGET_SCHEMA}" + echo "Work in Progress" + echo "Testing Deployment using ${MY_TARGET_SCHEMA}" + schemachange --config-folder ./demo/basics + echo "Tearing down up ${MY_TARGET_SCHEMA}" + schemachange --config-folder ./demo/teardown/basics_demo #- name: Test Citibike Demo # run: | # snow --config-file config.toml sql -f ./demo/setup/setup_citibike_demo.sql diff --git a/demo/basics/schemachange-config.yml b/demo/basics/schemachange-config.yml index 16b4e2be..6d4171bb 100644 --- a/demo/basics/schemachange-config.yml +++ b/demo/basics/schemachange-config.yml @@ -2,15 +2,10 @@ config-version: 1 root-folder: ./demo/basics -snowflake-user: {{ env_var('SNOWFLAKE_USER')}} -snowflake-account: {{ env_var('SNOWFLAKE_ACCOUNT')}} -snowflake-role: {{ env_var('SNOWFLAKE_ROLE')}} -snowflake-warehouse: {{ env_var('SNOWFLAKE_WAREHOUSE')}} -snowflake-database: {{ env_var('SNOWFLAKE_DATABASE')}} snowflake-schema: {{ env_var('MY_TARGET_SCHEMA')}} change-history-table: "{{ env_var('SNOWFLAKE_DATABASE')}}.{{ env_var('MY_TARGET_SCHEMA')}}.CHANGE_HISTORY" create-change-history-table: true vars: - database_name: {{env_var('SNOWFLAKE_DATABASE', 'SCHEMACHANGE_DEMO')}} - schema_name: {{env_var('SNOWFLAKE_SCHEMA', 'BASICS_DEMO')}} + database_name: {{env_var('SNOWFLAKE_DATABASE')}} + schema_name: {{env_var('MY_TARGET_SCHEMA')}} diff --git a/demo/setup/basics_demo.sql b/demo/setup/basics_demo/A__basics_demo.sql similarity index 96% rename from demo/setup/basics_demo.sql rename to demo/setup/basics_demo/A__basics_demo.sql index 323b2dba..a3308528 100644 --- a/demo/setup/basics_demo.sql +++ b/demo/setup/basics_demo/A__basics_demo.sql @@ -1,5 +1,5 @@ -SET TARGET_SCHEMA_NAME = '&{v_target_schema_name}'; -SET TARGET_DB_NAME = 'SCHEMACHANGE_DEMO'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking. +SET TARGET_SCHEMA_NAME = '{{ schema_name }}'; +SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking. -- Dependent Variables; Change the naming pattern if you want but not necessary SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas. SET DEPLOY_ROLE = $TARGET_DB_NAME || '_DEPLOY'; -- This role will be granted privileges to create objects in any schema in the database diff --git a/demo/setup/basics_demo/schemachange-config.yml b/demo/setup/basics_demo/schemachange-config.yml index d3d2fee3..6d505a13 100644 --- a/demo/setup/basics_demo/schemachange-config.yml +++ b/demo/setup/basics_demo/schemachange-config.yml @@ -1,16 +1,9 @@ config-version: 1 root-folder: ./demo/setup/basics_demo - -snowflake-user: {{ env_var('SNOWFLAKE_USER')}} -snowflake-account: {{ env_var('SNOWFLAKE_ACCOUNT')}} -snowflake-role: SCHEMACHANGE_DEMO_DEPLOY -snowflake-warehouse: SCHEMACHANGE_DEMO_WH -snowflake-database: SCHEMACHANGE_DEMO -snowflake-schema: BASICS_DEMO_{{ env_var('SCHEMACHANGE_BUILD_ID') }} -change-history-table: "SCHEMACHANGE_DEMO.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY" +change-history-table: "{{ env_var('SNOWFLAKE_DATABASE')}}.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY" create-change-history-table: true vars: - database_name: {{env_var('SNOWFLAKE_DATABASE', 'SCHEMACHANGE_DEMO')}} - schema_name: {{env_var('SNOWFLAKE_SCHEMA', 'BASICS_DEMO')}} + database_name: {{env_var('SNOWFLAKE_DATABASE')}} + schema_name: {{env_var('MY_TARGET_SCHEMA')}} diff --git a/demo/teardown/basics_demo.sql b/demo/teardown/basics_demo/A__basics_demo.sql similarity index 84% rename from demo/teardown/basics_demo.sql rename to demo/teardown/basics_demo/A__basics_demo.sql index 1b45621f..fab0d318 100644 --- a/demo/teardown/basics_demo.sql +++ b/demo/teardown/basics_demo/A__basics_demo.sql @@ -1,5 +1,5 @@ -SET TARGET_SCHEMA_NAME = '&{v_target_schema_name}'; -SET TARGET_DB_NAME = 'SCHEMACHANGE_DEMO'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking. +SET TARGET_SCHEMA_NAME = '{{ schema_name }}'; +SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking. -- Dependent Variables; Change the naming pattern if you want but not necessary SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas. SET DEPLOY_ROLE = $TARGET_DB_NAME || '_DEPLOY'; -- This role will be granted privileges to create objects in any schema in the database diff --git a/demo/teardown/basics_demo/schemachange-config.yml b/demo/teardown/basics_demo/schemachange-config.yml index 52faa511..618f7df8 100644 --- a/demo/teardown/basics_demo/schemachange-config.yml +++ b/demo/teardown/basics_demo/schemachange-config.yml @@ -1,16 +1,9 @@ config-version: 1 root-folder: ./demo/teardown/basics_demo - -snowflake-user: {{ env_var('SNOWFLAKE_USER')}} -snowflake-account: {{ env_var('SNOWFLAKE_ACCOUNT')}} -snowflake-role: SCHEMACHANGE_DEMO_DEPLOY -snowflake-warehouse: SCHEMACHANGE_DEMO_WH -snowflake-database: SCHEMACHANGE_DEMO -snowflake-schema: BASICS_DEMO_{{ env_var('SCHEMACHANGE_BUILD_ID') }} -change-history-table: "SCHEMACHANGE_DEMO.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY" +change-history-table: "{{ env_var('SNOWFLAKE_DATABASE')}}.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY" create-change-history-table: true vars: - database_name: {{env_var('SNOWFLAKE_DATABASE', 'SCHEMACHANGE_DEMO')}} - schema_name: {{env_var('SNOWFLAKE_SCHEMA', 'BASICS_DEMO')}} + database_name: {{env_var('SNOWFLAKE_DATABASE')}} + schema_name: {{env_var('MY_TARGET_SCHEMA')}}