This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a GitOps demonstration repository for database CI/CD using Bytebase and GitHub Actions with GitHub Flow. The repository shows how to integrate database schema changes with application deployment pipelines.
migrations-semver/: Contains SQL migration files following semantic versioning naming convention (e.g.,1.0.0_init.sql,1.1.1_comment.sql)schema/: Contains base database schema definitions.github/workflows/: GitHub Actions workflows for CI/CD pipeline
Migration files MUST follow semantic versioning pattern: {major}.{minor}.{patch}_{description}.sql
- Examples:
1.0.0_init.sql,1.1.1_comment.sql,1.13.0_phone.sql - Files are processed by Bytebase in semantic version order
- Triggers on pull requests to
mainbranch whenmigrations-semver/*.sqlfiles change - Uses
bytebase/bytebase-action:latestDocker image - Runs SQL validation against production database
- Requires
BYTEBASE_SERVICE_ACCOUNT_SECRETrepository secret
- Triggers on push to
mainbranch whenmigrations-semver/*.sqlfiles change - Three-stage process:
build: Mock application build stepcreate-rollout: Creates Bytebase rollout plan for both test and prod databasesdeploy-to-test: Deploys to test environment automaticallydeploy-to-prod: Deploys to production (requires manual approval via GitHub environment protection)
Both workflows use these environment variables:
BYTEBASE_URL: Bytebase instance URLBYTEBASE_SERVICE_ACCOUNT: Service account emailBYTEBASE_SERVICE_ACCOUNT_SECRET: Service account password (stored in GitHub secrets)BYTEBASE_PROJECT: Target Bytebase projectBYTEBASE_TARGETS: Comma-separated list of database targetsFILE_PATTERN: Glob pattern for migration files (migrations-semver/*.sql)
The schema includes:
- Employee management system with tables:
employee,department,dept_manager,dept_emp,title,salary - Audit logging system with trigger-based change tracking
- Views for current department assignments
- Create feature branch
- Add SQL migration files to
migrations-semver/with proper semantic versioning - Create pull request - triggers SQL review workflow
- Merge to main - triggers release workflow
- Test environment deployment happens automatically
- Production deployment requires manual approval through GitHub environment protection
- All database changes go through Bytebase for review and deployment
- GitHub environment protection rules control production deployments
- Migration files are validated against actual database schemas during PR review