Skip to content

fix(db): reject application models in migrations - #625

Merged
m4tx merged 3 commits into
cot-rs:masterfrom
Guflly:fix/migration-model-guard
Aug 3, 2026
Merged

fix(db): reject application models in migrations#625
m4tx merged 3 commits into
cot-rs:masterfrom
Guflly:fix/migration-model-guard

Conversation

@Guflly

@Guflly Guflly commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #623. Custom migrations now reject application models before they can access the database. Migration models and raw SQL keep working. Tested with the full cot suite, the macro suite, and clippy.

@github-actions github-actions Bot added C-lib Crate: cot (main library crate) C-macros Crate: cot-macros labels Jul 27, 2026
@Guflly
Guflly marked this pull request as ready for review July 27, 2026 18:40
Comment thread cot/src/db.rs Outdated
Comment thread cot/src/db.rs Outdated
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.93151% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cot/src/db.rs 78.78% 0 Missing and 7 partials ⚠️
cot/src/db/migrations.rs 88.57% 1 Missing and 3 partials ⚠️
Flag Coverage Δ
rust 90.42% <84.93%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot-macros/src/model.rs 96.52% <100.00%> (+0.15%) ⬆️
cot/src/db/migrations.rs 83.80% <88.57%> (+0.33%) ⬆️
cot/src/db.rs 88.39% <78.78%> (-0.44%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Guflly

Guflly commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated both. Database now uses DatabaseContext, and models expose a public non-exhaustive ModelType. The Cot and macro test suites and clippy pass.

Comment thread cot/src/db.rs

@seqre seqre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution and from my side it seems fine! I'll leave the final call to @m4tx

@Guflly
Guflly force-pushed the fix/migration-model-guard branch from ce735a6 to 0aaa8bd Compare August 2, 2026 20:48
@Guflly
Guflly requested a review from m4tx August 2, 2026 20:48

@m4tx m4tx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks a lot for this!

@m4tx
m4tx enabled auto-merge (squash) August 3, 2026 16:50
@m4tx
m4tx merged commit 140c75f into cot-rs:master Aug 3, 2026
24 checks passed
@cotbot cotbot Bot mentioned this pull request Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate) C-macros Crate: cot-macros

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of regular models in custom migrations should not be allowed

3 participants