Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Auto<T> fails to forward T::FOREIGN_KEY, causing wrapped foreign-key fields to lose their metadata and migration generation to omit the corresponding constraint.
1 open issue
What changed in this PR
Adds database-field metadata to support compiler-based migration generation, reducing reliance on source-code parsing.
Changes:
- Introduces documented
AUTOandFOREIGN_KEYconstants onDatabaseField. - Adds metadata implementations for
Auto,ForeignKey, andOption. - Tests metadata values for basic fields and wrapped types.
| File | Description |
|---|---|
cot/src/db/fields.rs |
Implements field metadata and forwarding through Option. |
cot/src/db.rs |
Defines and documents the constants and adds metadata tests. |
Review effort: Balanced
| impl<T: DatabaseField> DatabaseField for Auto<T> { | ||
| const NULLABLE: bool = T::NULLABLE; | ||
| const TYPE: ColumnType = T::TYPE; | ||
| const AUTO: bool = true; |
|
| Project | cot |
| Branch | migration-generator-rework-1 |
| 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 | 8,959.80 µs(-23.73%)Baseline: 11,748.10 µs | 18,919.13 µs (47.36%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 967.37 µs(+1.83%)Baseline: 949.95 µs | 1,372.05 µs (70.51%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 934.19 µs(+3.17%)Baseline: 905.45 µs | 1,285.54 µs (72.67%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 875.44 µs(+1.69%)Baseline: 860.89 µs | 1,233.50 µs (70.97%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 16,124.00 µs(-0.51%)Baseline: 16,207.01 µs | 22,818.17 µs (70.66%) |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
ElijahAhianyo
approved these changes
Nov 28, 2026
This branch has not been deployed
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.

Description
This adds
AUTOandFOREIGN_KEYassociated constants to theDatabaseFieldtrait. Before this change, the code didn't have a reliable way to tell whether a specific model field has a default value or is a foreign key, and we need that to generate migrations.This is part of the initiative to rework the migration generator to use the compiler rather than rely on dumb source code parsing.
Type of change