-- SheListens — migration 007: editable plan features, wellness resources
-- and legal pages content-management
-- Run via phpMyAdmin or: mysql -u USER -p DBNAME < migrations/007_editable_content.sql
-- Safe to run on an existing database.

ALTER TABLE plans
  ADD COLUMN IF NOT EXISTS features TEXT NULL COMMENT 'JSON array of short feature strings, admin-editable' AFTER video_included;

-- Seed from the marketing copy that was previously hardcoded in the
-- frontend, so nothing visually changes until an admin edits it.
UPDATE plans SET features = '["Unlimited secure chat","Voice notes","Video sessions + fee"]'
  WHERE id = 'weekly' AND (features IS NULL OR features = '');
UPDATE plans SET features = '["Everything in Weekly","Lower effective cost","Video sessions + fee"]'
  WHERE id = 'monthly' AND (features IS NULL OR features = '');
UPDATE plans SET features = '["Everything in Monthly","Video included","Priority booking"]'
  WHERE id = 'yearly' AND (features IS NULL OR features = '');

CREATE TABLE IF NOT EXISTS legal_pages (
  page_key    VARCHAR(30) PRIMARY KEY,
  title       VARCHAR(120) NOT NULL,
  body        LONGTEXT NOT NULL,
  updated_at  DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT IGNORE INTO legal_pages (page_key, title, body) VALUES
  ('terms', 'Terms of Service',
   'Placeholder text. Final wording for this policy is pending legal review.\n\nThis is where your Terms of Service will live once written — edit it any time from Admin -> Legal.'),
  ('privacy', 'Privacy Policy',
   'Placeholder text. Final wording for this policy is pending legal review.\n\nThis is where your Privacy Policy will live once written — edit it any time from Admin -> Legal.'),
  ('confidentiality', 'Confidentiality Policy',
   'Placeholder text. Final wording for this policy is pending legal review.\n\nThis is where your Confidentiality Policy will live once written — edit it any time from Admin -> Legal.');
