Skip to content

Commit 9cdb95b

Browse files
committed
add-option-to-continue-on-script-error
1 parent ad4a9b3 commit 9cdb95b

File tree

22 files changed

+371
-129
lines changed

22 files changed

+371
-129
lines changed

.github/workflows/dev-pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
SNOWFLAKE_ACCOUNT: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_ACCOUNT }}
3131
SNOWFLAKE_DATABASE: SCHEMACHANGE_DEMO
3232
SNOWFLAKE_WAREHOUSE: SCHEMACHANGE_DEMO_WH
33-
SNOWFLAKE_ROLE: SCHEMACHANGE_DEMO-DEPLOY
33+
SNOWFLAKE_ROLE: SCHEMACHANGE_DEMO-ADMIN
3434
MY_TARGET_SCHEMA: ${{ matrix.scenario-name }}_${{ github.run_number }}_${{ strategy.job-index }}
3535
SCENARIO_NAME: ${{ matrix.scenario-name }}
3636
steps:

.github/workflows/master-pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
env:
3232
SNOWFLAKE_ACCOUNT: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_ACCOUNT }}
3333
SNOWFLAKE_USER: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_USER }}
34-
SNOWFLAKE_ROLE: SCHEMACHANGE_DEMO-DEPLOY
34+
SNOWFLAKE_ROLE: SCHEMACHANGE_DEMO-ADMIN
3535
SNOWFLAKE_WAREHOUSE: SCHEMACHANGE_DEMO_WH
3636
SNOWFLAKE_DATABASE: SCHEMACHANGE_DEMO
3737
MY_TARGET_SCHEMA: ${{ matrix.scenario-name }}_${{ github.run_number }}_${{ strategy.job-index }}

CHANGELOG.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@ All notable changes to this project will be documented in this file.
33

44
*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).*
55

