feat(migration): add auto-migration generation from models#2102
Merged
feat(migration): add auto-migration generation from models#2102
Conversation
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>
d80191a to
13aa009
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AutoMigrator.cfc— a schema diff engine that compares model properties against current DB columnsdiff(modelName)returns{addColumns, removeColumns, changeColumns}for a single modeldiffAll()iterates all registered models and returns combined diff resultsgenerateMigrationCFC()produces a complete migration CFC withup()anddown()methods using the Wheels migration DSLwriteMigration()writes the generated CFC toapp/migrator/migrations/with proper timestamp prefixCloses the auto-migration gap (vs Django's
makemigrations) identified indocs/wheels-vs-frameworks.md.Test plan
bash tools/test-local.sh— all existing tests passvendor/wheels/tests/specs/migrator/autoMigratorSpec.cfcpassdiff()against known model with schema mismatch🤖 Generated with Claude Code