The commit «PCF: removing grouped price» from 2015-10-02 breaks Magento schema upgrading with the exception: «there can be only one auto column and it must be defined as a key»

The exception after bin/magento setup:upgrade:

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

The problem commit is MAGETWO-42501: PCF: removing grouped price · magento/magento2@da6d8a7 · GitHub

The problem line is:

GitHub issue 2007

My fix is to add the following code just before the problem line:

$setup->getConnection()->dropColumn($setup->getTable(Media::GALLERY_VALUE_TABLE), 'record_id');