-- Admin Panel Migration
-- Run this AFTER setup.sql against the my_media database

-- Add admin flag and account status to users
ALTER TABLE web_users
  ADD COLUMN IF NOT EXISTS is_admin TINYINT(1) NOT NULL DEFAULT 0,
  ADD COLUMN IF NOT EXISTS status ENUM('pending','active','suspended') NOT NULL DEFAULT 'active';

-- Subscription packages table
CREATE TABLE IF NOT EXISTS subscription_plans (
    id           INT AUTO_INCREMENT PRIMARY KEY,
    name         VARCHAR(100) NOT NULL,
    duration_days INT NOT NULL,
    price        DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    is_active    TINYINT(1) NOT NULL DEFAULT 1,
    created_at   TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Default plans
INSERT INTO subscription_plans (name, duration_days, price) VALUES
  ('تجريبي', 30, 0.00),
  ('شهري', 30, 9.99),
  ('ربع سنوي', 90, 24.99),
  ('سنوي', 365, 79.99)
ON DUPLICATE KEY UPDATE name = name;

-- Make first registered user an admin (run separately after first registration)
-- UPDATE web_users SET is_admin = 1, status = 'active' WHERE id = 1;
