Here's the method I've used to update from version 1 to version 2 of Commerce Stock. Please test this in a development environment!

1) Do a full DB backup
drush sql-dump > ~/db_snapshots/mysite-20121001233057.sql

2) Backup the two stock fields (populated with stock data that we'll lose after the upgrade)
drush sql-dump --tables-list=field_data_commerce_stock,field_revision_commerce_stock > before-stock-update.sql

3) Disable stock management
admin/commerce/config/stock

4) Disable any modules that depend on commerce_stock

5) Disable commerce_stock (and uninstall --- may not be necessary?)
drush dis commerce_stock
drush pm-uninstall commerce_stock

6) Remove the v1 version of commerce_stock
rm -rf sites/all/modules/contrib/commerce_stock/

7) Download the new version and enable it
drush dl commerce_stock-7.x-2.x-dev
drush en commerce_ssr, commerce_ss, commerce_stock
drush cc all

8) Re-enable stock management on the product types
admin/commerce/config/stock/ss

9) Now that we have a new commerce_stock field, we'll get its field definition and then use it to alter the data from before-stock-update.sql
drush sql-dump --tables-list=field_data_commerce_stock,field_revision_commerce_stock > after-stock-update.sql

10) Now, move over the table definitions from after-stock-update.sql to before-stock-update.sql so that before-stock-update.sql has the original data with the new table definitions. Don't touch the data WITHIN the tables, just change the table structure definitions. There should be only TWO lines that change for each of the two tables (the actual field moves from int to decimal, and the final COMMENT of the tables). I like to use Vim to make the changes:
vim -o before-stock-update.sql after-stock-update.sql

11) Do another full backup, justtttt in case ;)
drush sql-dump > ~/db_snapshots/mysite-20121001233627.sql

12) Import the before-stock-update.sql dump with:
drush sql-cli < before-stock-update.sql

13) Re-enable any modules you disabled in order to uninstall commerce_stock v1

14) TEST! Make sure the stock values are what you expected. Remember, you have at least 2 full backup points you could go back to… so quickly restore one of those if anything is suspicious.

Comments

guy_schneerson’s picture

Hi @agileadam
Thanks for sharing another approach that may work (needs testing) is :

1) Disable any modules that depend on commerce_stock

2) Disable commerce_stock (and uninstall)

3) Remove the v1 version of commerce_stock

4) Download v2 and enable its modules

5) Re-enable any modules you disabled in order to uninstall commerce_stock v1

the reason this should work is that both versions use the same field and that the stock field is controlled by the admin screen not the install/uninstall

agileadam’s picture

guy, that looks a lot easier :)
If you uninstall any of those modules, though, won't the data go away? I guess I call for the uninstall too, but I'm re-importing the data afterwards.
Who knows. Lol. Hopefully I won't have to do this again and I'll use the right version from the start ;)

guy_schneerson’s picture

Status: Active » Fixed

@agileadam but needs testing, haven't used this technique for a long time.

closing issue but got a link from the project page so we can get to it easily.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kirie’s picture

Thanks for the info guys! Just to confirm, the procedure described in #1 worked for me when upgrading from 1.1 to 2.0-alpha3 (nevertheless, I did backup the complete DB and specific tables as described by @agileadam - just to be sure).

kirie’s picture

Issue summary: View changes

Minor text change

lsolesen’s picture

I tried this - but have to work out some quirks #2225883: Fatal error together with commerce stock 2.x. Will return with my results when I figure that one out.

drush pm-disable commerce_stock
drush pm-uninstall commerce_stock
rm sites/all/modules/contrib/commerce_stock/ -R

drush dl commerce_stock
drush en commerce_ss commerce_ssr commerce_ssf
drush cc all
goose2000’s picture

This was very helpful - Thanks a lot ! I did not have to do the migration steps, only had a few products to deal with.