overhangio / tutor-ecommerce

Ecommerce plugin for Tutor
GNU Affero General Public License v3.0
17 stars 50 forks source link

fix: support mysql8 syntax #22

Closed gabor-boros closed 2 years ago

gabor-boros commented 2 years ago

In MySQL, if the sql_require_primary_key is turned on, no table can exist without a primary key. Since the migration 0005 drops the primary key field before model deletion, the table misses the primary key, hence the migration will fail.

To prevent migration failure, we swap the primary key before dropping the revisionpluginrevision_ptr field which is the actual primary key. In case the migration need to be reverted, the opposite will happen and we set the revisionpluginrevision_ptr as the primary key.

When selecting the new primary key, it doesn't really matter what we set, since at the end of the migration we drop the whole table.

Signed-off-by: Gabor Boros gabor.brs@gmail.com