Skip to content
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

Remove order association from inventory units #2377

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Nov 15, 2017

This is the fourth attempt to remove the order_id column from the spree_inventory_units table. It is redundant, as Inventory Units are associated with Shipments, which also have an order ID.

This will slow down some operations, as we're removing what is essentially a cache column from inventory units. It will also speed up some operation, as we are getting rid of a column with an indexes.

Most importantly, this simplifies our data model.

Compared to the previous attempts, this is simplified since work on the stock system has removed the necessity for packages and packers to be initialized with orders.

Previous related PRs: #1770 , #2124, #2125, #2256.

mamhoff and others added 12 commits November 15, 2017 21:31
Inventory units link line items to shipments. Both of these have an
order. Let's make this a has_many association, through :shipments, which
are required.

This made a number of changes in the codebase necessary, such as
checking for order instead of order id identity.
We do not need this column as the same data is represented
by the `order_id` column on the `spree_shipments` table.

I needed to change some stubbing in the manifest spec.
This method would be lost by the removal of the DB column.
Alternatively, we could call `order.id`, but that would
in many cases unnecessarily instantiate more objects, so
I opt for an explicit delegate.
This spec was quite brittle as everything was stubbed. This is a minimal fix,
I still do not regard this a well-working spec.
This shipment in this spec was not associated to the same order,
which is unrealistic. Fixed by adding the necessary association.
@mamhoff mamhoff requested a review from cbrunsdon November 21, 2017 17:07
Copy link
Contributor

@cbrunsdon cbrunsdon left a comment

Choose a reason for hiding this comment

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

Thanks for continually trying to get this merged. Good by me, 👍. I think its a positive step forward.

@gmacdougall gmacdougall merged commit 501fb09 into solidusio:master Nov 22, 2017
kennyadsl added a commit to solidusio-contrib/solidus_expedited_exchanges that referenced this pull request May 2, 2018
order_id column has been removed from solidus since solidusio/solidus#2377.
Now the order reference will be taken from the shipment in which the
inventory units are included.
kennyadsl added a commit to solidusio-contrib/solidus_expedited_exchanges that referenced this pull request May 3, 2018
order_id column has been removed from solidus since solidusio/solidus#2377.
Now the order reference will be taken from the shipment in which the
inventory units are included.
kennyadsl added a commit to solidusio-contrib/solidus_expedited_exchanges that referenced this pull request May 3, 2018
order_id column has been removed from solidus since solidusio/solidus#2377.
Now the order reference will be taken from the shipment in which the
inventory units are included.
kennyadsl added a commit to solidusio-contrib/solidus_expedited_exchanges that referenced this pull request May 3, 2018
order_id column has been removed from solidus since solidusio/solidus#2377.
Now the order reference will be taken from the shipment in which the
inventory units are included.
kennyadsl added a commit to solidusio-contrib/solidus_expedited_exchanges that referenced this pull request May 3, 2018
order_id column has been removed from solidus since solidusio/solidus#2377.
Now the order reference will be taken from the shipment in which the
inventory units are included.
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.

4 participants