Skip to content
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

Support "Remove Model" in Automatic Migration Generator #221

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

Soroushsrd
Copy link
Contributor

This adds support for automatically detecting when models are removed from the codebase and generating the appropriate migration operations. Now when a model exists in the database schema but has been removed from the application code, the migration generator will create a RemoveModel operation to drop the corresponding table.

Changes

  • Added a new RemoveModel variant to OperationInner enum
  • Implemented a RemoveModelBuilder to support the fluent builder pattern
  • Implemented the make_remove_model_operation function in migration_generator.rs
  • Updated remove_dependency and get_ops_adding_foreign_keys to handle the new operation type
  • Added unit tests for the new functionality

Fixes #207

@Soroushsrd Soroushsrd force-pushed the feature/remove-model-operation branch 2 times, most recently from 07eefc1 to 30ce2ef Compare March 3, 2025 21:29
Implement the ability to detect when a model has been removed from the
codebase and generate appropriate migration operations.
This includes:
- Add RemoveModel variant to OperationInner enum in migrations.rs
- Create RemoveModelBuilder for constructing remove operations
- Implement make_remove_model_operation in migration_generator.rs
- Update relevant utility functions to handle the new operation type
- Add tests for the new functionality
Fixes cot-rs#207
@Soroushsrd Soroushsrd force-pushed the feature/remove-model-operation branch from 30ce2ef to a9c7249 Compare March 3, 2025 21:42
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 78.83598% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cot/src/db/migrations.rs 62.50% 20 Missing and 1 partial ⚠️
cot-cli/src/migration_generator.rs 85.71% 19 Missing ⚠️
Flag Coverage Δ
rust 78.72% <78.83%> (+0.11%) ⬆️

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 82.39% <85.71%> (+1.10%) ⬆️
cot/src/db/migrations.rs 83.38% <62.50%> (-2.15%) ⬇️

... and 1 file with indirect coverage changes

@seqre seqre enabled auto-merge (squash) March 4, 2025 10:20
@seqre seqre merged commit 30cf784 into cot-rs:master Mar 4, 2025
18 checks passed
@cotbot cotbot bot mentioned this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suppport "remove model" in automatic migration generator
2 participants