From fc0d0f1fdc13121354bb2901b0b6e8cbb28270be Mon Sep 17 00:00:00 2001 From: Zane Date: Fri, 18 Oct 2024 06:42:40 -0700 Subject: [PATCH 01/16] fix: remove kw_only argument introduced in 3.10 --- schemachange/config/BaseConfig.py | 2 +- schemachange/config/DeployConfig.py | 2 +- schemachange/config/RenderConfig.py | 10 +++++++-- schemachange/session/Credential.py | 34 ++++++++++++----------------- schemachange/session/Script.py | 8 +++---- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/schemachange/config/BaseConfig.py b/schemachange/config/BaseConfig.py index f07df6d..a77c8da 100644 --- a/schemachange/config/BaseConfig.py +++ b/schemachange/config/BaseConfig.py @@ -18,7 +18,7 @@ T = TypeVar("T", bound="BaseConfig") -@dataclasses.dataclass(frozen=True, kw_only=True) +@dataclasses.dataclass(frozen=True) class BaseConfig(ABC): default_config_file_name: ClassVar[str] = "schemachange-config.yml" diff --git a/schemachange/config/DeployConfig.py b/schemachange/config/DeployConfig.py index c0bcc2e..e60656f 100644 --- a/schemachange/config/DeployConfig.py +++ b/schemachange/config/DeployConfig.py @@ -9,7 +9,7 @@ from schemachange.config.utils import get_snowflake_identifier_string -@dataclasses.dataclass(frozen=True, kw_only=True) +@dataclasses.dataclass(frozen=True) class DeployConfig(BaseConfig): subcommand: Literal["deploy"] = "deploy" snowflake_account: str | None = None diff --git a/schemachange/config/RenderConfig.py b/schemachange/config/RenderConfig.py index f17946a..2f644f0 100644 --- a/schemachange/config/RenderConfig.py +++ b/schemachange/config/RenderConfig.py @@ -8,10 +8,10 @@ from schemachange.config.utils import validate_file_path -@dataclasses.dataclass(frozen=True, kw_only=True) +@dataclasses.dataclass(frozen=True) class RenderConfig(BaseConfig): + script_path: Path | None = None subcommand: Literal["render"] = "render" - script_path: Path @classmethod def factory( @@ -31,3 +31,9 @@ def factory( script_path=validate_file_path(file_path=script_path), **kwargs, ) + + def __post_init__(self): + if self.script_path is None: + raise TypeError( + "RenderConfig is missing 1 required argument: 'script_path'" + ) diff --git a/schemachange/session/Credential.py b/schemachange/session/Credential.py index b39e180..f08e767 100644 --- a/schemachange/session/Credential.py +++ b/schemachange/session/Credential.py @@ -2,7 +2,6 @@ import dataclasses import os -from abc import ABC from typing import Literal, Union import structlog @@ -14,37 +13,32 @@ ) -@dataclasses.dataclass(kw_only=True, frozen=True) -class Credential(ABC): - authenticator: str - - -@dataclasses.dataclass(kw_only=True, frozen=True) -class OauthCredential(Credential): - authenticator: Literal["oauth"] = "oauth" +@dataclasses.dataclass(frozen=True) +class OauthCredential: token: str + authenticator: Literal["oauth"] = "oauth" -@dataclasses.dataclass(kw_only=True, frozen=True) -class PasswordCredential(Credential): - authenticator: Literal["snowflake"] = "snowflake" +@dataclasses.dataclass(frozen=True) +class PasswordCredential: password: str + authenticator: Literal["snowflake"] = "snowflake" -@dataclasses.dataclass(kw_only=True, frozen=True) -class PrivateKeyCredential(Credential): - authenticator: Literal["snowflake"] = "snowflake" +@dataclasses.dataclass(frozen=True) +class PrivateKeyCredential: private_key: bytes + authenticator: Literal["snowflake"] = "snowflake" -@dataclasses.dataclass(kw_only=True, frozen=True) -class ExternalBrowserCredential(Credential): - authenticator: Literal["externalbrowser"] = "externalbrowser" +@dataclasses.dataclass(frozen=True) +class ExternalBrowserCredential: password: str | None = None + authenticator: Literal["externalbrowser"] = "externalbrowser" -@dataclasses.dataclass(kw_only=True, frozen=True) -class OktaCredential(Credential): +@dataclasses.dataclass(frozen=True) +class OktaCredential: authenticator: str password: str diff --git a/schemachange/session/Script.py b/schemachange/session/Script.py index bfa29a8..ffe78d7 100644 --- a/schemachange/session/Script.py +++ b/schemachange/session/Script.py @@ -18,7 +18,7 @@ T = TypeVar("T", bound="Script") -@dataclasses.dataclass(kw_only=True, frozen=True) +@dataclasses.dataclass(frozen=True) class Script(ABC): pattern: ClassVar[Pattern[str]] type: ClassVar[Literal["V", "R", "A"]] @@ -47,7 +47,7 @@ def from_path(cls, file_path: Path, **kwargs) -> T: ) -@dataclasses.dataclass(kw_only=True, frozen=True) +@dataclasses.dataclass(frozen=True) class VersionedScript(Script): pattern: ClassVar[re.Pattern[str]] = re.compile( r"^(V)(?P.+?)?__(?P.+?)\.", re.IGNORECASE @@ -64,7 +64,7 @@ def from_path(cls: T, file_path: Path, **kwargs) -> T: ) -@dataclasses.dataclass(kw_only=True, frozen=True) +@dataclasses.dataclass(frozen=True) class RepeatableScript(Script): pattern: ClassVar[re.Pattern[str]] = re.compile( r"^(R)__(?P.+?)\.", re.IGNORECASE @@ -72,7 +72,7 @@ class RepeatableScript(Script): type: ClassVar[Literal["R"]] = "R" -@dataclasses.dataclass(kw_only=True, frozen=True) +@dataclasses.dataclass(frozen=True) class AlwaysScript(Script): pattern: ClassVar[re.Pattern[str]] = re.compile( r"^(A)__(?P.+?)\.", re.IGNORECASE From 6b1c1b3df3d7792981e0aacc8ec287795895ca26 Mon Sep 17 00:00:00 2001 From: Zane Date: Fri, 18 Oct 2024 07:59:51 -0700 Subject: [PATCH 02/16] fix: standardize "" and None alphanum_key behavior --- schemachange/deploy.py | 8 +++++--- schemachange/session/SnowflakeSession.py | 10 +++------- tests/test_cli_misc.py | 6 +++++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/schemachange/deploy.py b/schemachange/deploy.py index f1c53f3..b826d88 100644 --- a/schemachange/deploy.py +++ b/schemachange/deploy.py @@ -23,7 +23,9 @@ def alphanum_convert(text: str): # Each number is converted to and integer and string parts are left as strings # This will enable correct sorting in python when the lists are compared # e.g. get_alphanum_key('1.2.2') results in ['', 1, '.', 2, '.', 2, ''] -def get_alphanum_key(key): +def get_alphanum_key(key: str | int | None) -> list: + if key == "" or key is None: + return [] alphanum_key = [alphanum_convert(c) for c in re.split("([0-9]+)", key)] return alphanum_key @@ -100,7 +102,7 @@ def deploy(config: DeployConfig, session: SnowflakeSession): script_metadata = versioned_scripts.get(script.name) if ( - max_published_version != "" + max_published_version is not None and get_alphanum_key(script.version) <= max_published_version ): if script_metadata is None: @@ -113,7 +115,7 @@ def deploy(config: DeployConfig, session: SnowflakeSession): else: script_log.debug( "Script has already been applied", - max_published_version=str(max_published_version), + max_published_version=max_published_version, ) if script_metadata["checksum"] != checksum_current: script_log.info("Script checksum has drifted since application") diff --git a/schemachange/session/SnowflakeSession.py b/schemachange/session/SnowflakeSession.py index f6c88be..bb914ca 100644 --- a/schemachange/session/SnowflakeSession.py +++ b/schemachange/session/SnowflakeSession.py @@ -209,11 +209,7 @@ def get_script_metadata( self.logger.info( "Max applied change script version %(max_published_version)s" - % { - "max_published_version": max_published_version - if max_published_version != "" - else "None" - } + % {"max_published_version": max_published_version} ) return change_history, r_scripts_checksum, max_published_version @@ -251,10 +247,10 @@ def fetch_versioned_scripts( # Collect all the results into a list versioned_scripts: dict[str, dict[str, str | int]] = defaultdict(dict) - versions: list[str | int] = [] + versions: list[str | int | None] = [] for cursor in results: for version, script, checksum in cursor: - versions.append(version) + versions.append(version if version != "" else None) versioned_scripts[script] = { "version": version, "script": script, diff --git a/tests/test_cli_misc.py b/tests/test_cli_misc.py index d5c0ef8..e5877b1 100644 --- a/tests/test_cli_misc.py +++ b/tests/test_cli_misc.py @@ -30,7 +30,11 @@ def test_alphanum_convert_given__lowercase(): def test_get_alphanum_key_given__empty_string(): - assert get_alphanum_key("") == [""] + assert get_alphanum_key("") == [] + + +def test_get_alphanum_key_given__none(): + assert get_alphanum_key(None) == [] def test_get_alphanum_key_given__numbers_only(): From e947e427150eddd77f7c2ab1c742336776554172 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Fri, 25 Oct 2024 13:43:16 -0400 Subject: [PATCH 03/16] Updating Ownership hierarchy to allow schemachange to create the schema if it does not exist. --- CHANGELOG.md | 8 ++++++++ demo/provision/setup_schemachange_schema.sql | 1 + demo/setup/basics_demo/A__setup_basics_demo.sql | 1 + demo/setup/citibike_demo/A__setup_citibike_demo.sql | 1 + .../citibike_demo_jinja/A__setup_citibike_demo_jinja.sql | 1 + schemachange/cli.py | 2 +- tests/test_cli_misc.py | 2 +- 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 656504c..f409859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. *The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).* +## [4.0.0] - TBD +### Added +- use of structlog for standard log outputs + +### Changed +- Refactored the main cli.py to be more modular to aide in future development and testing. + + ## [3.7.0] - 2024-07-22 ### Added - Improved unit test coverage diff --git a/demo/provision/setup_schemachange_schema.sql b/demo/provision/setup_schemachange_schema.sql index 0c4322c..6be6ad3 100644 --- a/demo/provision/setup_schemachange_schema.sql +++ b/demo/provision/setup_schemachange_schema.sql @@ -38,6 +38,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; +GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/demo/setup/basics_demo/A__setup_basics_demo.sql b/demo/setup/basics_demo/A__setup_basics_demo.sql index a39e16f..31f48df 100644 --- a/demo/setup/basics_demo/A__setup_basics_demo.sql +++ b/demo/setup/basics_demo/A__setup_basics_demo.sql @@ -31,6 +31,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; +GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/demo/setup/citibike_demo/A__setup_citibike_demo.sql b/demo/setup/citibike_demo/A__setup_citibike_demo.sql index a39e16f..31f48df 100644 --- a/demo/setup/citibike_demo/A__setup_citibike_demo.sql +++ b/demo/setup/citibike_demo/A__setup_citibike_demo.sql @@ -31,6 +31,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; +GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql b/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql index a39e16f..31f48df 100644 --- a/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql +++ b/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql @@ -31,6 +31,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; +GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/schemachange/cli.py b/schemachange/cli.py index d6fe54f..f896d09 100644 --- a/schemachange/cli.py +++ b/schemachange/cli.py @@ -13,7 +13,7 @@ # region Global Variables # metadata -SCHEMACHANGE_VERSION = "3.7.0" +SCHEMACHANGE_VERSION = "4.0.0" SNOWFLAKE_APPLICATION_NAME = "schemachange" module_logger = structlog.getLogger(__name__) diff --git a/tests/test_cli_misc.py b/tests/test_cli_misc.py index e5877b1..97bbc68 100644 --- a/tests/test_cli_misc.py +++ b/tests/test_cli_misc.py @@ -10,7 +10,7 @@ def test_cli_given__schemachange_version_change_updated_in_setup_config_file(): - assert SCHEMACHANGE_VERSION == "3.7.0" + assert SCHEMACHANGE_VERSION == "4.0.0" def test_cli_given__constants_exist(): From 8d15e52dcc6385b809fc75c42721e4f1da336b69 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Fri, 25 Oct 2024 13:50:22 -0400 Subject: [PATCH 04/16] fixing syntax issue --- demo/provision/setup_schemachange_schema.sql | 2 +- demo/setup/basics_demo/A__setup_basics_demo.sql | 2 +- demo/setup/citibike_demo/A__setup_citibike_demo.sql | 2 +- demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/provision/setup_schemachange_schema.sql b/demo/provision/setup_schemachange_schema.sql index 6be6ad3..906c132 100644 --- a/demo/provision/setup_schemachange_schema.sql +++ b/demo/provision/setup_schemachange_schema.sql @@ -38,7 +38,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; -GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); +GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/demo/setup/basics_demo/A__setup_basics_demo.sql b/demo/setup/basics_demo/A__setup_basics_demo.sql index 31f48df..2d7edf7 100644 --- a/demo/setup/basics_demo/A__setup_basics_demo.sql +++ b/demo/setup/basics_demo/A__setup_basics_demo.sql @@ -31,7 +31,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; -GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); +GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/demo/setup/citibike_demo/A__setup_citibike_demo.sql b/demo/setup/citibike_demo/A__setup_citibike_demo.sql index 31f48df..2d7edf7 100644 --- a/demo/setup/citibike_demo/A__setup_citibike_demo.sql +++ b/demo/setup/citibike_demo/A__setup_citibike_demo.sql @@ -31,7 +31,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; -GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); +GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA diff --git a/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql b/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql index 31f48df..2d7edf7 100644 --- a/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql +++ b/demo/setup/citibike_demo_jinja/A__setup_citibike_demo_jinja.sql @@ -31,7 +31,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C); CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS; -- USE SCHEMA INFORMATION_SCHEMA; -- DROP SCHEMA IF EXISTS PUBLIC; -GRANT OWNERSHIP ON IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); +GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE); USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE); -- SCHEMA From 2537bb9ee323e770c9891921fd98eaee57a73cbd Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Fri, 25 Oct 2024 15:29:33 -0400 Subject: [PATCH 05/16] checking the default schema creation step --- demo/basics_demo/schemachange-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/basics_demo/schemachange-config.yml b/demo/basics_demo/schemachange-config.yml index 18680db..0e23a72 100644 --- a/demo/basics_demo/schemachange-config.yml +++ b/demo/basics_demo/schemachange-config.yml @@ -7,7 +7,7 @@ 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')}}" +# 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 From fc480ae9fecadd4b60db34d744dfacb6baf9f514 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Fri, 25 Oct 2024 19:39:19 -0400 Subject: [PATCH 06/16] adding missing schema reference in demo script --- demo/basics_demo/V1.0.2__StoredProc.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demo/basics_demo/V1.0.2__StoredProc.sql b/demo/basics_demo/V1.0.2__StoredProc.sql index bea83a0..dca2436 100644 --- a/demo/basics_demo/V1.0.2__StoredProc.sql +++ b/demo/basics_demo/V1.0.2__StoredProc.sql @@ -1,3 +1,5 @@ +use database {{ database_name }}; +use schema {{ schema_name }}; -- This block of code executes in Visual Studio Code but fails in Schemachange. -- Use the $$ ... $$ to mark the block and execute the code block successfully. -- The comment from a community user help find the root cause. From 1a2f1e76f5b1b8bd819e0e15e7347032dfa266bb Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Fri, 25 Oct 2024 19:40:02 -0400 Subject: [PATCH 07/16] Added create schema privilege to deploy role because schemachange tries to create the default schema if it does not exist. --- demo/provision/setup_schemachange_schema.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demo/provision/setup_schemachange_schema.sql b/demo/provision/setup_schemachange_schema.sql index 906c132..e1eef07 100644 --- a/demo/provision/setup_schemachange_schema.sql +++ b/demo/provision/setup_schemachange_schema.sql @@ -20,6 +20,8 @@ CREATE DATABASE ROLE IF NOT EXISTS DB_R; CREATE DATABASE ROLE IF NOT EXISTS DB_W; CREATE DATABASE ROLE IF NOT EXISTS DB_C; +GRANT CREATE SCHEMA ON DATABASE IDENTIFIER($TARGET_DB_NAME) TO DATABASE ROLE DB_C; + GRANT DATABASE ROLE DB_C TO ROLE IDENTIFIER($DEPLOY_ROLE); CREATE DATABASE ROLE IF NOT EXISTS IDENTIFIER($SC_M); From 4a261ecb9973ac9466910e84f3572b362dcce8d2 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Fri, 25 Oct 2024 19:45:10 -0400 Subject: [PATCH 08/16] Restore the schema reference in demo config --- demo/basics_demo/schemachange-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/basics_demo/schemachange-config.yml b/demo/basics_demo/schemachange-config.yml index 0e23a72..18680db 100644 --- a/demo/basics_demo/schemachange-config.yml +++ b/demo/basics_demo/schemachange-config.yml @@ -7,7 +7,7 @@ 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')}}" +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 From 1a7ed1180830136e56996c366f406941b18cc058 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 14:54:14 -0400 Subject: [PATCH 09/16] Changes - Removed 3.8 from github actions and added 3.12 - Updated contributing guide and docs to make it cohesive. --- .github/CONTRIBUTING.md | 41 ++++++++++++++++------------- .github/workflows/dev-pytest.yml | 2 +- .github/workflows/master-pytest.yml | 2 +- README.md | 6 ++++- demo/README.MD | 12 +++++---- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 52bcc14..5d4c314 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,12 +7,11 @@ operating environment, schemachange version and python version. Whenever possibl also include a brief, self-contained code example that demonstrates the problem. We have -included [issue templates for reporting bugs, requesting features and seeking clarifications.](https://github.com/Snowflake-Labs/schemachange/issues/new/choose) -Choose the appropriate issue template to contribute to the repository. +included [issue templates](https://github.com/Snowflake-Labs/schemachange/issues/new/choose) for reporting bugs, requesting features and seeking clarifications. Choose the appropriate issue template to contribute to the repository. ## Contributing code -Thanks for your interest in contributing code to schemachange! +Thank you for your interest in contributing code to schemachange! + If this is your first time contributing to a project on GitHub, please read through our [guide to contributing to schemachange](guide-to-contributing-to-schemachange). @@ -23,27 +22,29 @@ Thanks for your interest in contributing code to schemachange! ### Guide to contributing to schemachange +> **IMPORTANT** : You will need to follow the [provisioning and schemachange setup instructions](../demo/README.MD) to ensure you can run github actions against your snowflake account before placing a PR with main schemachange repository so that your PR can be merged into schemachange master branch. + 1. If you are a first-time contributor + Go to [Snowflake-Labs/Schemachange](https://github.com/Snowflake-Labs/schemachange) and click the "fork" button to create your own copy of the project. + [Clone](https://github.com/git-guides/git-clone) the project to your local computer ```shell - git clone https://github.com/your-username/schemachange.git - + # Replace with your Github User Name otherwise + # you will not be able to clone from the fork you created earlier. + git clone https://github.com//schemachange.git ``` + Change the directory ```shell cd schemachange - ``` + + Add upstream repository: ```shell git remote add upstream https://github.com/Snowflake-Labs/schemachange - ``` + Now, `git remote -v` will show two [remote](https://github.com/git-guides/git-remote) repositories named: @@ -54,7 +55,6 @@ Thanks for your interest in contributing code to schemachange! ```shell git checkout main git pull upstream main --tags - ``` 2. Create and Activate a Virtual Environment @@ -68,7 +68,7 @@ Thanks for your interest in contributing code to schemachange! of [this](https://docs.python.org/3/library/venv.html#how-venvs-work) table: | Platform | Shell | Command | - |----------|------------|---------------------------------------| + |----------|------------|---------------------------------------| | POSIX | bash/zsh | `$ source /bin/activate` | | POSIX | fish | `$ source /bin/activate.fish` | | POSIX | csh/tcsh | `$ source /bin/activate.csh` | @@ -76,12 +76,14 @@ Thanks for your interest in contributing code to schemachange! | Windows | cmd.exe | `C:\> \Scripts\activate.bat` | | Windows | PowerShell | `PS C:\> \Scripts\Activate.ps1` | - 3. With your virtual environment activated, upgrade pip + 3. With your virtual environment activated, upgrade `pip` + ```bash python -m pip install --upgrade pip ``` 4. Install the repo as an "editable" package with development dependencies + ```bash pip install -e .[dev] ``` @@ -90,27 +92,30 @@ Thanks for your interest in contributing code to schemachange! + Create a branch for the features you want to work on. Since the branch name will appear in the merge message, use a sensible name such as 'update-build-library-dependencies': - ```shell - git checkout -b update-build-library-dependencies - ``` + ```shell + git checkout -b update-build-library-dependencies + ``` + Commit locally as you progress ( [git add](https://github.com/git-guides/git-add) and [git commit](https://github.com/git-guides/git-commit) ). Use a properly formatted commit message. Be sure to - document any changed behavior. + document any changed behavior in the [CHANGELOG.md](../CHANGELOG.md) file to help us collate the changes for a specific release. + +4. Test your contribution locally -4. Test your contribution ```bash python -m pytest ``` + PS: Please add test cases to the features you are developing so that over time, we can capture any lapse in functionality changes. + +5. Push your contribution to GitHub -5. To submit your contribution - + [Push](https://github.com/git-guides/git-push) your changes back to your fork on GitHub + [Push](https://github.com/git-guides/git-push) your changes back to your fork on GitHub ```shell git push origin update-build-library-dependencies - ``` +6. + Go to GitHub. The new branch will show up with a green [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#initiating-the-pull-request) button. Make sure the title and message are clear, concise and self-explanatory. Then click the button to submit diff --git a/.github/workflows/dev-pytest.yml b/.github/workflows/dev-pytest.yml index 4cfa9cb..94abf1e 100644 --- a/.github/workflows/dev-pytest.yml +++ b/.github/workflows/dev-pytest.yml @@ -20,7 +20,7 @@ jobs: matrix: scenario-name: [ 'basics_demo', 'citibike_demo', 'citibike_demo_jinja'] os: ["ubuntu-latest"] - python-version: ["3.11"] + python-version: ["3.12"] runs-on: ${{ matrix.os }} if: ${{ github.event.label.name == 'ci-run-tests' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} diff --git a/.github/workflows/master-pytest.yml b/.github/workflows/master-pytest.yml index 80ba7aa..5caa505 100644 --- a/.github/workflows/master-pytest.yml +++ b/.github/workflows/master-pytest.yml @@ -25,7 +25,7 @@ jobs: matrix: scenario-name: [ 'basics_demo', 'citibike_demo', 'citibike_demo_jinja'] os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] runs-on: ${{ matrix.os }} if: ${{ github.event.label.name == 'ci-run-tests' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} env: diff --git a/README.md b/README.md index ae9fe7a..93dcd74 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ blog post. For the complete list of changes made to schemachange check out the [CHANGELOG](CHANGELOG.md). +To learn more about making a contribution to schemachange, please see our [Contributing guide](.github/CONTRIBUTING.md). + **Please note** that schemachange is a community-developed tool, not an official Snowflake offering. It comes with no support or warranty. @@ -490,7 +492,9 @@ compatibility with versions prior to 3.2. This is the main command that runs the deployment process. -`usage: schemachange deploy [-h] [--config-folder CONFIG_FOLDER] [-f ROOT_FOLDER] [-m MODULES_FOLDER] [-a SNOWFLAKE_ACCOUNT] [-u SNOWFLAKE_USER] [-r SNOWFLAKE_ROLE] [-w SNOWFLAKE_WAREHOUSE] [-d SNOWFLAKE_DATABASE] [-s SNOWFLAKE_SCHEMA] [-c CHANGE_HISTORY_TABLE] [--vars VARS] [--create-change-history-table] [-ac] [-v] [--dry-run] [--query-tag QUERY_TAG]` +```bash +usage: schemachange deploy [-h] [--config-folder CONFIG_FOLDER] [-f ROOT_FOLDER] [-m MODULES_FOLDER] [-a SNOWFLAKE_ACCOUNT] [-u SNOWFLAKE_USER] [-r SNOWFLAKE_ROLE] [-w SNOWFLAKE_WAREHOUSE] [-d SNOWFLAKE_DATABASE] [-s SNOWFLAKE_SCHEMA] [-c CHANGE_HISTORY_TABLE] [--vars VARS] [--create-change-history-table] [-ac] [-v] [--dry-run] [--query-tag QUERY_TAG] +``` | Parameter | Description | |----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/demo/README.MD b/demo/README.MD index 24fc262..14576fd 100644 --- a/demo/README.MD +++ b/demo/README.MD @@ -29,14 +29,16 @@ dev branches respectively. - If you are consumer who is installing schemachange and wants to test-run the demo, then you will have to set the following environment variables. - SNOWFLAKE_ACCOUNT: This will be the account identifier for your snowflake account. - - SNOWFLAKE_USER: This will be the user that will connect to you snowflake account. - - SNOWFLAKE_PASSWORD: This is the password for the user (SNOWFLAKE_USER) that will connect to the snowflake account. + - SNOWFLAKE_USER: This will be the user that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). + - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). - SCENARIO_NAME: This will be demo folder you intend to experiment with. For starters, `basics_demo`, `citibike_demo` or `citibike_demo_jinja` are included with the repo that will set the root folder value in the respective schemachange-config.yml file. - - SNOWFLAKE_WAREHOUSE: This will be the warehouse you set up for the demo. Default setup is SCHEMACHANGE_DEMO_WH - - SNOWFLAKE_DATABASE Keyed to SCHEMACHANGE_DEMO - - SNOWFLAKE_ROLE Keyed to SCHEMACHANGE_DEMO-DEPLOY + - SNOWFLAKE_WAREHOUSE: This will be the warehouse you set up for the demo. Default setup is SCHEMACHANGE_DEMO_WH. You can update this to your warehouse in your snowflake account (`SNOWFLAKE_ACCOUNT`). + - SNOWFLAKE_DATABASE Keyed to SCHEMACHANGE_DEMO. You can update this to the database in your snowflake account (`SNOWFLAKE_ACCOUNT`) + - SNOWFLAKE_ROLE Keyed to SCHEMACHANGE_DEMO-DEPLOY. This particular role name was chosen to test hyphenated roles in schemachange. You can update this value to match the role you have setup in your snowflake account (`SNOWFLAKE_ACCOUNT`). + +Either you setup Warehouse, Database and role to match the demo defaults and run the demo as is pointing to your account (`SNOWFLAKE_ACCOUNT`) or update the schemachange-config.yml file keys to match values you have setup in your local snowflake account and run the demo scenarios to get a feel for how schemachange works. The scripts in the `provision` folder can be used to set up up your demo database along with a schema in that database that will house the change tracking tables needed to set up and teardown the schemas used to test a working version of From 8004ed9880b046c886ee3f93b09ec7da6b0c68dc Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 15:53:40 -0400 Subject: [PATCH 10/16] Update .github/CONTRIBUTING.md Accepting review comments. Co-authored-by: Tyler White --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5d4c314..48315f7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -22,7 +22,7 @@ Thank you for your interest in contributing code to schemachange! ### Guide to contributing to schemachange -> **IMPORTANT** : You will need to follow the [provisioning and schemachange setup instructions](../demo/README.MD) to ensure you can run github actions against your snowflake account before placing a PR with main schemachange repository so that your PR can be merged into schemachange master branch. +> **IMPORTANT** : You will need to follow the [provisioning and schemachange setup instructions](../demo/README.MD) to ensure you can run GitHub actions against your Snowflake account before placing a PR with main schemachange repository so that your PR can be merged into schemachange master branch. 1. If you are a first-time contributor + Go to [Snowflake-Labs/Schemachange](https://github.com/Snowflake-Labs/schemachange) and click the "fork" button to From 402cb2b55ed29300aafbd84682265dd34332c883 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 15:54:00 -0400 Subject: [PATCH 11/16] Update demo/README.MD Accepting Review comment Co-authored-by: Tyler White --- demo/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/README.MD b/demo/README.MD index 14576fd..9dbea86 100644 --- a/demo/README.MD +++ b/demo/README.MD @@ -28,7 +28,7 @@ dev branches respectively. - If you are consumer who is installing schemachange and wants to test-run the demo, then you will have to set the following environment variables. - - SNOWFLAKE_ACCOUNT: This will be the account identifier for your snowflake account. + - SNOWFLAKE_ACCOUNT: This will be the account identifier for your Snowflake account. - SNOWFLAKE_USER: This will be the user that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). - SCENARIO_NAME: This will be demo folder you intend to experiment with. For From 73cbe88efcded591b3042615de878f232c897121 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 15:54:27 -0400 Subject: [PATCH 12/16] Update demo/README.MD accepted Co-authored-by: Tyler White --- demo/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/README.MD b/demo/README.MD index 9dbea86..ca59f8f 100644 --- a/demo/README.MD +++ b/demo/README.MD @@ -30,7 +30,7 @@ dev branches respectively. following environment variables. - SNOWFLAKE_ACCOUNT: This will be the account identifier for your Snowflake account. - SNOWFLAKE_USER: This will be the user that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). - - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). + - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your Snowflake account (`SNOWFLAKE_ACCOUNT`). - SCENARIO_NAME: This will be demo folder you intend to experiment with. For starters, `basics_demo`, `citibike_demo` or `citibike_demo_jinja` are included with the repo that will set the root folder value in the respective schemachange-config.yml file. From 6314ce43467dc0900d13a544b116b00bcee4e3bc Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 15:54:57 -0400 Subject: [PATCH 13/16] Update demo/README.MD Accepted Co-authored-by: Tyler White --- demo/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/README.MD b/demo/README.MD index ca59f8f..928f977 100644 --- a/demo/README.MD +++ b/demo/README.MD @@ -29,7 +29,7 @@ dev branches respectively. - If you are consumer who is installing schemachange and wants to test-run the demo, then you will have to set the following environment variables. - SNOWFLAKE_ACCOUNT: This will be the account identifier for your Snowflake account. - - SNOWFLAKE_USER: This will be the user that will connect to your snowflake account (`SNOWFLAKE_ACCOUNT`). + - SNOWFLAKE_USER: This will be the user that will connect to your Snowflake account (`SNOWFLAKE_ACCOUNT`). - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your Snowflake account (`SNOWFLAKE_ACCOUNT`). - SCENARIO_NAME: This will be demo folder you intend to experiment with. For starters, `basics_demo`, `citibike_demo` or `citibike_demo_jinja` are included with the repo that will set the From bf08a2aa6c8de9fac2a4fcf850fa9e5ae426edf7 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 15:55:15 -0400 Subject: [PATCH 14/16] Update demo/README.MD Accepted Co-authored-by: Tyler White --- demo/README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/README.MD b/demo/README.MD index 928f977..ac4d9ed 100644 --- a/demo/README.MD +++ b/demo/README.MD @@ -34,7 +34,7 @@ dev branches respectively. - SCENARIO_NAME: This will be demo folder you intend to experiment with. For starters, `basics_demo`, `citibike_demo` or `citibike_demo_jinja` are included with the repo that will set the root folder value in the respective schemachange-config.yml file. - - SNOWFLAKE_WAREHOUSE: This will be the warehouse you set up for the demo. Default setup is SCHEMACHANGE_DEMO_WH. You can update this to your warehouse in your snowflake account (`SNOWFLAKE_ACCOUNT`). + - SNOWFLAKE_WAREHOUSE: This will be the warehouse you set up for the demo. Default setup is SCHEMACHANGE_DEMO_WH. You can update this to your warehouse in your Snowflake account (`SNOWFLAKE_ACCOUNT`). - SNOWFLAKE_DATABASE Keyed to SCHEMACHANGE_DEMO. You can update this to the database in your snowflake account (`SNOWFLAKE_ACCOUNT`) - SNOWFLAKE_ROLE Keyed to SCHEMACHANGE_DEMO-DEPLOY. This particular role name was chosen to test hyphenated roles in schemachange. You can update this value to match the role you have setup in your snowflake account (`SNOWFLAKE_ACCOUNT`). From 2c553e87144ebb789a00b90db901058d7a44c820 Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 15:57:58 -0400 Subject: [PATCH 15/16] Implementing review changes --- .github/CONTRIBUTING.md | 6 +++--- CHANGELOG.md | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 48315f7..a7bd6ad 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -13,8 +13,8 @@ included [issue templates](https://github.com/Snowflake-Labs/schemachange/issues Thank you for your interest in contributing code to schemachange! -+ If this is your first time contributing to a project on GitHub, please read through - our [guide to contributing to schemachange](guide-to-contributing-to-schemachange). ++ If this is your first time contributing to a project on GitHub, please continue reading through + [our guide to contributing to schemachange](#guide-to-contributing-to-schemachange). + There are many online tutorials to help you [learn git](https://try.github.io/). For discussions of specific git workflows, see these discussions on [linux git workflow](https://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html), @@ -115,7 +115,7 @@ Thank you for your interest in contributing code to schemachange! git push origin update-build-library-dependencies ``` -6. +6. Raise a Pull Request to merge your contribution into the a Schemachange Release + Go to GitHub. The new branch will show up with a green [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#initiating-the-pull-request) button. Make sure the title and message are clear, concise and self-explanatory. Then click the button to submit diff --git a/CHANGELOG.md b/CHANGELOG.md index f409859..5d1c933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file. ## [4.0.0] - TBD ### Added -- use of structlog for standard log outputs +- Use of `structlog~=24.1.0` for standard log outputs +- Verified Schemachange against Python 3.12 ### Changed -- Refactored the main cli.py to be more modular to aide in future development and testing. +- Refactored the main cli.py into multiple modules - config, session. +- Updated contributing guidelines and demo readme content to help contributors setup local snowflake account to run the github actions in their fork before pushing the PR to upstream repository. +- Removed tests against Python 3.8 [End of Life on 2024-10-07](https://devguide.python.org/versions/#supported-versions) ## [3.7.0] - 2024-07-22 From 11bdee7420ff60dbf611c6b7ce0624c53bfb6aba Mon Sep 17 00:00:00 2001 From: Tiji Mathew Date: Tue, 29 Oct 2024 16:09:30 -0400 Subject: [PATCH 16/16] Implementing review comments --- demo/README.MD | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/demo/README.MD b/demo/README.MD index ac4d9ed..a36dadf 100644 --- a/demo/README.MD +++ b/demo/README.MD @@ -13,32 +13,24 @@ not break any existing functionality. - [setup_schemachange_schema.sql](provision/setup_schemachange_schema.sql): Contains the SQL variables to track the individual demo scenarios in its own change history table. -### Contributors - -As a contributor, you will have to set up schemachange demo database and schemachange schema (See Initialize and Setup -scripts below). Along with that you will also set up the following Secrets in your forked repository so that the GitHub -actions can set up, test and teardown the temporary schema it creates to test the changes to your code in the master and -dev branches respectively. - -- SCHEMACHANGE_SNOWFLAKE_PASSWORD -- SCHEMACHANGE_SNOWFLAKE_USER -- SCHEMACHANGE_SNOWFLAKE_ACCOUNT - ### Consumers - If you are consumer who is installing schemachange and wants to test-run the demo, then you will have to set the following environment variables. - SNOWFLAKE_ACCOUNT: This will be the account identifier for your Snowflake account. - SNOWFLAKE_USER: This will be the user that will connect to your Snowflake account (`SNOWFLAKE_ACCOUNT`). - - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your Snowflake account (`SNOWFLAKE_ACCOUNT`). + - SNOWFLAKE_PASSWORD: This is the password for the user (`SNOWFLAKE_USER`) that will connect to your Snowflake + account (`SNOWFLAKE_ACCOUNT`). - SCENARIO_NAME: This will be demo folder you intend to experiment with. For starters, `basics_demo`, `citibike_demo` or `citibike_demo_jinja` are included with the repo that will set the root folder value in the respective schemachange-config.yml file. - - SNOWFLAKE_WAREHOUSE: This will be the warehouse you set up for the demo. Default setup is SCHEMACHANGE_DEMO_WH. You can update this to your warehouse in your Snowflake account (`SNOWFLAKE_ACCOUNT`). - - SNOWFLAKE_DATABASE Keyed to SCHEMACHANGE_DEMO. You can update this to the database in your snowflake account (`SNOWFLAKE_ACCOUNT`) - - SNOWFLAKE_ROLE Keyed to SCHEMACHANGE_DEMO-DEPLOY. This particular role name was chosen to test hyphenated roles in schemachange. You can update this value to match the role you have setup in your snowflake account (`SNOWFLAKE_ACCOUNT`). - -Either you setup Warehouse, Database and role to match the demo defaults and run the demo as is pointing to your account (`SNOWFLAKE_ACCOUNT`) or update the schemachange-config.yml file keys to match values you have setup in your local snowflake account and run the demo scenarios to get a feel for how schemachange works. + - SNOWFLAKE_WAREHOUSE: This will be the warehouse you set up for the demo in your Snowflake + account (`SNOWFLAKE_ACCOUNT`). Default setup is SCHEMACHANGE_DEMO_WH. + - SNOWFLAKE_DATABASE Keyed to SCHEMACHANGE_DEMO. You can update this to the database in your snowflake account + (`SNOWFLAKE_ACCOUNT`). You will also need to update the provision scripts accordingly. + - SNOWFLAKE_ROLE Keyed to SCHEMACHANGE_DEMO-DEPLOY. This particular role name was chosen to test hyphenated roles + in schemachange. You can update this value to match the role you have setup in your snowflake + account (`SNOWFLAKE_ACCOUNT`). The scripts in the `provision` folder can be used to set up up your demo database along with a schema in that database that will house the change tracking tables needed to set up and teardown the schemas used to test a working version of @@ -49,6 +41,17 @@ the demo DDL scripts. - The [setup](provision/setup_schemachange_schema.sql) script creates the `SCHEMACHANGE` schema in the database that you created in the initialize step. +### Contributors + +As a contributor, you will have to set up schemachange demo database and schemachange schema (See Initialize and Setup +scripts below). Along with that you will also set up the following Secrets in your forked repository so that the GitHub +actions can set up, test and teardown the temporary schema it creates to test the changes to your code in the master and +dev branches respectively. + +- SCHEMACHANGE_SNOWFLAKE_PASSWORD +- SCHEMACHANGE_SNOWFLAKE_USER +- SCHEMACHANGE_SNOWFLAKE_ACCOUNT + # Setup The setup scripts are included to build the schema needed by the GitHub Actions Workflow to avoid conflict across jobs