6-
## [4.1.0] - 2025-03-18
6+
7+
## [4.2.0] - 2025-08-06
78
### Added
8-
- Optional flags to continue deploying remaining scripts after an error, recording full error messages in the change history table and listing failed scripts at completion.
9+
- Optional flags to continue deploying remaining scripts after an error, recording full error messages in the change history table and listing failed scripts at completion. (#339 by @luisggc)
10+
- Automatically add missing `ERROR_MESSAGE` column to the change history table to capture full script errors (#339 by @luisggc)
11+
12+
13+
## [4.1.0] - 2025-08-05
14+
### Added
15+
- Added flag `--error-on-ignored-versioned-migration` to throw an error when versioned migrations are ignored due to being out of order (#287 by @zanebclark)
16+
- Added `py.typed` marker file for better MyPy type checking support (#332 by @fozcodes)
17+
18+
### Changed
19+
- Updated Flyway documentation links to current Red Gate community documentation (#333 by @sfc-gh-adamle)
20+
921
### Fixed
10-
- Automatically add missing `ERROR_MESSAGE` column to the change history table to capture full script errors
22+
- Fixed secret redaction functionality to properly handle configuration secrets (#312 by @zanebclark)
23+
24+
### Deprecated
25+
- Deprecated the `--verbose` flag in favor of structured logging (#288 by @zanebclark)
26+
1127

1228
## [4.0.1] - 2025-02-17
1329
### Changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ JSON object formatted as a string.
186186
schemachange will replace any variable placeholders before running your change script code and will throw an error if it
187187
finds any variable placeholders that haven't been replaced.
188188

189+
If a script contains jinja-style syntax that should not be processed by schemachange, add the comment
190+
`-- schemachange-no-jinja` anywhere in the file. When this marker is present, schemachange will skip jinja rendering for
191+
that script and execute it as-is.
192+
189193
#### Secrets filtering
190194

191195
While many CI/CD tools already have the capability to filter secrets, it is best that any tool also does not output
@@ -226,6 +230,10 @@ These files can be stored in the root-folder but schemachange also provides a se
226230
folder `--modules-folder`. This allows common logic to be stored outside of the main changes scripts.
227231
The [demo/citibike_demo_jinja](demo/citibike_demo_jinja) has a simple example that demonstrates this.
228232

233+
schemachange uses Jinja's [`PrefixLoader`](https://jinja.palletsprojects.com/en/stable/api/#jinja2.PrefixLoader), so
234+
regardless of the `--modules-folder` that's used, the file paths (such as those passed to [`include`](https://jinja.palletsprojects.com/en/stable/templates/#include))
235+
should be prefixed with `modules/`.
236+
229237
The Jinja auto-escaping feature is disabled in schemachange, this feature in Jinja is currently designed for where the
230238
output language is HTML/XML. So if you are using schemachange with untrusted inputs you will need to handle this within
231239
your change scripts.

demo/basics_demo/1_setup/A__setup.sql

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
22
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
33
-- Dependent Variables; Change the naming pattern if you want but not necessary
4-
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
5-
-- Including hyphen in the role to test for hyphenated role support
6-
SET DEPLOY_ROLE = '"' || $TARGET_DB_NAME || '-DEPLOY"'; -- This role will be granted privileges to create objects in any schema in the database
4+
SET ADMIN_ROLE = '"' || $TARGET_DB_NAME || '-ADMIN"'; -- This role will be granted privileges to create objects in any schema in the database
75
SET WAREHOUSE_NAME = $TARGET_DB_NAME || '_WH';
86
SET SCHEMACHANGE_NAMESPACE = $TARGET_DB_NAME || '.' || $TARGET_SCHEMA_NAME;
97
SET SC_M = 'SC_M_' || $TARGET_SCHEMA_NAME;
@@ -28,10 +26,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_M) TO DATABASE ROLE IDENTIFIER($SC_R);
2826
GRANT DATABASE ROLE IDENTIFIER($SC_R) TO DATABASE ROLE IDENTIFIER($SC_W);
2927
GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C);
3028

31-
CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS;
32-
-- USE SCHEMA INFORMATION_SCHEMA;
33-
-- DROP SCHEMA IF EXISTS PUBLIC;
34-
GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE) REVOKE CURRENT GRANTS;
29+
CREATE TRANSIENT SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS;
3530

3631
USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE);
3732
-- SCHEMA

demo/basics_demo/3_teardown/A__teardown.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
22
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
33
-- Dependent Variables; Change the naming pattern if you want but not necessary
4-
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
5-
-- Including hyphen in the role to test for hyphenated role support
6-
SET DEPLOY_ROLE = '"' || $TARGET_DB_NAME || '-DEPLOY"'; -- This role will be granted privileges to create objects in any schema in the database
4+
SET ADMIN_ROLE = '"' || $TARGET_DB_NAME || '-ADMIN"'; -- This role will be granted privileges to create objects in any schema in the database
75
SET WAREHOUSE_NAME = $TARGET_DB_NAME || '_WH';
86
SET SCHEMACHANGE_NAMESPACE = $TARGET_DB_NAME || '.' || $TARGET_SCHEMA_NAME;
97
SET SC_M = 'SC_M_' || $TARGET_SCHEMA_NAME;

demo/citibike_demo/1_setup/A__setup.sql

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
22
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
33
-- Dependent Variables; Change the naming pattern if you want but not necessary
4-
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
5-
-- Including hyphen in the role to test for hyphenated role support
6-
SET DEPLOY_ROLE = '"' || $TARGET_DB_NAME || '-DEPLOY"'; -- This role will be granted privileges to create objects in any schema in the database
4+
SET ADMIN_ROLE = '"' || $TARGET_DB_NAME || '-ADMIN"'; -- This role will be granted privileges to create objects in any schema in the database
75
SET WAREHOUSE_NAME = $TARGET_DB_NAME || '_WH';
86
SET SCHEMACHANGE_NAMESPACE = $TARGET_DB_NAME || '.' || $TARGET_SCHEMA_NAME;
97
SET SC_M = 'SC_M_' || $TARGET_SCHEMA_NAME;
@@ -28,10 +26,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_M) TO DATABASE ROLE IDENTIFIER($SC_R);
2826
GRANT DATABASE ROLE IDENTIFIER($SC_R) TO DATABASE ROLE IDENTIFIER($SC_W);
2927
GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C);
3028

31-
CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS;
32-
-- USE SCHEMA INFORMATION_SCHEMA;
33-
-- DROP SCHEMA IF EXISTS PUBLIC;
34-
GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE) REVOKE CURRENT GRANTS;
29+
CREATE TRANSIENT SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS;
3530

