-
Notifications
You must be signed in to change notification settings - Fork 0
Hook data sync into Rails db setup tasks #16
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.