# pavandevopsengineer/snowflake-ci-cd-schema-change architecture

> Architecture diagram of the GitHub repository pavandevopsengineer/snowflake-ci-cd-schema-change, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pavandevopsengineer/snowflake-ci-cd-schema-change
- Repository: https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change

## Overview

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: [`scripts/deploy.py`](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/deploy.py) (Deploy CLI), [`.github/workflows`](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows) (GitHub Actions), [`.github/workflows/feature-deploy.yml`](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/feature-deploy.yml) (Feature deploy), [`.github/workflows/develop-deploy.yml`](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/develop-deploy.yml) (Develop deploy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_ci["CI/CD"]
  node_workflow_feature["Feature deploy<br/>workflow<br/>[feature-deploy.yml]"]
  node_workflow_develop["Develop deploy<br/>workflow<br/>[develop-deploy.yml]"]
  node_workflow_main["Main deploy<br/>workflow<br/>[main-deploy.yml]"]
  node_workflow_hotfix["Hotfix deploy<br/>workflow<br/>[hotfix-deploy.yml]"]
end

subgraph group_group_scripts["Scripts"]
  node_deploy_cli["Deploy CLI<br/>python entrypoint<br/>[deploy.py]"]
  node_migration_state[("Migration state<br/>snowflake tables")]
  node_placeholder_swap["Placeholder swap<br/>sql preprocessing"]
  node_generate_migration["Scaffold migration"]
  node_validate_schema["Schema check<br/>validator<br/>[validate_schema.py]"]
  node_validate_workflows["Workflow check<br/>validator"]
  node_test_secrets["Secret check<br/>preflight<br/>[test_secrets.py]"]
end

subgraph group_group_migrations["Migrations"]
  node_ddl_migrations["DDL migrations<br/>sql changes"]
  node_dml_migrations["DML migrations<br/>sql seed data"]
end

subgraph group_group_config["Config"]
  node_env_config["Env config<br/>yaml settings"]
end

subgraph group_group_docs["Docs"]
  node_branch_docs["Branching guide<br/>process docs"]
  node_deploy_guide["Deploy guide<br/>process docs"]
end

subgraph group_group_outputs["Outputs"]
  node_deploy_log["Deploy log<br/>artifact"]
end

node_github_actions(("GitHub Actions<br/>orchestrator<br/>[workflows]"))
node_snowflake[("Snowflake<br/>database platform")]

node_github_actions -->|"triggers"| node_workflow_feature
node_github_actions -->|"triggers"| node_workflow_develop
node_github_actions -->|"triggers"| node_workflow_main
node_github_actions -->|"triggers"| node_workflow_hotfix
node_workflow_feature -->|"invokes"| node_deploy_cli
node_workflow_develop -->|"invokes"| node_deploy_cli
node_workflow_main -->|"invokes"| node_deploy_cli
node_workflow_hotfix -->|"invokes"| node_deploy_cli
node_workflow_feature -->|"checks"| node_validate_workflows
node_workflow_develop -->|"checks"| node_validate_workflows
node_workflow_main -->|"checks"| node_validate_workflows
node_workflow_hotfix -->|"checks"| node_validate_workflows
node_deploy_cli -->|"preprocesses"| node_placeholder_swap
node_deploy_cli -->|"applies"| node_ddl_migrations
node_deploy_cli -->|"applies"| node_dml_migrations
node_deploy_cli -->|"records"| node_migration_state
node_deploy_cli -->|"connects"| node_snowflake
node_deploy_cli -->|"loads"| node_env_config
node_deploy_cli -->|"validates"| node_validate_schema
node_deploy_cli -->|"scaffolds"| node_generate_migration
node_deploy_cli -->|"preflights"| node_test_secrets
node_workflow_feature -->|"uploads"| node_deploy_log
node_workflow_develop -->|"uploads"| node_deploy_log
node_workflow_main -->|"uploads"| node_deploy_log
node_workflow_hotfix -->|"uploads"| node_deploy_log
node_branch_docs -.->|"explains"| node_github_actions
node_deploy_guide -.->|"documents"| node_deploy_cli
node_env_config -->|"targets"| node_snowflake

click node_github_actions "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows"
click node_workflow_feature "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/feature-deploy.yml"
click node_workflow_develop "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/develop-deploy.yml"
click node_workflow_main "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/main-deploy.yml"
click node_workflow_hotfix "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/hotfix-deploy.yml"
click node_deploy_cli "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/deploy.py"
click node_generate_migration "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/generate_migration.py"
click node_validate_schema "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/validate_schema.py"
click node_validate_workflows "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/validate_workflows.py"
click node_test_secrets "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/test_secrets.py"
click node_ddl_migrations "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/tree/main/migrations/ddl"
click node_dml_migrations "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/tree/main/migrations/dml"
click node_env_config "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/tree/main/config"
click node_branch_docs "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/docs/branching-strategy.md"
click node_deploy_guide "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/docs/deployment-guide.md"
click node_deploy_log "https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/artifacts/deploy-dev-20260602T082449Z.log"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workflow_feature,node_workflow_develop,node_workflow_main,node_workflow_hotfix toneBlue
class node_deploy_cli,node_migration_state,node_placeholder_swap,node_generate_migration,node_validate_schema,node_validate_workflows,node_test_secrets toneAmber
class node_ddl_migrations,node_dml_migrations toneMint
class node_env_config toneRose
class node_branch_docs,node_deploy_guide toneIndigo
class node_deploy_log toneTeal
class node_github_actions,node_snowflake toneNeutral
```

## Components

### CI/CD

GitHub Actions workflows and release gating

- [Feature deploy](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/feature-deploy.yml): workflow · Deploy path for feature branches · `.github/workflows/feature-deploy.yml`
- [Develop deploy](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/develop-deploy.yml): workflow · Deploy path for PRs into develop / QA · `.github/workflows/develop-deploy.yml`
- [Main deploy](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/main-deploy.yml): workflow · Deploy path for PRs into main / PROD · `.github/workflows/main-deploy.yml`
- [Hotfix deploy](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows/hotfix-deploy.yml): workflow · Deploy path for hotfix branches · `.github/workflows/hotfix-deploy.yml`

### Scripts

Python deployment engine and operational utilities

- [Deploy CLI](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/deploy.py): python entrypoint · Canonical CLI for deploy, rollback, validate, generate, and preflight · `scripts/deploy.py`
- **Migration state**: snowflake tables · Tracks applied files and prevents duplicate or concurrent runs
- **Placeholder swap**: sql preprocessing · Resolves <env> placeholders at deploy time
- [Scaffold migration](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/generate_migration.py): utility · Creates new migration file templates · `scripts/generate_migration.py`
- [Schema check](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/validate_schema.py): validator · Validates migration and schema correctness · `scripts/validate_schema.py`
- [Workflow check](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/validate_workflows.py): validator · Checks workflow definitions and deployment wiring · `scripts/validate_workflows.py`
- [Secret check](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/scripts/test_secrets.py): preflight · Verifies required Snowflake credentials before deployment · `scripts/test_secrets.py`

### Migrations

Versioned SQL changes delivered to Snowflake

- [DDL migrations](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/tree/main/migrations/ddl): sql changes · Versioned schema and object migrations · `migrations/ddl`
- [DML migrations](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/tree/main/migrations/dml): sql seed data · Versioned reference and seed data migrations · `migrations/dml`

### Config

Environment-specific deployment settings

- [Env config](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/tree/main/config): yaml settings · DEV, QA, and PROD Snowflake defaults and context · `config`

### Docs

Branching and deployment procedures

- [Branching guide](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/docs/branching-strategy.md): process docs · Explains branch-to-environment routing · `docs/branching-strategy.md`
- [Deploy guide](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/docs/deployment-guide.md): process docs · Documents deployment procedure and operational flow · `docs/deployment-guide.md`

### Outputs

Deployment artifacts and logs

- [Deploy log](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/artifacts/deploy-dev-20260602T082449Z.log): artifact · Structured deployment log uploaded for audit and debugging · `artifacts/deploy-dev-20260602T082449Z.log`

### Other components

- [GitHub Actions](https://github.com/pavandevopsengineer/snowflake-ci-cd-schema-change/blob/main/.github/workflows): orchestrator · Runs branch-based deployment workflows · `.github/workflows`
- **Snowflake**: database platform · Target system for schema and data changes

## Connections

- 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
