Skip to content

Kits part 2 - KitItem - #5517

Merged
awwaiid merged 11 commits into
mainfrom
kits-part2-kititem
Jun 7, 2026
Merged

awwaiid merged 11 commits into
mainfrom
kits-part2-kititem

Conversation

@dorner

@dorner dorner commented Mar 13, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is the next step on the Kit roadmap #3652.

This creates two new classes, KitItem and ConcreteItem, and turns Item into a parent class by adding a type column and Single Table Inheritance. It renames the association between kits and items to kit_item to make this more explicit.

The next PR will have us actually switch from creating / updating kits to creating / updating KitItems, and move the sync from kit -> item to instead be kit_item -> kit (for backwards compatibility - we'll stop looking at kits entirely unless something goes wrong). We'll update code that reads from kits to instead read from kit items and stop following that link.

Finally we'll stop the backwards writing and kill off kits for good.

Most of this PR is just the rename of item to kit_item :)

@dorner
dorner requested a review from awwaiid March 13, 2026 20:43
Comment on lines +3 to +4
add_column :items, :type, :string, default: 'ConcreteItem', null: false
Item.where.not(kit_id: nil).update_all(type: 'KitItem', updated_at: Time.zone.now)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Comment thread db/schema.rb
t.index ["user_id"], name: "index_deprecated_feedback_messages_on_user_id"
end

create_table "diaper_drive_participants", id: :serial, force: :cascade do |t|

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated table drop -- is it incorrectly in the main branch, or is this a mistake in the PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's incorrectly in the main branch.

class RenameDiaperDriveParticipantToProductDriveParticipant < ActiveRecord::Migration[6.1]

@awwaiid awwaiid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failures look like they are at least from some SQL reports. Also some stray things got into the schema.rb

Concept continues to be good and good incremental step. One validation to add (in the next PR probably) is that a ConcreteItem should not be allowed to have any line_items, I think?

let(:outside_time) { Time.zone.parse("2019-05-31 14:00:00") }

# Concrete items that go inside kits
let!(:ai_concrete_1) { create(:item, name: "Adult Briefs (Medium)", reporting_category: "adult_incontinence", organization: organization) }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one had to be rearchitected a bit because it was set up incorrectly - it just "happened" to work because the kit -> item relationship was identical to the line item -> item relationship. So this put the kit item inside the kit instead of something like diapers inside the kit 😂

@dorner

dorner commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator Author

@awwaiid ready for re-review!

@awwaiid
awwaiid self-requested a review May 10, 2026 14:22

@awwaiid awwaiid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good, AND I did QA

@awwaiid
awwaiid merged commit 483529e into main Jun 7, 2026
37 of 40 checks passed
@awwaiid
awwaiid deleted the kits-part2-kititem branch June 7, 2026 14:06
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

@dorner: Your PR Kits part 2 - KitItem is part of today's Human Essentials production release: 2026.06.07.
Thank you very much for your contribution!

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