-- Fix missing mission columns in global.user table
USE `global`;

-- Add missing mission tracking columns to global.user table
ALTER TABLE `user` 
ADD COLUMN IF NOT EXISTS `m_act` tinyint(3) unsigned DEFAULT 1,
ADD COLUMN IF NOT EXISTS `m_act2` tinyint(3) unsigned DEFAULT 1,
ADD COLUMN IF NOT EXISTS `m_mission` tinyint(3) unsigned DEFAULT 1,
ADD COLUMN IF NOT EXISTS `m_mission2` tinyint(3) unsigned DEFAULT 1,
ADD COLUMN IF NOT EXISTS `m_finishflag` tinyint(1) DEFAULT 0;

-- Add other commonly used user columns that might be missing
ALTER TABLE `user`
ADD COLUMN IF NOT EXISTS `pm_add` varchar(50) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `pm_ban` varchar(50) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `menulvl` tinyint(3) unsigned DEFAULT 0,
ADD COLUMN IF NOT EXISTS `click` tinyint(3) unsigned DEFAULT 0,
ADD COLUMN IF NOT EXISTS `NPC` tinyint(1) DEFAULT 0,
ADD COLUMN IF NOT EXISTS `VM` tinyint(1) DEFAULT 0;

-- Research columns  
ALTER TABLE `user`
ADD COLUMN IF NOT EXISTS `r_1` int(11) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `r_2` int(11) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `r_3` int(11) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `r_4` int(11) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `r_5` int(11) DEFAULT NULL;

-- Premium/payment columns
ALTER TABLE `user`
ADD COLUMN IF NOT EXISTS `p_signup` datetime DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `p_startempire` datetime DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `p_type` tinyint(3) unsigned DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `p_expire` datetime DEFAULT NULL;

-- Verify the columns were added
SELECT 'Verification - global.user now has these columns:' as info;
SELECT column_name, data_type, is_nullable, column_default 
FROM information_schema.columns 
WHERE table_schema = 'global' AND table_name = 'user' 
AND column_name IN ('m_act2', 'm_mission2', 'm_act', 'm_mission', 'm_finishflag')
ORDER BY column_name;