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 https://github.com/magento/magento2/commit/da6d8a7c614e57ede12986f9774e9052b149595e#diff-605d420bfa8093a93b97323d20a2a65f

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');