-- SwiftPayHub administrator repair / bootstrap
-- Database: swiftpay_api_marketplace
-- This resets the built-in administrator to admin / admin123.
-- Run once in phpMyAdmin, then change the password immediately.

USE swiftpay_api_marketplace;

INSERT INTO users (username, email, password, api_key, role, status)
VALUES (
  'admin',
  'admin@example.com',
  '$2y$12$ydfOSY/N72sqagChtJFrCuIwvLuDy/mXPaoDZC/Lb0iUJDexmaNyC',
  CONCAT('sph_admin_', SHA2(RAND(),256)),
  'admin',
  'active'
)
ON DUPLICATE KEY UPDATE
  password = VALUES(password),
  role = 'admin',
  status = 'active';

INSERT INTO wallets (user_id, balance)
SELECT id, 0.00 FROM users WHERE username='admin'
ON DUPLICATE KEY UPDATE user_id=user_id;
