diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9bb1d9d9..03d2a289 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,11 +8,15 @@ on: push: paths: - 'admin/*' + - 'privileges/*' + - 'users_and_roles/*' + - 'databases/*' branches: - "main" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + jobs: # This workflow contains a single job called "deploy" deploy: @@ -66,4 +70,37 @@ jobs: - name: Grant privileges run: | - ~/bin/snowsql -f privileges/grants.sql \ No newline at end of file + ~/bin/snowsql -f privileges/grants.sql + + schemachange: + runs-on: ubuntu-latest + + env: + SNOWFLAKE_PASSWORD: ${{ secrets.SNOWSQL_PWD }} + SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWSQL_ACCOUNT }} + SNOWFLAKE_USER: ${{ secrets.SNOWSQL_USER }} + # SNOWSQL_DATABASE: ${{ secrets.SNOWFLAKE_DATABASE }} + # SNOWSQL_SCHEMA: ${{ secrets.SNOWFLAKE_SCHEMA }} + # SNOWSQL_ROLE: ${{ secrets.SNOWFLAKE_ROLE }} + SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWSQL_WAREHOUSE }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.10 + + - name: install-py-dependencies + shell: bash + run: | + schemachange + + - name: deploy schemachange + shell: bash + run: | + schemachange \ + -a $SNOWFLAKE_ACCOUNT \ + -u $SNOWFLAKE_USER \ + -r SYSADMIN \ + -w compute_xsmall \ + -d METADATA diff --git a/databases/V1.0.0__first_warehouse_init.sql b/databases/V1.0.0__first_warehouse_init.sql new file mode 100644 index 00000000..5a4fb93f --- /dev/null +++ b/databases/V1.0.0__first_warehouse_init.sql @@ -0,0 +1,29 @@ +use role sysadmin; +create warehouse if not exists compute_org +warehouse_type = STANDARD +warehouse_size = XSMALL +auto_suspend = 90 +auto_resume = TRUE +initially_suspended = TRUE; + +create warehouse if not exists compute_medium +warehouse_type = STANDARD +warehouse_size = MEDIUM +auto_suspend = 70 +auto_resume = TRUE +initially_suspended = TRUE; + +create warehouse if not exists recover_xsmall +warehouse_type = STANDARD +warehouse_size = XSMALL +auto_suspend = 90 +auto_resume = TRUE +initially_suspended = TRUE; + +// Tableau warehouse should have longer suspect time to leverage caching +create warehouse if not exists tableau +warehouse_type = STANDARD +warehouse_size = XSMALL +auto_suspend = 300 +auto_resume = TRUE +initially_suspended = TRUE; diff --git a/databases/V1.1.0__alter_xsmall_warehouses.sql b/databases/V1.1.0__alter_xsmall_warehouses.sql new file mode 100644 index 00000000..331b9bd0 --- /dev/null +++ b/databases/V1.1.0__alter_xsmall_warehouses.sql @@ -0,0 +1,6 @@ +use role sysadmin; +alter warehouse if exists compute_org rename to compute_xsmall; +alter warehouse if exists compute_xsmall set +auto_suspend = 70; + +alter warehouse if exists tableau rename to tableau_xsmall; diff --git a/users_and_roles/roles.sql b/users_and_roles/roles.sql index af52cb92..dbdef950 100644 --- a/users_and_roles/roles.sql +++ b/users_and_roles/roles.sql @@ -1,6 +1,7 @@ USE WAREHOUSE COMPUTE_ORG; USE ROLE USERADMIN; +-- TODO: Create role for tableau warehouse -- system wide roles CREATE ROLE IF NOT EXISTS MASKING_ADMIN; CREATE ROLE IF NOT EXISTS DATA_ENGINEER;