Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the support_table_data gem to automatically synchronize support table data when running common Rails database tasks. The main change introduces automatic task hooks that trigger the data synchronization after tasks like db:seed, db:prepare, and db:test:prepare, with a configuration option to disable this behavior.
Key changes:
- Automatic synchronization task hooks for common Rails database tasks (configurable via
config.support_table.auto_sync) - Refactored
support_table_key_attributeimplementation to use a private backing attribute with explicit default behavior - New
ValidationErrorclass that provides better context when validation failures occur during data synchronization
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/support_table_data/railtie.rb | Added auto-sync functionality that enhances Rails database tasks and restructured configuration to use config.support_table namespace |
| lib/support_table_data.rb | Refactored support_table_key_attribute to use a private backing attribute and wrap validation errors with more context |
| lib/support_table_data/validation_error.rb | New custom error class that provides detailed validation failure information including model class and key values |
| test_app/lib/tasks/database.rake | Example implementation showing how to hook sync into db:migrate task with connection re-establishment |
| test_app/db/support_tables/things.yml | Added test data file for the new Thing model |
| test_app/db/secondary_schema.rb | Added schema for secondary database with things and statuses tables |
| test_app/db/secondary_migrate/20260104000001_create_things.rb | Migration to create things table in secondary database |
| test_app/config/environments/test.rb | New test environment configuration |
| test_app/config/environments/development.rb | Updated with frozen_string_literal comment |
| test_app/config/database.yml | Extended to support multiple databases (primary and secondary) |
| test_app/app/models/thing.rb | New model using SupportTableData connected to secondary database |
| test_app/app/models/status.rb | Updated to use ApplicationRecord and added validation |
| test_app/app/models/secondary_application_record.rb | New base class for models connecting to secondary database |
| test_app/app/models/application_record.rb | New standard ApplicationRecord base class |
| spec/support_table_data_spec.rb | Updated tests to expect new ValidationError instead of ActiveRecord::RecordInvalid |
| spec/models/color.rb | Updated validation syntax to match Rails best practices |
| VERSION | Version bump from 1.4.1 to 1.5.0 |
| README.md | Updated documentation to reflect new auto-sync feature and configuration changes |
| CHANGELOG.md | Documented changes for version 1.5.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s' into hook-into-rake-tasks
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.
Added
db:seed,db:seed:replant,db:prepare,db:test:prepare,db:fixtures:load. Support tables will be synced after running any of these tasks. This can be disabled by settingconfig.support_table.auto_sync = falsein the Rails application configuration.