36 lines
823 B
MySQL
36 lines
823 B
MySQL
|
|
SET @index_exists := (
|
||
|
|
SELECT COUNT(1)
|
||
|
|
FROM information_schema.statistics
|
||
|
|
WHERE table_schema = DATABASE()
|
||
|
|
AND table_name = 'payment_methods'
|
||
|
|
AND index_name = 'uq_payment_methods_company_system_key'
|
||
|
|
);
|
||
|
|
|
||
|
|
SET @drop_index_sql := IF(
|
||
|
|
@index_exists > 0,
|
||
|
|
'DROP INDEX `uq_payment_methods_company_system_key` ON `payment_methods`',
|
||
|
|
'SELECT 1'
|
||
|
|
);
|
||
|
|
|
||
|
|
PREPARE stmt FROM @drop_index_sql;
|
||
|
|
EXECUTE stmt;
|
||
|
|
DEALLOCATE PREPARE stmt;
|
||
|
|
|
||
|
|
SET @column_exists := (
|
||
|
|
SELECT COUNT(1)
|
||
|
|
FROM information_schema.columns
|
||
|
|
WHERE table_schema = DATABASE()
|
||
|
|
AND table_name = 'payment_methods'
|
||
|
|
AND column_name = 'system_key'
|
||
|
|
);
|
||
|
|
|
||
|
|
SET @drop_column_sql := IF(
|
||
|
|
@column_exists > 0,
|
||
|
|
'ALTER TABLE `payment_methods` DROP COLUMN `system_key`',
|
||
|
|
'SELECT 1'
|
||
|
|
);
|
||
|
|
|
||
|
|
PREPARE stmt FROM @drop_column_sql;
|
||
|
|
EXECUTE stmt;
|
||
|
|
DEALLOCATE PREPARE stmt;
|