Skip to content

Conversation

@bdurand
Copy link
Owner

@bdurand bdurand commented Jan 6, 2026

Added

  • The data synchronization task is now automatically attached to several Rails tasks: 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 setting config.support_table.auto_sync = false in the Rails application configuration.

Copy link
Contributor

Copilot AI left a 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_attribute implementation to use a private backing attribute with explicit default behavior
  • New ValidationError class 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.

bdurand and others added 5 commits January 5, 2026 21:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bdurand bdurand merged commit 2f4ef6f into main Jan 6, 2026
7 checks passed
@bdurand bdurand deleted the hook-into-rake-tasks branch January 6, 2026 17:02
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.

2 participants