-- Add missing columns to posts table for service contract management

ALTER TABLE posts ADD COLUMN IF NOT EXISTS contract_end DATE AFTER contract_date;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS owner_phone VARCHAR(20) AFTER owner_id;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS owner_address TEXT AFTER owner_phone;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS services LONGTEXT AFTER content_value;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS location VARCHAR(255);
ALTER TABLE posts ADD COLUMN IF NOT EXISTS surface_area DECIMAL(10,2);
ALTER TABLE posts ADD COLUMN IF NOT EXISTS access_points INT;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS num_buildings INT;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS content_value DECIMAL(15,2);
ALTER TABLE posts ADD COLUMN IF NOT EXISTS grand_total DECIMAL(15,2) DEFAULT 0;

-- Verify columns were added
SHOW COLUMNS FROM posts;
