FactuGES_ERP/docs/catalogs/sql/add-payment-method-default-and-system-key.sql
david 5dfbdd2a1c feat(payment-methods): add payment method management functionality
- Implemented `usePaymentMethodUpdateMutation` for updating payment methods with validation.
- Created settings controllers and hooks for managing payment methods.
- Added UI components for creating, editing, deleting, and displaying payment methods.
- Introduced error handling and feedback mechanisms for payment method operations.
- Developed form schemas and utility functions for handling payment method data.
- Established a new settings page for managing payment methods with appropriate loading and error states.
2026-08-13 01:04:56 +02:00

32 lines
850 B
SQL

ALTER TABLE `payment_methods`
ADD COLUMN IF NOT EXISTS `is_default` TINYINT(1) NOT NULL DEFAULT 0 AFTER `is_system`;
ALTER TABLE `payment_methods`
ADD COLUMN IF NOT EXISTS `system_key` VARCHAR(64) NULL AFTER `is_default`;
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 @create_index_sql := IF(
@index_exists = 0,
'CREATE UNIQUE INDEX `uq_payment_methods_company_system_key` ON `payment_methods` (`company_id`, `system_key`)',
'SELECT 1'
);
PREPARE stmt FROM @create_index_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
UPDATE `payment_methods`
SET `is_default` = 0
WHERE `is_default` IS NULL;
UPDATE `payment_methods`
SET `system_key` = NULL
WHERE `is_system` = 0;