Deleting a gateway doesn't remove its name from the unique index.
After trying to set another gateway to the name of that which was deleted, the following error occurs:
(For example with the 'PayPal' name):
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'PayPal' for key 'commerce_gateways_name_unq_idx' in /vendor/yiisoft/yii2/db/Command.php:1258
Stack trace:0 /vendor/yiisoft/yii2/db/Command.php(1258): PDOStatement->execute()
Next yii\db\IntegrityException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'PayPal' for key 'commerce_gateways_name_unq_idx'
The SQL being executed was: UPDATEcommerce_gatewaysSETname='PayPal',isFrontendEnabled=1,isArchived=0,dateUpdated='2018-09-11 21:23:30' WHEREid=4 in /vendor/yiisoft/yii2/db/Schema.php:664
Stack trace:0 /vendor/yiisoft/yii2/db/Command.php(1263): yii\db\Schema->convertException(Object(PDOException), 'UPDATE `commerc...')
Additional Information:
Array
(
[0] => 23000
[1] => 1062
[2] => Duplicate entry 'PayPal' for key 'commerce_gateways_name_unq_idx'
)
In fact, having a closer look at my database, I realize it's worse: the actual Gateway doesn't even get deleted in the first place. The index is right: it still exists, but it's no longer visible from the CP.
Not deleting the gateway is on purpose, it is so you can still refund payment for existing orders etc.
Will update to work with the new soft delete feature and update the delete action to rename (append '_deleted') to for any the unique column constraints.
FYI we will be updating commerce to support Craft's new soft deletes: https://craftcms.com/news/craft-3-1-dev-preview
@andris-sevcenko this will be able to be closed once we push out project config support.
Closed in fc3116a, going to be released with 2.0 GA most likely.
Most helpful comment
FYI we will be updating commerce to support Craft's new soft deletes: https://craftcms.com/news/craft-3-1-dev-preview