Skip to content

Commit

Permalink
Add in schema change
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasyu888 committed Oct 30, 2023
1 parent 02aca24 commit 21b2deb
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
39 changes: 38 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -66,4 +70,37 @@ jobs:

- name: Grant privileges
run: |
~/bin/snowsql -f privileges/grants.sql
~/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
29 changes: 29 additions & 0 deletions databases/V1.0.0__first_warehouse_init.sql
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions databases/V1.1.0__alter_xsmall_warehouses.sql
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions users_and_roles/roles.sql
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 21b2deb

Please sign in to comment.