Skip to content

feat(migration): add auto-migration generation from models#2102

Merged
bpamiri merged 2 commits intodevelopfrom
peter/auto-migrations
Apr 15, 2026
Merged

feat(migration): add auto-migration generation from models#2102
bpamiri merged 2 commits intodevelopfrom
peter/auto-migrations

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 15, 2026

Summary

  • Adds AutoMigrator.cfc — a schema diff engine that compares model properties against current DB columns
  • diff(modelName) returns {addColumns, removeColumns, changeColumns} for a single model
  • diffAll() iterates all registered models and returns combined diff results
  • generateMigrationCFC() produces a complete migration CFC with up() and down() methods using the Wheels migration DSL
  • writeMigration() writes the generated CFC to app/migrator/migrations/ with proper timestamp prefix
  • Handles cf_sql type mapping, skips calculated properties and primary keys
  • Includes comprehensive BDD spec

Closes the auto-migration gap (vs Django's makemigrations) identified in docs/wheels-vs-frameworks.md.

Test plan

  • Run bash tools/test-local.sh — all existing tests pass
  • New tests in vendor/wheels/tests/specs/migrator/autoMigratorSpec.cfc pass
  • Test diff() against known model with schema mismatch
  • Verify generated migration CFC is valid and runnable

🤖 Generated with Claude Code

bpamiri and others added 2 commits April 14, 2026 22:51
Adds AutoMigrator.cfc that compares model property definitions against
current database schema and generates migration CFCs automatically.
Supports diff(), diffAll(), generateMigrationCFC(), and writeMigration().
Handles type mapping, skips calculated properties and primary keys.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ision

Sanitize migration name before using it as a filename to prevent
filesystem errors with special characters. Add millisecond precision
to the timestamp prefix to reduce collision risk on rapid successive
writeMigration() calls. Includes 8 tests for the sanitizer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bpamiri bpamiri force-pushed the peter/auto-migrations branch from d80191a to 13aa009 Compare April 15, 2026 05:52
@bpamiri bpamiri merged commit 5c4f347 into develop Apr 15, 2026
3 checks passed
@bpamiri bpamiri deleted the peter/auto-migrations branch April 15, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant