How pavandevopsengineer/snowflake-ci-cd-schema-change works
1. This repository is a Snowflake schema-change delivery system, not an application runtime. Its main purpose is to take SQL migrations from version control and apply them safely to Snowflake through GitHub Actions.
2. The central execution engine is scripts/deploy.py. It acts as the canonical CLI for deploy, rollback, validate, generate, and preflight operations, and it is the component that actually connects to Snowflake and executes migration SQL.
3. Migration inputs are split into two tracks: migrations/ddl/ for schema and object changes, and migrations/dml/ for reference/seed data. The migrations are versioned files, and the deploy tool tracks what has already been applied so it can skip duplicates.
4. Environment-specific behavior is driven by config/dev.yml, config/qa.yml, and config/prod.yml. These files define Snowflake connection defaults and environment context, so the same migration set can be deployed differently to DEV, QA, and PROD.
5. GitHub Actions is the orchestration layer. The workflows in .github/workflows/ map branch types to environments: feature branches deploy to DEV, PRs into develop deploy to QA, PRs into main deploy to PROD, and hotfix branches have their own path. Path filters ensure only migration changes trigger deploy logic.
6. The CI/CD pipeline has a clear gating sequence: checkout, install Python, validate scripts, verify secrets, run SQL placeholder substitution, and then invoke the deploy CLI. This makes the repo’s Python tooling part of the release boundary, not just a local convenience.
7. Snowflake itself is both the target system and part of the state-management layer. The deploy tool uses a schema_migrations table plus a lock table to record applied files and prevent concurrent runs from colliding.
8. SQL files can contain <env> placeholders that are resolved at deploy time. That means object names or other environment-specific references are templated inside the migration layer rather than hardcoded per environment.
9. There are supporting utilities in scripts/ that enforce operational discipline: generate_migration.py scaffolds new migration files, validate_schema.py and validate_workflows.py check correctness, and test_secrets.py verifies required Snowflake credentials before deployment.
10. artifacts/ holds structured deployment logs, which GitHub Actions uploads for auditability and debugging. This is an important output boundary: the pipeline is designed to leave an inspectable record of what was deployed and when.
11. The docs/ directory documents the branching strategy and deployment procedure, which is architecturally significant because the repo depends on merge behavior and branch naming to route deployments correctly.
12. The main external dependencies that materially shape the design are GitHub Actions for orchestration, Snowflake as the database platform, Python for the deployment CLI, and YAML for environment configuration. The overall data flow is: commit/PR event → workflow filters → Python deploy tool → Snowflake migrations/state tables → log artifact upload.
Main entry points: deploy.py Deploy CLI · workflows GitHub Actions · feature-deploy.yml Feature deploy · develop-deploy.yml Develop deploy
Components 19
CI/CD
GitHub Actions workflows and release gating
- Feature deploy · Deploy path for feature branches
.github/workflows/feature-deploy.yml - Develop deploy · Deploy path for PRs into develop / QA
.github/workflows/develop-deploy.yml - Main deploy · Deploy path for PRs into main / PROD
.github/workflows/main-deploy.yml - Hotfix deploy · Deploy path for hotfix branches
.github/workflows/hotfix-deploy.yml
Scripts
Python deployment engine and operational utilities
- Deploy CLI · Canonical CLI for deploy, rollback, validate, generate, and preflight
scripts/deploy.py - Migration state · Tracks applied files and prevents duplicate or concurrent runs
- Placeholder swap · Resolves <env> placeholders at deploy time
- Scaffold migration · Creates new migration file templates
scripts/generate_migration.py - Schema check · Validates migration and schema correctness
scripts/validate_schema.py - Workflow check · Checks workflow definitions and deployment wiring
scripts/validate_workflows.py - Secret check · Verifies required Snowflake credentials before deployment
scripts/test_secrets.py
Migrations
Versioned SQL changes delivered to Snowflake
- DDL migrations · Versioned schema and object migrations
migrations/ddl - DML migrations · Versioned reference and seed data migrations
migrations/dml
Config
Environment-specific deployment settings
- Env config · DEV, QA, and PROD Snowflake defaults and context
config
Docs
Branching and deployment procedures
- Branching guide · Explains branch-to-environment routing
docs/branching-strategy.md - Deploy guide · Documents deployment procedure and operational flow
docs/deployment-guide.md
Outputs
Deployment artifacts and logs
- Deploy log · Structured deployment log uploaded for audit and debugging
artifacts/deploy-dev-20260602T082449Z.log
Other components
- GitHub Actions · Runs branch-based deployment workflows
.github/workflows - Snowflake · Target system for schema and data changes
Connections 28
- GitHub Actions → Feature deploy: triggers · Feature branch events start the feature deployment workflow
- GitHub Actions → Develop deploy: triggers · PRs into develop start QA deployment
- GitHub Actions → Main deploy: triggers · PRs into main start PROD deployment
- GitHub Actions → Hotfix deploy: triggers · Hotfix branches follow a separate deployment path
- Feature deploy → Deploy CLI: invokes · Workflow gates culminate in the deploy CLI
- Develop deploy → Deploy CLI: invokes · Workflow gates culminate in the deploy CLI
- Main deploy → Deploy CLI: invokes · Workflow gates culminate in the deploy CLI
- Hotfix deploy → Deploy CLI: invokes · Workflow gates culminate in the deploy CLI
- Feature deploy → Workflow check: checks · Workflow definitions are validated as part of CI
- Develop deploy → Workflow check: checks · Workflow definitions are validated as part of CI
- Main deploy → Workflow check: checks · Workflow definitions are validated as part of CI
- Hotfix deploy → Workflow check: checks · Workflow definitions are validated as part of CI
- Deploy CLI → Placeholder swap: preprocesses · Resolves environment placeholders before execution
- Deploy CLI → DDL migrations: applies · Executes schema and object migrations
- Deploy CLI → DML migrations: applies · Executes reference and seed data migrations
- Deploy CLI → Migration state: records · Reads and writes migration state for idempotency and locking
- Deploy CLI → Snowflake: connects · Executes SQL against Snowflake
- Deploy CLI → Env config: loads · Uses environment-specific configuration for each deployment target
- Deploy CLI → Schema check: validates · Supports schema validation and preflight checks
- Deploy CLI → Scaffold migration: scaffolds · Creates new migration files when requested
- Deploy CLI → Secret check: preflights · Verifies required credentials before deployment
- Feature deploy → Deploy log: uploads · Deployment logs are preserved as artifacts
- Develop deploy → Deploy log: uploads · Deployment logs are preserved as artifacts
- Main deploy → Deploy log: uploads · Deployment logs are preserved as artifacts
- Hotfix deploy → Deploy log: uploads · Deployment logs are preserved as artifacts
- Branching guide → GitHub Actions: explains · Documents how branch strategy maps to deployment behavior
- Deploy guide → Deploy CLI: documents · Describes operational use of the deployment engine
- Env config → Snowflake: targets · Environment settings define Snowflake connection context