Make Dangerfile Migration Check Align With Strong Migrations Guidance
Introduction
As a maintainer of vets-api, it is essential to ensure that the Dangerfile checks are nuanced and do not incorrectly fail or overly restrict PRs that follow strong_migrations guidelines. The current MigrationIsolator
section of the Dangerfile fails any PR that contains both schema changes and application code changes. However, this is an overly strict approach, as certain migration patterns (like remove_column
) require additional changes to application code, such as updating Active Record's schema cache. In this article, we will evaluate the Strong Migrations guidance, determine what types of changes are acceptable to include alongside migrations, and update the Dangerfile logic to reflect these nuances.
Understanding Strong Migrations Guidance
The Strong Migrations README provides guidance on what types of changes are acceptable to include alongside migrations. According to the README, certain migration patterns, such as remove_column
, require additional changes to application code. These changes are valid and sometimes necessary. It is essential to understand these nuances and update the Dangerfile logic to reflect them.
Reviewing the Strong Migrations README
To update the Dangerfile logic, we need to review the remove_column
section (and others) of the Strong Migrations README. This will help us identify which code changes should be allowed in migration PRs (e.g., ignore_columns
).
Remove Column Section
The remove_column
section of the Strong Migrations README provides guidance on how to remove columns from a table. According to the README, when removing a column, it is essential to update the application code to reflect the change. This may involve updating Active Record's schema cache.
Ignore Columns
The ignore_columns
section of the Strong Migrations README provides guidance on how to ignore certain columns when running migrations. According to the README, when ignoring columns, it is essential to update the application code to reflect the change.
Updating the Dangerfile Logic
To update the Dangerfile logic, we need to identify which code changes should be allowed in migration PRs. We can do this by reviewing the Strong Migrations README and identifying the nuances of each migration pattern.
MigrationIsolator Section
The MigrationIsolator
section of the Dangerfile currently fails any PR that contains both schema changes and application code changes. However, this is an overly strict approach, as certain migration patterns (like remove_column
) require additional changes to application code. To update the Dangerfile logic, we need to modify the MigrationIsolator
section to allow valid code changes as defined in strong_migrations.
Danger Message Output
To provide more context to the user, we can update the Danger message output to include a link to the strong_migrations README. This will help users understand the nuances of each migration pattern and how to update their application code accordingly.
Creating a PR to Implement the Updates
To implement the updates, we need to create a PR that reflects the changes to the Dangerfile logic. PR should include the updated MigrationIsolator
section and the updated Danger message output.
Acceptance Criteria
To confirm that the issue is complete, we need to meet the following acceptance criteria:
- The Dangerfile allows valid code changes as defined in strong_migrations while still flagging unsafe patterns.
- A PR is merged that reflects these updates to the Dangerfile.
- Create PRs to test the logic.
Validation
To confirm that the issue is complete, we need to take the following actions:
- Review the updated Dangerfile logic to ensure that it allows valid code changes as defined in strong_migrations.
- Test the updated Dangerfile logic by creating PRs that reflect the changes.
- Verify that the Danger message output includes a link to the strong_migrations README.
- Merge the PR that reflects the updates to the Dangerfile logic.
Q: What is the current issue with the Dangerfile migration check?
A: The current MigrationIsolator
section of the Dangerfile fails any PR that contains both schema changes and application code changes. However, this is an overly strict approach, as certain migration patterns (like remove_column
) require additional changes to application code.
Q: What is Strong Migrations, and why is it important?
A: Strong Migrations is a gem that provides guidance on how to write safe and predictable database migrations. It helps to prevent common migration mistakes and ensures that database schema changes are properly tested and validated.
Q: What are the nuances of each migration pattern that need to be considered?
A: Each migration pattern has its own set of nuances that need to be considered. For example, when removing a column, it is essential to update the application code to reflect the change. Similarly, when ignoring columns, it is essential to update the application code to reflect the change.
Q: How can we update the Dangerfile logic to reflect these nuances?
A: We can update the Dangerfile logic by modifying the MigrationIsolator
section to allow valid code changes as defined in strong_migrations. We can also update the Danger message output to include a link to the strong_migrations README, which will help users understand the nuances of each migration pattern.
Q: What are the acceptance criteria for confirming that the issue is complete?
A: The acceptance criteria for confirming that the issue is complete are:
- The Dangerfile allows valid code changes as defined in strong_migrations while still flagging unsafe patterns.
- A PR is merged that reflects these updates to the Dangerfile.
- Create PRs to test the logic.
Q: How can we validate that the issue is complete?
A: We can validate that the issue is complete by taking the following actions:
- Review the updated Dangerfile logic to ensure that it allows valid code changes as defined in strong_migrations.
- Test the updated Dangerfile logic by creating PRs that reflect the changes.
- Verify that the Danger message output includes a link to the strong_migrations README.
- Merge the PR that reflects the updates to the Dangerfile logic.
Q: What are the benefits of updating the Dangerfile logic to align with Strong Migrations guidance?
A: The benefits of updating the Dangerfile logic to align with Strong Migrations guidance include:
- Improved code quality and predictability
- Reduced risk of migration mistakes and database schema changes
- Enhanced user experience through more informative and helpful error messages
- Better alignment with industry best practices and standards
Q: How can we get started with updating the Dangerfile logic to align with Strong Migrations guidance?
A: To get started with updating the Dangerfile logic to align with Strong Migrations guidance, follow these steps:
- Review the Strong Migrations README to understand the nuances of each migration pattern.
- Update the Dangerfile logic to allow valid code changes as defined in strong_migrations.
- Update the Danger message output to include a link to the strong_migrations README.
- Create a PR to implement the updates and test the logic.
- Merge the PR that reflects the updates to the Dangerfile logic.