AshScylla.MigrationGenerator (AshScylla v1.0.7)

Copy Markdown View Source

Generates CQL migration files from Ash resource definitions.

Compares current Ash resource snapshots against the live ScyllaDB schema and generates CQL statements to bring the schema in sync.

Usage

# Generate a migration for all resources
mix ash_scylla.generate_migrations

# Generate with a specific name
mix ash_scylla.generate_migrations add_user_table

# Dry run (print without creating files)
mix ash_scylla.generate_migrations --dry-run

# Check if migrations are needed (exit code 1 if so)
mix ash_scylla.generate_migrations --check

Snapshots

Snapshots are stored in priv/repo_name/resource_snapshots/ as JSON files. Each snapshot captures the state of a resource's schema at a point in time. The migration generator compares the current resource definition against the most recent snapshot to determine what changes need to be made.

Summary

Functions

Main entry point for migration generation.

Takes snapshots of the given resources without generating migrations. Useful for initial setup.

Functions

generate(opts \\ [])

Main entry point for migration generation.

Options:

  • :domains - list of domains to generate for (defaults to all configured)
  • :snapshot_path - custom path for snapshots (default: priv/repo/resource_snapshots)
  • :migration_path - custom path for migrations (default: priv/repo/migrations)
  • :name - name for the migration (auto-generated if not provided)
  • :quiet - suppress output
  • :format - format generated Elixir code (default: true)
  • :dry_run - print migrations without creating files
  • :check - return exit code 1 if migrations needed
  • :dev - create dev migrations (suffixed with _dev)
  • :snapshots_only - only create snapshots, no migration files

take_snapshots(opts \\ [])

Takes snapshots of the given resources without generating migrations. Useful for initial setup.