-- ============================================================
--  Break the Locks — Part 6 (Take Action) Schema
--  Run once in phpMyAdmin on the admin_btlc database before
--  using part6.php.
--
--  Two tables:
--    lock_action_suggestions  → admin-editable library of actions
--                               for each lock. Add more rows any time.
--    user_lock_actions        → which actions a user has committed to
--                               (also pushed into their Life List).
-- ============================================================

CREATE TABLE IF NOT EXISTS `lock_action_suggestions` (
  `id`            INT AUTO_INCREMENT PRIMARY KEY,
  `lock_id`       INT NOT NULL,
  `title`         VARCHAR(255) NOT NULL,
  `description`   TEXT NULL,
  `is_recurring`  TINYINT(1) NOT NULL DEFAULT 1,  -- default to a daily habit
  `sort_order`    INT NOT NULL DEFAULT 0,
  `active`        TINYINT(1) NOT NULL DEFAULT 1,
  `created_at`    TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_lock_active` (`lock_id`, `active`, `sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE IF NOT EXISTS `user_lock_actions` (
  `id`                INT AUTO_INCREMENT PRIMARY KEY,
  `user_id`           INT NOT NULL,
  `lock_id`           INT NOT NULL,
  `suggestion_id`     INT NULL,                   -- NULL if user typed their own
  `title`             VARCHAR(255) NOT NULL,
  `description`       TEXT NULL,
  `is_recurring`      TINYINT(1) NOT NULL DEFAULT 1,
  `life_list_item_id` INT NULL,                   -- link back to Life List
  `created_at`        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY `uk_user_lock_suggestion` (`user_id`, `lock_id`, `suggestion_id`),
  INDEX `idx_user_lock` (`user_id`, `lock_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- ============================================================
--  Seed: starter action suggestions, ~6 per lock.
--  Add, edit, or deactivate rows here over time; the app reads
--  whatever is `active = 1` for each lock.
-- ============================================================

-- Lock 1 — Not Understanding Desires & Subconscious Programming
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(1, 'Journal 10 minutes about what triggered your strongest emotion today', 10),
(1, 'Pause for 3 breaths before reacting — name what you''re feeling', 20),
(1, 'Read 10 pages a day on mindset or subconscious patterns', 30),
(1, 'Identify one inherited belief this week and challenge it in writing', 40),
(1, 'Ask "whose voice is this?" before any big decision', 50),
(1, 'List 3 desires each morning and rate which are truly yours', 60);

-- Lock 2 — Lack of Focus & Sense of Purpose
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(2, 'Re-read your purpose statement out loud each morning', 10),
(2, 'Block 90 minutes daily for purpose-aligned deep work', 20),
(2, 'Say no to one off-purpose opportunity this week', 30),
(2, 'End each day reviewing what moved your purpose forward', 40),
(2, 'Cut one distraction completely for 30 days', 50),
(2, 'Schedule weekly review — am I still on the path?', 60);

-- Lock 3 — Dopamine Addiction
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(3, 'No phone for the first 30 minutes after waking', 10),
(3, 'Take a 24-hour social media fast every week', 20),
(3, 'Replace phone-in-bed with reading a book', 30),
(3, 'Delete one infinite-scroll app from your phone', 40),
(3, 'Track screen time daily, aim to cut 15 minutes each week', 50),
(3, 'Single-task for 50 minutes before checking notifications', 60);

-- Lock 4 — Money & Greed Programming
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(4, 'Affirm "money is a tool for impact" each morning', 10),
(4, 'Raise your rate or ask for what you''re worth on the next opportunity', 20),
(4, 'Write what abundance would let you do for others', 30),
(4, 'Save or invest 10% of every paycheck this month', 40),
(4, 'Read one money-mindset article or chapter per week', 50),
(4, 'Track your income weekly without judgment', 60);

-- Lock 5 — Distaste for Rules & Restrictions
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(5, 'Pick one personal rule and hold it for 30 days', 10),
(5, 'Set a recurring wake-up time and stick to it', 20),
(5, 'Define 3 non-negotiables for your day and protect them', 30),
(5, 'Plan tomorrow''s top 3 before going to bed', 40),
(5, 'Review rule adherence each weekend', 50),
(5, 'Schedule "do not disturb" hours and honor them', 60);

-- Lock 6 — Comfort & Stress Programming
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(6, 'Do one uncomfortable thing each day (cold shower, hard talk, etc.)', 10),
(6, 'Reframe stress as "this is growth" when it shows up', 20),
(6, 'Take on one challenge that scares you this week', 30),
(6, 'Sit with discomfort 5 minutes before reaching for a distraction', 40),
(6, 'Push past your first "I want to quit" instinct in workouts', 50),
(6, 'Schedule one growth-edge conversation each month', 60);

-- Lock 7 — Entitlement Programming
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(7, 'List the impact you created each day before logging off', 10),
(7, 'Ask "what value did I add today?" every evening', 20),
(7, 'Offer help to someone in your field this week', 30),
(7, 'Pitch one valuable idea or solution to a leader each month', 40),
(7, 'Track outcomes, not hours, in your work', 50),
(7, 'Share one win with a teammate every week', 60);

-- Lock 8 — Praise of Ideas Over Execution
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(8, 'Set a hard deadline for one current idea and ship it', 10),
(8, 'Spend 80% of your time executing, 20% ideating', 20),
(8, 'Learn one persuasion or marketing skill this month', 30),
(8, 'Show your work publicly at least once a week', 40),
(8, 'Kill 3 ideas you''ve been procrastinating on', 50),
(8, 'Take one tiny step on your top idea every day', 60);

-- Lock 9 — Distrust of Others
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(9, 'Have one meaningful conversation with a new person this week', 10),
(9, 'Limit news consumption to 15 minutes per day', 20),
(9, 'Attend one community event or group meeting monthly', 30),
(9, 'Assume good intent in one interaction per day', 40),
(9, 'Build one new genuine connection this month', 50),
(9, 'Reach out to a friend you''ve lost touch with', 60);

-- Lock 10 — Externally Defined Identity
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(10, 'Write a new identity statement that feels true to you', 10),
(10, 'Read your identity statement morning and night', 20),
(10, 'Introduce yourself by who you''re becoming, not what you do', 30),
(10, 'Remove one role-based label from your bio', 40),
(10, 'Act on a self-chosen identity once a day', 50),
(10, 'List 3 things that are true about you, regardless of any role', 60);

-- Lock 11 — Energy Depletion
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(11, 'Get 7+ hours of sleep nightly', 10),
(11, '20-minute walk outside each day', 20),
(11, 'No screens 30 minutes before bed', 30),
(11, 'Eat one whole-food meal per day with no processed sugar', 40),
(11, 'Two-minute breathwork break mid-day', 50),
(11, 'Drink 64+ oz of water daily', 60);

-- Lock 12 — Trapped Behind the Four Doors of Spiritual Desires
INSERT INTO `lock_action_suggestions` (`lock_id`, `title`, `sort_order`) VALUES
(12, 'Define what hope, security, value, and connection mean for you', 10),
(12, 'Practice gratitude for 5 minutes each morning', 20),
(12, 'Schedule one real connection moment with someone you love daily', 30),
(12, 'Take one act that fulfills your spiritual side each week', 40),
(12, 'Meditate or pray for 10 minutes daily', 50),
(12, 'Write down one thing you''re hopeful about each evening', 60);