3631
USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE);
3732
-- SCHEMA

demo/citibike_demo/3_teardown/A__teardown.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
22
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
33
-- Dependent Variables; Change the naming pattern if you want but not necessary
4-
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
5-
-- Including hyphen in the role to test for hyphenated role support
6-
SET DEPLOY_ROLE = '"' || $TARGET_DB_NAME || '-DEPLOY"'; -- This role will be granted privileges to create objects in any schema in the database
4+
SET ADMIN_ROLE = '"' || $TARGET_DB_NAME || '-ADMIN"'; -- This role will be granted privileges to create objects in any schema in the database
75
SET WAREHOUSE_NAME = $TARGET_DB_NAME || '_WH';
86
SET SCHEMACHANGE_NAMESPACE = $TARGET_DB_NAME || '.' || $TARGET_SCHEMA_NAME;
97
SET SC_M = 'SC_M_' || $TARGET_SCHEMA_NAME;

demo/citibike_demo_jinja/1_setup/A__setup.sql

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
22
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
33
-- Dependent Variables; Change the naming pattern if you want but not necessary
4-
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
5-
-- Including hyphen in the role to test for hyphenated role support
6-
SET DEPLOY_ROLE = '"' || $TARGET_DB_NAME || '-DEPLOY"'; -- This role will be granted privileges to create objects in any schema in the database
4+
SET ADMIN_ROLE = '"' || $TARGET_DB_NAME || '-ADMIN"'; -- This role will be granted privileges to create objects in any schema in the database
75
SET WAREHOUSE_NAME = $TARGET_DB_NAME || '_WH';
86
SET SCHEMACHANGE_NAMESPACE = $TARGET_DB_NAME || '.' || $TARGET_SCHEMA_NAME;
97
SET SC_M = 'SC_M_' || $TARGET_SCHEMA_NAME;
@@ -28,10 +26,7 @@ GRANT DATABASE ROLE IDENTIFIER($SC_M) TO DATABASE ROLE IDENTIFIER($SC_R);
2826
GRANT DATABASE ROLE IDENTIFIER($SC_R) TO DATABASE ROLE IDENTIFIER($SC_W);
2927
GRANT DATABASE ROLE IDENTIFIER($SC_W) TO DATABASE ROLE IDENTIFIER($SC_C);
3028

31-
CREATE SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS;
32-
-- USE SCHEMA INFORMATION_SCHEMA;
33-
-- DROP SCHEMA IF EXISTS PUBLIC;
34-
GRANT OWNERSHIP ON SCHEMA IDENTIFIER($TARGET_SCHEMA_NAME) TO ROLE IDENTIFIER($DEPLOY_ROLE) REVOKE CURRENT GRANTS;
29+
CREATE TRANSIENT SCHEMA IF NOT EXISTS IDENTIFIER($TARGET_SCHEMA_NAME) WITH MANAGED ACCESS;
3530

3631
USE SCHEMA IDENTIFIER($SCHEMACHANGE_NAMESPACE);
3732
-- SCHEMA

demo/citibike_demo_jinja/3_teardown/A__teardown.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
22
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
33
-- Dependent Variables; Change the naming pattern if you want but not necessary
4-
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
5-
-- Including hyphen in the role to test for hyphenated role support
6-
SET DEPLOY_ROLE = '"' || $TARGET_DB_NAME || '-DEPLOY"'; -- This role will be granted privileges to create objects in any schema in the database
4+
SET ADMIN_ROLE = '"' || $TARGET_DB_NAME || '-ADMIN"'; -- This role will be granted privileges to create objects in any schema in the database
75
SET WAREHOUSE_NAME = $TARGET_DB_NAME || '_WH';
86
SET SCHEMACHANGE_NAMESPACE = $TARGET_DB_NAME || '.' || $TARGET_SCHEMA_NAME;
97
SET SC_M = 'SC_M_' || $TARGET_SCHEMA_NAME;

0 commit comments

Comments
 (0)