rust/spanner-migrations/README.md
Schema migrations for Spanner database.
Create a new SQL file in migrations/:
{version}-{description}.spanner.sql
Example: 0002-create_databases.spanner.sql
NOTE: THE MIGRATION FILE MUST HAVE ONLY ONE DDL STATEMENT AND MUST BE IDEMPOTENT.
Write your Spanner DDL in the file (one statement per file).
Regenerate the manifest (from rust/rust-sysdb/spanner-migrations/ directory):
cd rust/rust-sysdb/spanner-migrations
cargo run --bin spanner_migration -- --generate-sum
This writes directly to migrations/migrations.sum.
Commit both the new migration file and updated migrations.sum.
The migrations.sum file protects against:
If validation fails, regenerate the manifest and commit both the migration and updated migrations.sum.
# Apply migrations (default mode)
cargo run --bin spanner_migration
# Validate migrations are applied
cargo run --bin spanner_migration # with migration_mode: validate in config
Filename: {version}-{description}.spanner.sql
version: Zero-padded number (e.g., 0001, 0002)description: snake_case description.spanner.sqlManifest: migrations.sum
{filename} {sha256_hash}#