You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Item has a canonical_item_id field that's used as the foreign key in its association. CanonicalItem effectively has 2 keys -- id and partner_key. The problem is that when the app has places where Item and :partner_key intersect, we end up having to look up the CanonicalItem table first, and then do the Item lookups. (basically: converting one key to the other)
Desired change
We can keep id for now since it's the Rails Way(tm) and it's not hurting anything (ie. any actions where CanonicalItem is the resource can remain as-is) -- but the association between Item and CanonicalItem should be based on the partner_key field instead of id / canonical_item_id. (ie. any actions where Item is the resource and it needs to reference its canonical_item association may need to be changed)
with an accompanying migration adjustment to the Items table to add a partner_key:string column, and migrate the previous canonical_item_id association to it (N.B. you'll need to pull CanonicalItem.all first -- there's < 50 records so just load it into memory).
Add a scope called by_partner_key. (should should facilitate solving #394)
Changes will also need to be made in controllers, seed files, factories, and basically any file that comes up with grep -lR canonical_item_id. The test suite should reveal any missing changes. Be sure to include model spec coverage.
The text was updated successfully, but these errors were encountered:
Currently
Item
has acanonical_item_id
field that's used as the foreign key in its association.CanonicalItem
effectively has 2 keys --id
andpartner_key
. The problem is that when the app has places whereItem
and:partner_key
intersect, we end up having to look up theCanonicalItem
table first, and then do theItem
lookups. (basically: converting one key to the other)Desired change
We can keep
id
for now since it's the Rails Way(tm) and it's not hurting anything (ie. any actions whereCanonicalItem
is the resource can remain as-is) -- but the association betweenItem
andCanonicalItem
should be based on thepartner_key
field instead ofid / canonical_item_id
. (ie. any actions whereItem
is the resource and it needs to reference itscanonical_item
association may need to be changed)Something like this should work
with an accompanying migration adjustment to the
Items
table to add apartner_key:string
column, and migrate the previouscanonical_item_id
association to it (N.B. you'll need to pullCanonicalItem.all
first -- there's < 50 records so just load it into memory).Add a scope called
by_partner_key
. (should should facilitate solving #394)Changes will also need to be made in controllers, seed files, factories, and basically any file that comes up with
grep -lR canonical_item_id
. The test suite should reveal any missing changes. Be sure to include model spec coverage.The text was updated successfully, but these errors were encountered: