-- Fix missing columns in global tables
USE `global`;

-- Check if user_good table exists and add missing columns
ALTER TABLE `user_good` 
ADD COLUMN IF NOT EXISTS `g1` bigint(20) DEFAULT 0,
ADD COLUMN IF NOT EXISTS `g2` bigint(20) DEFAULT 0,
ADD COLUMN IF NOT EXISTS `g3` bigint(20) DEFAULT 0,
ADD COLUMN IF NOT EXISTS `g4` bigint(20) DEFAULT 0,
ADD COLUMN IF NOT EXISTS `g5` bigint(20) DEFAULT 0,
ADD COLUMN IF NOT EXISTS `g6` bigint(20) DEFAULT 0;

-- Check if event table exists and add missing columns
ALTER TABLE `event` 
ADD COLUMN IF NOT EXISTS `post` varchar(250) DEFAULT NULL;

-- Check if event_attack table exists and add missing columns  
ALTER TABLE `event_attack`
ADD COLUMN IF NOT EXISTS `source` int(11) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `target` int(11) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `winflag` tinyint(1) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `attackpower` bigint(20) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `defensepower` bigint(20) DEFAULT NULL;

-- Verify the structure
SELECT 'Verification:' as info;
DESCRIBE `user_good`;
DESCRIBE `event`; 
DESCRIBE `event_attack`;