USE restpo;

-- Add currency column to restaurants
ALTER TABLE `restaurants`
    ADD COLUMN IF NOT EXISTS `currency` VARCHAR(10) NOT NULL DEFAULT '$' AFTER `logo`,
    ADD COLUMN IF NOT EXISTS `package_id` INT UNSIGNED NULL AFTER `currency`;

-- Clear existing packages (adjust if you want to keep custom ones)
-- DELETE FROM packages;

-- Insert the 4 default packages with feature limits in JSON
-- Features JSON structure:
-- {
--   "max_floors": 1|2|null(unlimited),
--   "max_tables": 10|20|null(unlimited),
--   "max_cashiers": 1|2|null(unlimited),
--   "max_waiters": 5|10|null(unlimited),
--   "qr_ordering": true|false,
--   "kitchen_display": true|false,
--   "is_trial": true|false
-- }

INSERT INTO `packages` (`name`, `price`, `duration_days`, `features`, `status`) VALUES
(
    'Basic',
    29.99,
    30,
    '{"max_floors":1,"max_tables":10,"max_cashiers":1,"max_waiters":5,"qr_ordering":false,"kitchen_display":false,"is_trial":false}',
    'active'
),
(
    'Premium',
    59.99,
    30,
    '{"max_floors":2,"max_tables":20,"max_cashiers":2,"max_waiters":10,"qr_ordering":true,"kitchen_display":false,"is_trial":false}',
    'active'
),
(
    'Advanced',
    99.99,
    30,
    '{"max_floors":null,"max_tables":null,"max_cashiers":null,"max_waiters":null,"qr_ordering":true,"kitchen_display":true,"is_trial":false}',
    'active'
),
(
    'Trial',
    0.00,
    14,
    '{"max_floors":1,"max_tables":10,"max_cashiers":1,"max_waiters":5,"qr_ordering":false,"kitchen_display":false,"is_trial":true}',
    'active'
);
