Skip to content

fix(migrations): keep explicit table names in generated migration models - #726

Open
shadowcpy wants to merge 1 commit into
cot-rs:masterfrom
shadowcpy:fix-migr-tablename
Open

shadowcpy wants to merge 1 commit into
cot-rs:masterfrom
shadowcpy:fix-migr-tablename

Conversation

@shadowcpy

Copy link
Copy Markdown

The migration generator clears all attributes of a model when writing it into a migration file, including an explicit table_name. The migration model then derived its table name from its own struct name, so the next cot migration make compared it against a different table and generated a bogus remove/create pair for every model with a custom table name.

Related issue or discussion

Necessary work for the Auth Refactor, see #634

Description

When generating the migration model, the table name attribute is preserved such that the generator recognizes the model in a future migration.

A test is added to ensure this behaviour does not break in the future.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / cleanup
  • Performance improvement
  • Other (describe above)

Checklist

  • I've read the contributing guide
  • Tests pass locally (just test-all)
  • Code passes clippy (just clippy)
  • Code is properly formatted (cargo fmt)
  • New tests added (regression test for bugs, coverage for new features)
  • Documentation (both code and site) updated (if applicable)

@github-actions github-actions Bot added the C-cli Crate: cot-cli (issues and Pull Requests related to Cot CLI) label Nov 5, 2026
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
rust 91.10% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
cot-cli/src/migration_generator.rs 89.49% <100.00%> (+0.12%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added C-lib Crate: cot (main library crate) C-core labels Nov 5, 2026
The migration generator cleared all attributes of a model when writing it
into a migration file, including an explicit `table_name`. The migration
model then derived its table name from its own struct name, so the next
`cot migration make` compared it against a different table and generated
a bogus remove/create pair for every model with a custom table name.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cli Crate: cot-cli (issues and Pull Requests related to Cot CLI) C-core C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant