-- Create Users_test table for safe email testing
-- This table contains Barry Kirk, David Ramos, and ALL users with "Admin" in their name for testing purposes

-- Drop the table if it exists

-- Create the test users table with the same structure as Users
CREATE TABLE `Users_test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `memberId` varchar(50) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `handicap` varchar(10) DEFAULT NULL,
  `handicapDec` decimal(10,3) DEFAULT NULL,
  `federation` varchar(50) DEFAULT NULL,
  `privileges` varchar(50) DEFAULT NULL,
  `gender` char(1) DEFAULT NULL,
  `usertoken` varchar(255) DEFAULT NULL,
  `balance` decimal(10,2) DEFAULT NULL,
  `balanceDate` date DEFAULT NULL,
  `lastLogin` datetime DEFAULT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `allergy` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- Insert Barry Kirk, David Ramos, and ALL users with "Admin" in their name
INSERT INTO `Users_test` (
  `id`, `memberId`, `name`, `email`, `password`, `phone`, `handicap`, `handicapDec`, 
  `federation`, `privileges`, `gender`, `usertoken`, `balance`, `balanceDate`, 
  `lastLogin`, `createdAt`, `updatedAt`, `allergy`
)
-- First, add Barry Kirk and David Ramos specifically
SELECT 
  2515, '8022', 'KIRK,  BARRY', 'barry@scala4.com', '$2y$10$flPkUs7WGflXBRqzGl1treYKIMO3lMYzTdYzNet3ufrDkLKqVHhQK', '+34 711 047 461', '14,3', 14.300, 'AM55913703', 'Admin', 'M', '71dba028e99ded904bf0c61e249ba52df8bea83cdcd0bb4d30b463963ef10482', '-78.99', NULL, '2025-06-23 07:15:36', '2021-10-12 15:43:16', '2025-07-01 04:00:28', ''

UNION ALL

SELECT 
  9999, '9999', 'RAMOS, DAVID', 'david.ramos@elparaisogolf.com', '$2y$10$testpasswordhash', '+34 000 000 000', '15,0', 15.000, 'AM99999999', 'Admin', 'M', NULL, '0', NULL, NULL, NOW(), NOW(), ''

UNION ALL

-- Then add ALL users with "Admin" in their name from the main Users table
SELECT 
  `id`, `memberId`, `name`, `email`, `password`, `phone`, `handicap`, `handicapDec`, 
  `federation`, `privileges`, `gender`, `usertoken`, `balance`, `balanceDate`, 
  `lastLogin`, `createdAt`, `updatedAt`, `allergy`
FROM `Users` 
WHERE `name` LIKE '%Admin%' 
  AND `id` NOT IN (2515, 9999); -- Exclude Barry Kirk and David Ramos to avoid duplicates

-- Show the test users
SELECT id, memberId, name, email, privileges FROM Users_test ORDER BY name; 