-
-
Notifications
You must be signed in to change notification settings - Fork 37
feat(orm): support custom migrations #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
| Branch | custom-migrations |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 5,671.20 µs(-5.11%)Baseline: 5,976.29 µs | 7,016.82 µs (80.82%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,026.40 µs(+0.56%)Baseline: 1,020.67 µs | 1,152.78 µs (89.04%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 949.46 µs(+0.93%)Baseline: 940.68 µs | 1,055.23 µs (89.98%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 915.10 µs(+1.47%)Baseline: 901.87 µs | 1,012.96 µs (90.34%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 16,763.00 µs(-4.83%)Baseline: 17,613.55 µs | 20,900.45 µs (80.20%) |
This adds support for user-defined migrations that might contain arbitrary code in them. This is primarily useful for data migrations which do not modify the schema, but fill in the data in the database instead. This extends the migration engine to support a new type of migrations, as well as cot-cli with a new command that creates a new custom migration.
ca9e1b8 to
2104d84
Compare
11d8817 to
4475202
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for custom migrations to the Cot ORM, allowing developers to define data migrations with arbitrary code that don't modify the database schema.
Changes:
- Added
MigrationContext,CustomOperationFn, andCustomBuilderto the migration engine for defining custom migration operations - Implemented
migration_opattribute macro to transform async functions into migration operations - Added
cot migration newCLI command to create custom migrations with a user-defined name
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| cot/src/db/migrations.rs | Core implementation of custom migrations including the context type, operation builder, and execution logic |
| cot-macros/src/migration_op.rs | Macro implementation that transforms async functions to return pinned boxed futures |
| cot-macros/src/lib.rs | Export of the new migration_op macro |
| cot-macros/tests/ui/attr_migration_op.rs | UI test for correct usage of the macro |
| cot-macros/tests/ui/attr_migration_op_not_async.stderr | Expected error output for non-async functions |
| cot-macros/tests/ui/attr_migration_op_not_async.rs | UI test for error case |
| cot-macros/tests/compile_tests.rs | Test registration for macro compile tests |
| cot-cli/src/migration_generator.rs | Generator for custom migration files and refactored naming logic |
| cot-cli/src/main.rs | CLI command routing for the new migration command |
| cot-cli/src/handlers.rs | Handler implementation for creating custom migrations |
| cot-cli/src/args.rs | CLI argument definitions for the new command |
| cot-cli/tests/migration_generator.rs | Tests for custom migration generation and compilation |
| cot-cli/tests/snapshot_testing/help/snapshots/*.snap | Updated help text snapshots showing the new command |
| cot-cli/tests/snapshot_testing/cli/snapshots/*.snap | Updated shell completion snapshots for the new command |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
seqre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it LGTM, please write more tests before merging
This adds support for user-defined migrations that might contain arbitrary code in them. This is primarily useful for data migrations which do not modify the schema, but fill in the data in the database instead.
This extends the migration engine to support a new type of migrations, as well as cot-cli with a new command that creates a new custom migration.
Fixes #211.