-- Subscription Settings Schema
-- Stores admin-configurable subscription parameters

SET FOREIGN_KEY_CHECKS = 0;

CREATE TABLE IF NOT EXISTS `subscription_settings` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `setting_key` VARCHAR(100) NOT NULL UNIQUE,
    `setting_value` TEXT NOT NULL,
    `setting_type` ENUM('string', 'number', 'boolean', 'json') NOT NULL DEFAULT 'string',
    `setting_description` VARCHAR(500) DEFAULT NULL,
    `is_active` BOOLEAN DEFAULT TRUE,
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX `idx_setting_key` (`setting_key`),
    INDEX `idx_is_active` (`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Insert default subscription settings
INSERT INTO `subscription_settings` (`setting_key`, `setting_value`, `setting_type`, `setting_description`) VALUES
('free_inventory_limit', '100', 'number', 'Maximum number of inventory items for FREE plan'),
('free_reports_days', '14', 'number', 'Number of days for reports history in FREE plan'),
('free_staff_limit', '1', 'number', 'Maximum number of staff members for FREE plan'),
('trial_days', '15', 'number', 'Number of trial days for new businesses'),
('premium_monthly_price', '5.00', 'number', 'Monthly subscription price for PREMIUM plan in USD');

SET FOREIGN_KEY_CHECKS = 1; 