Skip to content

Convert quotable item quote data to direct quotes#1005

Open
Copilot wants to merge 4 commits intomainfrom
copilot/convert-quotable-item-quotes
Open

Convert quotable item quote data to direct quotes#1005
Copilot wants to merge 4 commits intomainfrom
copilot/convert-quotable-item-quotes

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

What is the goal of this PR and why is this important?

This PR simplifies the quote data architecture by converting from a join table pattern to direct polymorphic relationships. Currently, quotes are related to quotable items (workshops, reports, workshop_logs) through a quotable_item_quotes join table. Since quotes are rarely shared between items in production, we can eliminate this unnecessary complexity by making quotes directly belong to quotable items.

How did you approach the change?

Database Migrations:

  • Added polymorphic columns (quotable_id, quotable_type) to the quotes table
  • Created a reversible data migration to copy associations from quotable_item_quotes to quotes

Models:

  • Updated Quote model to use direct belongs_to :quotable, polymorphic: true relationship
  • Changed Workshop and Report models from has_many :quotable_item_quotes to has_many :quotes, as: :quotable
  • Updated nested attributes in Report model to use quotes directly

Controllers:

  • Simplified WorkshopLogsController form building logic (removed nested join table complexity)
  • Updated permitted params to use quotes_attributes instead of quotable_item_quotes_attributes

Views:

  • Updated workshop logs form to use :quotes directly instead of :quotable_item_quotes
  • Created new simplified _quote_fields.html.erb partial
  • Updated quote index and show views to use direct quote.quotable access

Decorators & Tests:

  • Simplified QuoteDecorator to use direct object.quotable access
  • Updated all association tests in quote, workshop, and report specs

Architecture Change:

  • Before: Quote ←→ QuotableItemQuote ←→ Quotable (Workshop/Report/WorkshopLog)
  • After: Quote → Quotable (direct polymorphic relationship)

Anything else to add?

The quotable_item_quotes table is preserved to ensure safe rollback capability. It can be removed in a follow-up after production verification.

Comprehensive migration instructions, rollback plan, and testing guidance are documented in MIGRATION_NOTES.md.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
@maebeale
Copy link
Collaborator

@copilot try again

@maebeale maebeale marked this pull request as ready for review February 15, 2026 21:41
Copilot AI and others added 2 commits February 15, 2026 21:48
…onship

Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot try again

Completed the full conversion from quotable_item_quotes join table to direct polymorphic relationships.

Key changes in commit fb9f825:

  • Updated all models, controllers, views, decorators, and tests
  • Created migrations to add polymorphic columns and migrate data
  • Simplified form handling and removed nested join table logic
  • Added comprehensive migration documentation in MIGRATION_NOTES.md

The changes are ready for review. After running migrations, the quotable_item_quotes table can be safely removed in a follow-up.

Copilot AI changed the title [WIP] Convert quotable item quote data to direct quotes Convert quotable item quote data to direct quotes Feb 15, 2026
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