-- BarberShop hosted shop installer (generic product zip)
-- Branding in this file is a placeholder. Owner edits company name
-- in Admin → Page Content / Branding.
--
--   tenants.subdomain              = charlies until you run sql/set-shop-slug.sql
--   tenants.name / business_name   = Company Name Here
--   hero_headline                  = Title Here
--
-- After import, run sql/set-shop-slug.sql so the slug matches
-- YOURSHOP.barber-shop.us (required for the Android shop name).
--
-- Roles:
--   owner  = shop admin (web /admin)
--   customer = public users (web portal + Android app)
--
-- Seed logins (change after go-live):
--   Owner:    admin / password32
--   Customer: sam@charlies.barber-shop.us / customer32
--
-- Startup imagery lives in uploads/tenant_1/ and ships in the zip.
-- Do not omit that folder on upload.
--
-- phpMyAdmin: select the shop database first, then Import this file.
-- Do not wrap this in CREATE DATABASE on GoDaddy (the DB already exists).

-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Aug 23, 2026 at 08:44 AM
-- Server version: 10.11.18-MariaDB-cll-lve
-- PHP Version: 8.4.24

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;

SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS demo_presence;
DROP TABLE IF EXISTS shop_order_items;
DROP TABLE IF EXISTS shop_orders;
DROP TABLE IF EXISTS payments;
DROP TABLE IF EXISTS booking_reminders;
DROP TABLE IF EXISTS staff_services;
DROP TABLE IF EXISTS staff_time_off;
DROP TABLE IF EXISTS style_gallery;
DROP TABLE IF EXISTS bookings;
DROP TABLE IF EXISTS products;
DROP TABLE IF EXISTS services;
DROP TABLE IF EXISTS staff_barbers;
DROP TABLE IF EXISTS media_assets;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS reminder_settings;
DROP TABLE IF EXISTS client_policy;
DROP TABLE IF EXISTS payment_settings;
DROP TABLE IF EXISTS page_settings;
DROP TABLE IF EXISTS license_metrics;
DROP TABLE IF EXISTS sms_carriers;
DROP TABLE IF EXISTS tenants;
DROP TABLE IF EXISTS schema_migrations;
SET FOREIGN_KEY_CHECKS = 1;

SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: (select the shop DB in phpMyAdmin first)
--

-- --------------------------------------------------------

--
-- Table structure for table `bookings`
--

CREATE TABLE `bookings` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `service_id` int(11) DEFAULT NULL,
  `staff_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `customer_name` varchar(150) NOT NULL,
  `customer_phone` varchar(50) DEFAULT NULL,
  `customer_email` varchar(150) DEFAULT NULL,
  `starts_at` datetime NOT NULL,
  `ends_at` datetime NOT NULL,
  `status` varchar(30) DEFAULT 'pending',
  `notes` text DEFAULT NULL,
  `payment_status` varchar(30) NOT NULL DEFAULT 'unpaid',
  `deposit_paid` decimal(10,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bookings`
--

INSERT INTO `bookings` (`id`, `tenant_id`, `service_id`, `staff_id`, `user_id`, `customer_name`, `customer_phone`, `customer_email`, `starts_at`, `ends_at`, `status`, `notes`, `payment_status`, `deposit_paid`, `created_at`) VALUES
(1, 1, 2, 1, 2, 'Sam Rivera', '5550101888', 'sam@charlies.barber-shop.us', DATE_ADD(CURDATE(), INTERVAL 1 DAY) + INTERVAL 11 HOUR, DATE_ADD(CURDATE(), INTERVAL 1 DAY) + INTERVAL 11 HOUR + INTERVAL 50 MINUTE, 'confirmed', 'App test booking', 'unpaid', 0.00, CURRENT_TIMESTAMP);

-- --------------------------------------------------------

--
-- Table structure for table `booking_reminders`
--

CREATE TABLE `booking_reminders` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `booking_id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `channel` varchar(10) NOT NULL,
  `scheduled_for` datetime NOT NULL,
  `sent_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT 'pending',
  `provider_ref` varchar(100) DEFAULT NULL,
  `error_message` varchar(500) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `booking_reminders`
--

-- no pending reminder rows in a fresh hosted shop

-- --------------------------------------------------------

--
-- Table structure for table `client_policy`
--

CREATE TABLE `client_policy` (
  `tenant_id` int(11) NOT NULL,
  `notice_hours` int(11) NOT NULL DEFAULT 24,
  `cancel_fee` decimal(10,2) NOT NULL DEFAULT 25.00,
  `allow_reschedule` tinyint(1) NOT NULL DEFAULT 1,
  `allow_cancel` tinyint(1) NOT NULL DEFAULT 1,
  `fee_note` varchar(255) DEFAULT 'A cancellation fee may apply if changed within the notice window.'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `client_policy`
--

INSERT INTO `client_policy` (`tenant_id`, `notice_hours`, `cancel_fee`, `allow_reschedule`, `allow_cancel`, `fee_note`) VALUES
(1, 24, 25.00, 1, 1, 'Changes within 24 hours may incur a $25 fee (collected at the shop until online payments are enabled).');

-- --------------------------------------------------------

--
-- Table structure for table `license_metrics`
--

CREATE TABLE `license_metrics` (
  `tenant_id` int(11) NOT NULL,
  `subscription_type` varchar(50) DEFAULT 'starter',
  `renewal_date` date DEFAULT NULL,
  `sms_count_month` int(11) DEFAULT 0,
  `email_count_month` int(11) DEFAULT 0,
  `booking_count_month` int(11) DEFAULT 0,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `license_metrics`
--

INSERT INTO `license_metrics` (`tenant_id`, `subscription_type`, `renewal_date`, `sms_count_month`, `email_count_month`, `booking_count_month`, `notes`) VALUES
(1, 'hosted_subdomain', DATE_ADD(CURDATE(), INTERVAL 1 YEAR), 0, 0, 0, 'Test sale: hosted subdomain charlies.barber-shop.us');

-- --------------------------------------------------------

--
-- Table structure for table `media_assets`
--

CREATE TABLE `media_assets` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `file_tag` varchar(50) DEFAULT 'general',
  `optimized_path` varchar(255) DEFAULT NULL,
  `original_name` varchar(255) DEFAULT NULL,
  `mime_type` varchar(100) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `media_assets`
--

INSERT INTO `media_assets` (`id`, `tenant_id`, `file_path`, `file_tag`, `optimized_path`, `original_name`, `mime_type`, `created_at`) VALUES
(1, 1, 'tenant_1/43cd823af3aa4ad2_1784755944.jpg', 'general', NULL, 'PixVerse_Image_Effect_prompt_Create and image.jpg', 'image/jpeg', '2026-07-22 21:32:24'),
(2, 1, 'tenant_1/ee0790ed6c30648e_1784764602.jpg', 'lowskinfade', NULL, 'low skin fade.jpg', 'image/jpeg', '2026-07-22 23:56:42'),
(3, 1, 'tenant_1/a6102f4b39974da5_1784764754.png', 'classicpompadour', NULL, 'Classic Pompadour.png', 'image/png', '2026-07-22 23:59:14'),
(4, 1, 'tenant_1/82ab63f2e1ad7b57_1784764927.jpg', 'tailoredbeardtrim', NULL, 'Tailored Beard Trim.jpg', 'image/jpeg', '2026-07-23 00:02:07'),
(5, 1, 'tenant_1/42d5738ad065c501_1784765117.jpg', 'midfadecrop', NULL, 'Mid Fade Crop haircut.jpg', 'image/jpeg', '2026-07-23 00:05:17'),
(6, 1, 'tenant_1/50f4b19996f13fe6_1784765382.jpg', 'sidepartclassic', NULL, 'PixVerse_Image_Effect_prompt_for a barber shop.jpg', 'image/jpeg', '2026-07-23 00:09:42'),
(7, 1, 'tenant_1/fdf2e948f8bbedbb_1784765518.png', 'texturedquiff', NULL, 'Textured Quiff.png', 'image/png', '2026-07-23 00:11:58'),
(8, 1, 'tenant_1/9ad318979a5eea36_1784765680.png', 'fullbeardsculpt', NULL, 'Full Beard Sculpt.png', 'image/png', '2026-07-23 00:14:41'),
(9, 1, 'tenant_1/42a5eaa093a28cee_1784765829.png', 'mustachedetail', NULL, 'Mustache Detail.png', 'image/png', '2026-07-23 00:17:09'),
(10, 1, 'tenant_1/47cccaa99023cdc4_1785191778.jpg', 'skinfade', 'tenant_1/47cccaa99023cdc4_1785191778.webp', 'Skin Fade.jpg', 'image/jpeg', '2026-07-27 22:36:18'),
(11, 1, 'tenant_1/a653c57cabac305a_1785191787.png', 'middropfade', 'tenant_1/a653c57cabac305a_1785191787.webp', 'Mid Drop Fade.png', 'image/png', '2026-07-27 22:36:27'),
(12, 1, 'tenant_1/e1ad51a5ac6cf7ce_1785191797.jpg', 'lowertaperfade', 'tenant_1/e1ad51a5ac6cf7ce_1785191797.webp', 'Low Taper Fade.jpg', 'image/jpeg', '2026-07-27 22:36:37'),
(13, 1, 'tenant_1/a646b118ffefe1aa_1785193251.jpg', 'style', 'tenant_1/a646b118ffefe1aa_1785193251.webp', 'Curtain Bangs.jpg', 'image/jpeg', '2026-07-27 23:00:51'),
(14, 1, 'tenant_1/4d9b030e5e593e21_1785193269.jpg', 'general', 'tenant_1/4d9b030e5e593e21_1785193269.webp', 'Modern Mullet(1).jpg', 'image/jpeg', '2026-07-27 23:01:09'),
(15, 1, 'tenant_1/1ef8fc6059291d0a_1785193282.jpg', 'general', 'tenant_1/1ef8fc6059291d0a_1785193282.webp', 'Modern Mullet.jpg', 'image/jpeg', '2026-07-27 23:01:23'),
(16, 1, 'tenant_1/c6431ff7aca9acb5_1785193293.jpg', 'general', 'tenant_1/c6431ff7aca9acb5_1785193293.webp', 'French Crop- Men\'(1).jpg', 'image/jpeg', '2026-07-27 23:01:34'),
(17, 1, 'tenant_1/03c66deda466ace1_1785193305.jpg', 'general', 'tenant_1/03c66deda466ace1_1785193305.webp', 'French Crop- Men\'.jpg', 'image/jpeg', '2026-07-27 23:01:45'),
(18, 1, 'tenant_1/85d561d4b61793c2_1785193317.jpg', 'general', 'tenant_1/85d561d4b61793c2_1785193317.webp', 'Crew Cut with Skin Fade.jpg', 'image/jpeg', '2026-07-27 23:01:58'),
(19, 1, 'tenant_1/c6d514be489ee58a_1785193333.jpg', 'general', 'tenant_1/c6d514be489ee58a_1785193333.webp', 'Texture Crop- Men(1).jpg', 'image/jpeg', '2026-07-27 23:02:13'),
(20, 1, 'tenant_1/40fa06a76538e215_1785193343.jpg', 'general', 'tenant_1/40fa06a76538e215_1785193343.webp', 'Texture Crop.jpg', 'image/jpeg', '2026-07-27 23:02:24'),
(21, 1, 'tenant_1/57d458b7018795d9_1785193353.jpg', 'general', 'tenant_1/57d458b7018795d9_1785193353.webp', 'Textured Crop (2).jpg', 'image/jpeg', '2026-07-27 23:02:33'),
(22, 1, 'tenant_1/61d6e73e90ba33d2_1785193367.jpg', 'general', 'tenant_1/61d6e73e90ba33d2_1785193367.webp', 'Textured Crop.jpg', 'image/jpeg', '2026-07-27 23:02:47'),
(23, 1, 'tenant_1/7f43186a7f5b21b2_1785193376.jpg', 'general', 'tenant_1/7f43186a7f5b21b2_1785193376.webp', 'Texture Pomp.jpg', 'image/jpeg', '2026-07-27 23:02:57'),
(24, 1, 'tenant_1/faa90e30260d49bd_1785193387.jpg', 'general', 'tenant_1/faa90e30260d49bd_1785193387.webp', 'Buzz Cut Fade.jpg', 'image/jpeg', '2026-07-27 23:03:08'),
(25, 1, 'tenant_1/fe6209c4671b6ad6_1785193398.png', 'general', 'tenant_1/fe6209c4671b6ad6_1785193398.webp', 'Blowout with Lower Crop Fade.png', 'image/png', '2026-07-27 23:03:18'),
(26, 1, 'tenant_1/aa85a324ea161199_1785193408.jpg', 'general', 'tenant_1/aa85a324ea161199_1785193408.webp', 'Skin Fade.jpg', 'image/jpeg', '2026-07-27 23:03:29'),
(27, 1, 'tenant_1/0de7f7b7bcb90874_1785193421.png', 'general', 'tenant_1/0de7f7b7bcb90874_1785193421.webp', 'Mid Drop Fade.png', 'image/png', '2026-07-27 23:03:41'),
(28, 1, 'tenant_1/1c2d441c4bbb8670_1785193428.jpg', 'general', 'tenant_1/1c2d441c4bbb8670_1785193428.webp', 'Low Taper Fade.jpg', 'image/jpeg', '2026-07-27 23:03:49'),
(29, 1, 'tenant_1/dc62161177e02a9b_1785193442.jpg', 'general', 'tenant_1/dc62161177e02a9b_1785193442.webp', 'Warrior Cut- Men\'.jpg', 'image/jpeg', '2026-07-27 23:04:02'),
(30, 1, 'tenant_1/04b8929989e55875_1785193459.jpg', 'general', 'tenant_1/04b8929989e55875_1785193459.webp', 'Side Part with Low Taper.jpg', 'image/jpeg', '2026-07-27 23:04:20'),
(31, 1, 'tenant_1/0602b61d79fc1225_1785193469.jpg', 'general', 'tenant_1/0602b61d79fc1225_1785193469.webp', 'Brushback- Men\'s.jpg', 'image/jpeg', '2026-07-27 23:04:29'),
(32, 1, 'tenant_1/3512e51c58aaa04c_1785193479.jpg', 'general', 'tenant_1/3512e51c58aaa04c_1785193479.webp', 'Brushback- Men\'s(1).jpg', 'image/jpeg', '2026-07-27 23:04:39'),
(33, 1, 'tenant_1/49b50628f57d00bb_1785193489.jpg', 'general', 'tenant_1/49b50628f57d00bb_1785193489.webp', 'Messy Fringe.jpg', 'image/jpeg', '2026-07-27 23:04:50'),
(34, 1, 'tenant_1/5a06b84e6045a33b_1785194037.jpg', 'general', 'tenant_1/5a06b84e6045a33b_1785194037.webp', 'PixVerse_Image_Effect_prompt_Mustache Detail-.jpg', 'image/jpeg', '2026-07-27 23:13:57'),
(35, 1, 'tenant_1/67e0b807bac9fa86_1785194422.jpg', 'general', 'tenant_1/67e0b807bac9fa86_1785194422.webp', 'Combo Beard And C.jpg', 'image/jpeg', '2026-07-27 23:20:22'),
(36, 1, 'tenant_1/2f35d943699ed2de_1785194808.jpg', 'product', 'tenant_1/2f35d943699ed2de_1785194808.webp', 'PixVerse_Image_Effect_prompt_Matte Clay Pomade.jpg', 'image/jpeg', '2026-07-27 23:26:49'),
(37, 1, 'tenant_1/2115dea012e81f3e_1785194823.jpg', 'general', 'tenant_1/2115dea012e81f3e_1785194823.webp', 'PixVerse_Image_Effect_prompt_Beard Oil - Cedar(1).jpg', 'image/jpeg', '2026-07-27 23:27:03'),
(38, 1, 'tenant_1/2a071411cec46f01_1785194833.jpg', 'general', 'tenant_1/2a071411cec46f01_1785194833.webp', 'PixVerse_Image_Effect_prompt_Sea Salt Spray fo.jpg', 'image/jpeg', '2026-07-27 23:27:13'),
(39, 1, 'tenant_1/e0f62f195f5ed306_1785194842.jpg', 'general', 'tenant_1/e0f62f195f5ed306_1785194842.webp', 'PixVerse_Image_Effect_prompt_ Daily Organic Sh.jpg', 'image/jpeg', '2026-07-27 23:27:22'),
(40, 1, 'tenant_1/f32ae2704808c318_1785194851.jpg', 'general', 'tenant_1/f32ae2704808c318_1785194851.webp', 'PixVerse_Image_Effect_prompt_ Beard Brush.jpg', 'image/jpeg', '2026-07-27 23:27:32'),
(41, 1, 'tenant_1/5de1807c96ac4761_1785194861.jpg', 'general', 'tenant_1/5de1807c96ac4761_1785194861.webp', 'PixVerse_Image_Effect_prompt_ Aftershave Bal.jpg', 'image/jpeg', '2026-07-27 23:27:42'),
(42, 1, 'tenant_1/1701a91d70e672d7_1785195488.jpg', 'staff', 'tenant_1/1701a91d70e672d7_1785195488.webp', 'PixVerse_Image_Effect_prompt_a black barber po.jpg', 'image/jpeg', '2026-07-27 23:38:09'),
(43, 1, 'tenant_1/e54b0f8f3a5163a8_1785195499.jpg', 'staff', 'tenant_1/e54b0f8f3a5163a8_1785195499.webp', 'PixVerse_Image_Effect_prompt_a barber posing.jpg', 'image/jpeg', '2026-07-27 23:38:20');

-- --------------------------------------------------------

--
-- Table structure for table `page_settings`
--

CREATE TABLE `page_settings` (
  `tenant_id` int(11) NOT NULL,
  `hero_headline` varchar(255) DEFAULT NULL,
  `hero_subheadline` text DEFAULT NULL,
  `hero_media_path` varchar(255) DEFAULT NULL,
  `cta_text` varchar(100) DEFAULT 'Book Now',
  `cta_link` varchar(255) DEFAULT '#book',
  `business_name` varchar(255) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `social_links` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`social_links`)),
  `maps_embed` text DEFAULT NULL,
  `seo_title` varchar(255) DEFAULT NULL,
  `seo_description` text DEFAULT NULL,
  `announcement_enabled` tinyint(1) DEFAULT 0,
  `announcement_text` varchar(500) DEFAULT NULL,
  `announcement_bg_color` varchar(7) DEFAULT '#1a1a1a'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `page_settings`
--

INSERT INTO `page_settings` (`tenant_id`, `hero_headline`, `hero_subheadline`, `hero_media_path`, `cta_text`, `cta_link`, `business_name`, `address`, `phone`, `social_links`, `maps_embed`, `seo_title`, `seo_description`, `announcement_enabled`, `announcement_text`, `announcement_bg_color`) VALUES
(1, 'Title Here', 'Walk-ins welcome. Appointments preferred. Edit this copy in Admin → Page Content.', 'tenant_1/43cd823af3aa4ad2_1784755944.jpg', 'Book Now', '#book', 'Company Name Here', 'Address Here', '(555) 000-0000', '{\"instagram\":\"\",\"facebook\":\"\",\"tiktok\":\"\"}', '', 'Company Name Here', 'Edit this description in Admin → Page Content.', 0, '', '#1c1410');

-- --------------------------------------------------------

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `provider` varchar(30) NOT NULL,
  `purpose` varchar(40) NOT NULL,
  `reference_type` varchar(40) NOT NULL,
  `reference_id` int(11) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `currency` char(3) NOT NULL DEFAULT 'USD',
  `status` varchar(30) NOT NULL DEFAULT 'pending',
  `external_id` varchar(255) DEFAULT NULL,
  `checkout_url` text DEFAULT NULL,
  `payer_email` varchar(150) DEFAULT NULL,
  `meta_json` longtext DEFAULT NULL,
  `paid_at` datetime DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payments`
--

-- no payments in a fresh hosted shop

-- --------------------------------------------------------

--
-- Table structure for table `payment_settings`
--

CREATE TABLE `payment_settings` (
  `tenant_id` int(11) NOT NULL,
  `mode` varchar(10) NOT NULL DEFAULT 'test',
  `enable_stripe` tinyint(1) NOT NULL DEFAULT 0,
  `enable_paypal` tinyint(1) NOT NULL DEFAULT 0,
  `enable_venmo` tinyint(1) NOT NULL DEFAULT 0,
  `enable_square` tinyint(1) NOT NULL DEFAULT 0,
  `enable_ach` tinyint(1) NOT NULL DEFAULT 0,
  `enable_pay_at_shop` tinyint(1) NOT NULL DEFAULT 1,
  `stripe_publishable_key` varchar(255) DEFAULT NULL,
  `stripe_secret_key` varchar(255) DEFAULT NULL,
  `stripe_webhook_secret` varchar(255) DEFAULT NULL,
  `paypal_client_id` varchar(255) DEFAULT NULL,
  `paypal_client_secret` varchar(255) DEFAULT NULL,
  `paypal_webhook_id` varchar(255) DEFAULT NULL,
  `square_application_id` varchar(255) DEFAULT NULL,
  `square_access_token` varchar(255) DEFAULT NULL,
  `square_location_id` varchar(255) DEFAULT NULL,
  `default_currency` char(3) NOT NULL DEFAULT 'USD',
  `booking_payments` varchar(20) NOT NULL DEFAULT 'off',
  `retail_payments` varchar(20) NOT NULL DEFAULT 'optional',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payment_settings`
--

INSERT INTO `payment_settings` (`tenant_id`, `mode`, `enable_stripe`, `enable_paypal`, `enable_venmo`, `enable_square`, `enable_ach`, `enable_pay_at_shop`, `stripe_publishable_key`, `stripe_secret_key`, `stripe_webhook_secret`, `paypal_client_id`, `paypal_client_secret`, `paypal_webhook_id`, `square_application_id`, `square_access_token`, `square_location_id`, `default_currency`, `booking_payments`, `retail_payments`, `updated_at`) VALUES
(1, 'test', 0, 0, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'USD', 'off', 'optional', CURRENT_TIMESTAMP);

-- --------------------------------------------------------

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `slug` varchar(160) NOT NULL,
  `short_description` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `stock` int(11) NOT NULL DEFAULT 0,
  `image_path` varchar(255) DEFAULT NULL,
  `category` varchar(80) DEFAULT 'Grooming',
  `is_active` tinyint(1) DEFAULT 1,
  `display_order` int(11) DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `tenant_id`, `name`, `slug`, `short_description`, `description`, `price`, `stock`, `image_path`, `category`, `is_active`, `display_order`, `created_at`) VALUES
(1, 1, 'Matte Clay Pomade', 'matte-clay-pomade', 'Medium hold, natural finish.', 'Shop favorite clay for texture and control without shine. Water-based wash-out.', 18.00, 24, 'tenant_1/2f35d943699ed2de_1785194808.webp', 'Styling', 1, 1, '2026-07-23 00:44:55'),
(2, 1, 'Beard Oil - Cedar', 'beard-oil-cedar', 'Softens and conditions.', 'Lightweight cedarwood blend to tame itch and add healthy sheen.', 16.00, 30, 'tenant_1/2115dea012e81f3e_1785194823.webp', 'Beard', 1, 2, '2026-07-23 00:44:55'),
(3, 1, 'Sea Salt Spray', 'sea-salt-spray', 'Beach texture, light hold.', 'Lift and grit for casual styles. Mist on damp or dry hair.', 14.00, 20, 'tenant_1/2a071411cec46f01_1785194833.webp', 'Styling', 1, 3, '2026-07-23 00:44:55'),
(4, 1, 'Daily Shampoo', 'daily-shampoo', 'Clean without stripping.', 'Gentle daily wash for all hair types. Barbershop scent.', 12.00, 39, 'tenant_1/e0f62f195f5ed306_1785194842.webp', 'Wash', 1, 4, '2026-07-23 00:44:55'),
(5, 1, 'Aftershave Balm', 'aftershave-balm', 'Calms post-shave skin.', 'Alcohol-free balm with aloe. Use after hot towel shaves.', 15.00, 18, 'tenant_1/5de1807c96ac4761_1785194861.webp', 'Skin', 1, 5, '2026-07-23 00:44:55'),
(6, 1, 'Beard Brush', 'beard-brush', 'Boar bristle grooming brush.', 'Distributes oils evenly and shapes growth. Fits travel kit.', 22.00, 12, 'tenant_1/f32ae2704808c318_1785194851.webp', 'Tools', 1, 6, '2026-07-23 00:44:55');

-- --------------------------------------------------------

--
-- Table structure for table `reminder_settings`
--

CREATE TABLE `reminder_settings` (
  `tenant_id` int(11) NOT NULL,
  `email_enabled` tinyint(1) DEFAULT 1,
  `sms_enabled` tinyint(1) DEFAULT 0,
  `hours_before` int(11) DEFAULT 24,
  `email_from_name` varchar(150) DEFAULT 'Company Name Here',
  `email_from_address` varchar(150) DEFAULT NULL,
  `email_subject` varchar(255) DEFAULT 'Appointment reminder',
  `sms_template` varchar(500) DEFAULT 'Hi {name}, reminder: {service} on {date} at {time} with {barber}. Reply STOP to opt out.',
  `email_template` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `reminder_settings`
--

INSERT INTO `reminder_settings` (`tenant_id`, `email_enabled`, `sms_enabled`, `hours_before`, `email_from_name`, `email_from_address`, `email_subject`, `sms_template`, `email_template`) VALUES
(1, 1, 0, 24, 'Company Name Here', NULL, 'Reminder: your appointment at Company Name Here', 'Hi {name}, reminder: {service} on {date} at {time} with {barber}. Reply STOP to opt out.', 'Hi {name},\r\n\r\nThis is a reminder that you have {service} on {date} at {time} with {barber} at {shop}.\r\n\r\nSee you soon!');

-- --------------------------------------------------------

--
-- Table structure for table `schema_migrations`
--

CREATE TABLE `schema_migrations` (
  `filename` varchar(255) NOT NULL,
  `applied_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `schema_migrations`
--

INSERT INTO `schema_migrations` (`filename`, `applied_at`) VALUES
('001_schema.sql', CURRENT_TIMESTAMP),
('002_bookings.sql', CURRENT_TIMESTAMP),
('003_users_reminders.sql', CURRENT_TIMESTAMP),
('004_products.sql', CURRENT_TIMESTAMP),
('005_sms_carriers.sql', CURRENT_TIMESTAMP),
('006_client_portal.sql', CURRENT_TIMESTAMP),
('007_payments.sql', CURRENT_TIMESTAMP),
('008_staff_time_off.sql', CURRENT_TIMESTAMP),
('009_demo_presence.sql', CURRENT_TIMESTAMP),
('010_user_roles.sql', CURRENT_TIMESTAMP);

-- --------------------------------------------------------

--
-- Table structure for table `services`
--

CREATE TABLE `services` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `description` text DEFAULT NULL,
  `duration_minutes` int(11) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `deposit_mode` varchar(20) NOT NULL DEFAULT 'none',
  `deposit_value` decimal(10,2) NOT NULL DEFAULT 0.00,
  `image_url` varchar(255) DEFAULT NULL,
  `display_order` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `services`
--

INSERT INTO `services` (`id`, `tenant_id`, `name`, `description`, `duration_minutes`, `price`, `deposit_mode`, `deposit_value`, `image_url`, `display_order`) VALUES
(1, 1, 'Signature Haircut', 'Consultation, cut, and style finish.', 45, 35.00, 'none', 0.00, NULL, 1),
(2, 1, 'Skin Fade', 'Precision fade with clean finish.', 50, 40.00, 'none', 0.00, NULL, 2),
(3, 1, 'Beard Trim & Shape', 'Line-up, trim, and hot towel.', 30, 25.00, 'none', 0.00, NULL, 3),
(4, 1, 'Kids Cut', 'Ages 12 and under.', 30, 22.00, 'none', 0.00, NULL, 4),
(5, 1, 'Cut + Beard Combo', 'Full haircut with beard detailing.', 70, 55.00, 'none', 0.00, NULL, 5);

-- --------------------------------------------------------

--
-- Table structure for table `shop_orders`
--

CREATE TABLE `shop_orders` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `customer_name` varchar(150) NOT NULL,
  `customer_phone` varchar(50) DEFAULT NULL,
  `customer_email` varchar(150) DEFAULT NULL,
  `status` varchar(30) DEFAULT 'pending_pickup',
  `fulfillment` varchar(30) DEFAULT 'pickup',
  `subtotal` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total` decimal(10,2) NOT NULL DEFAULT 0.00,
  `notes` text DEFAULT NULL,
  `payment_status` varchar(30) NOT NULL DEFAULT 'unpaid',
  `payment_provider` varchar(30) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `shop_orders`
--

-- no retail orders in a fresh hosted shop

-- --------------------------------------------------------

--
-- Table structure for table `shop_order_items`
--

CREATE TABLE `shop_order_items` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `product_name` varchar(150) NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `qty` int(11) NOT NULL DEFAULT 1,
  `line_total` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `shop_order_items`
--

-- no retail order items in a fresh hosted shop

-- --------------------------------------------------------

--
-- Table structure for table `sms_carriers`
--

CREATE TABLE `sms_carriers` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `sms_domain` varchar(150) NOT NULL,
  `mms_domain` varchar(150) DEFAULT NULL,
  `country` char(2) DEFAULT 'US',
  `status` varchar(30) DEFAULT 'active',
  `notes` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sms_carriers`
--

INSERT INTO `sms_carriers` (`id`, `name`, `sms_domain`, `mms_domain`, `country`, `status`, `notes`, `is_active`) VALUES
(13, 'Verizon', 'vtext.com', 'vzwpix.com', 'US', 'degraded', 'Free gateway degrading - full shutdown announced ~Mar 2027', 1),
(14, 'AT&T', 'txt.att.net', 'mms.att.net', 'US', 'retired', 'Gateway shut down Jun 2025 - kept for reference only', 0),
(15, 'T-Mobile', 'tmomail.net', 'tmomail.net', 'US', 'retired', 'Gateway unreliable or offline since late 2024', 0),
(16, 'US Cellular', 'email.uscc.net', 'mms.uscc.net', 'US', 'active', 'May still accept email-to-SMS', 1),
(17, 'Google Fi', 'msg.fi.google.com', 'msg.fi.google.com', 'US', 'active', 'May still accept email-to-SMS', 1),
(18, 'Xfinity Mobile', 'vtext.com', 'vzwpix.com', 'US', 'degraded', 'Uses Verizon network / vtext', 1),
(19, 'Visible', 'vtext.com', 'vzwpix.com', 'US', 'degraded', 'Verizon MVNO / vtext', 1),
(20, 'Mint Mobile', 'tmomail.net', 'tmomail.net', 'US', 'retired', 'T-Mobile MVNO - gateway retired', 0),
(21, 'Cricket', 'mms.cricketwireless.net', 'mms.cricketwireless.net', 'US', 'retired', 'AT&T MVNO - gateway retired with AT&T', 0),
(22, 'Boost Mobile', 'sms.myboostmobile.com', 'myboostmobile.com', 'US', 'unknown', 'Status varies after network changes', 1),
(23, 'Metro by T-Mobile', 'mymetropcs.com', 'mymetropcs.com', 'US', 'retired', 'T-Mobile brand - treat as retired', 0),
(24, 'Other / Manual', 'custom', NULL, 'US', 'manual', 'Use custom gateway domain on the user record', 1);

-- --------------------------------------------------------

--
-- Table structure for table `staff_barbers`
--

CREATE TABLE `staff_barbers` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `title` varchar(100) DEFAULT NULL,
  `bio` text DEFAULT NULL,
  `specialties` varchar(255) DEFAULT NULL,
  `profile_image_url` varchar(255) DEFAULT NULL,
  `working_hours` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`working_hours`))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `staff_barbers`
--

INSERT INTO `staff_barbers` (`id`, `tenant_id`, `name`, `title`, `bio`, `specialties`, `profile_image_url`, `working_hours`) VALUES
(1, 1, 'Marcus Cole', 'Master Barber', 'Fifteen years behind the chair specializing in fades and classic cuts.', 'Fades, Tapers', 'tenant_1/1701a91d70e672d7_1785195488.webp', '{\"mon\":null,\"tue\":{\"open\":\"09:00\",\"close\":\"18:00\"},\"wed\":{\"open\":\"09:00\",\"close\":\"18:00\"},\"thu\":{\"open\":\"09:00\",\"close\":\"19:00\"},\"fri\":{\"open\":\"09:00\",\"close\":\"19:00\"},\"sat\":{\"open\":\"08:00\",\"close\":\"16:00\"},\"sun\":null}'),
(2, 1, 'Jordan Lee', 'Senior Barber', 'Beard sculpting and modern texture work.', 'Beards, Texture', 'tenant_1/e54b0f8f3a5163a8_1785195499.webp', '{\"mon\":null,\"tue\":{\"open\":\"10:00\",\"close\":\"18:00\"},\"wed\":{\"open\":\"10:00\",\"close\":\"18:00\"},\"thu\":{\"open\":\"10:00\",\"close\":\"18:00\"},\"fri\":{\"open\":\"10:00\",\"close\":\"19:00\"},\"sat\":{\"open\":\"09:00\",\"close\":\"15:00\"},\"sun\":null}');

-- --------------------------------------------------------

--
-- Table structure for table `staff_services`
--

CREATE TABLE `staff_services` (
  `staff_id` int(11) NOT NULL,
  `service_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `staff_services`
--

INSERT INTO `staff_services` (`staff_id`, `service_id`) VALUES
(1, 1),
(1, 2),
(1, 5),
(2, 1),
(2, 3),
(2, 4),
(2, 5);

-- --------------------------------------------------------

--
-- Table structure for table `staff_time_off`
--

CREATE TABLE `staff_time_off` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  `off_date` date NOT NULL,
  `is_day_off` tinyint(1) NOT NULL DEFAULT 1,
  `open_time` time DEFAULT NULL,
  `close_time` time DEFAULT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `style_gallery`
--

CREATE TABLE `style_gallery` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `style_name` varchar(150) NOT NULL,
  `category_tag` varchar(50) DEFAULT NULL,
  `image_url` varchar(255) NOT NULL,
  `linked_service_id` int(11) DEFAULT NULL,
  `is_active_stock` tinyint(1) DEFAULT 0,
  `display_order` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `style_gallery`
--

INSERT INTO `style_gallery` (`id`, `tenant_id`, `style_name`, `category_tag`, `image_url`, `linked_service_id`, `is_active_stock`, `display_order`) VALUES
(1, 1, 'Low Skin Fade', 'Haircut', 'tenant_1/ee0790ed6c30648e_1784764602.jpg', 2, 0, 1),
(2, 1, 'Classic Pompadour', 'Haircut', 'tenant_1/a6102f4b39974da5_1784764754.png', 1, 0, 2),
(5, 1, 'Textured Quiff', 'Haircut', 'tenant_1/fdf2e948f8bbedbb_1784765518.png', 1, 0, 5),
(8, 1, 'Side Part Classic', 'Haircut', 'tenant_1/50f4b19996f13fe6_1784765382.jpg', 1, 0, 8),
(11, 1, 'Textured Crop', 'Beard', 'tenant_1/61d6e73e90ba33d2_1785193367.webp', 3, 0, 11),
(19, 1, 'Low Taper Fade', 'Haircut', 'tenant_1/1c2d441c4bbb8670_1785193428.webp', 2, 0, 1),
(20, 1, 'Textured Pompadour', 'Haircut', 'tenant_1/7f43186a7f5b21b2_1785193376.webp', 1, 0, 2),
(21, 1, 'Tailored Beard Trim', 'Beard', 'tenant_1/82ab63f2e1ad7b57_1784764927.jpg', 3, 0, 3),
(22, 1, 'Mid Fade Crop', 'Haircut', 'tenant_1/42d5738ad065c501_1784765117.jpg', 2, 0, 4),
(24, 1, 'Full Beard Sculpt', 'Beard', 'tenant_1/9ad318979a5eea36_1784765680.png', 3, 0, 6),
(25, 1, 'Taper Fade', 'Haircut', 'https://images.unsplash.com/photo-1605497788044-5a32c7078486?w=800&q=80', 2, 1, 7),
(26, 1, 'French Crop', 'Haircut', 'tenant_1/03c66deda466ace1_1785193305.webp', 1, 0, 8),
(27, 1, 'Buzz Cut Clean', 'Haircut', 'tenant_1/85d561d4b61793c2_1785193317.webp', 1, 0, 9),
(29, 1, 'Mustache Detail', 'Beard', 'tenant_1/5a06b84e6045a33b_1785194037.webp', 3, 0, 11),
(30, 1, 'Blowout with Lower Crop Fade', 'Haircut', 'tenant_1/fe6209c4671b6ad6_1785193398.png', 2, 0, 12),
(31, 1, 'Curtain Bangs', 'Haircut', 'tenant_1/a646b118ffefe1aa_1785193251.webp', 1, 0, 13),
(32, 1, 'Buzz Cut Fade', 'Haircut', 'tenant_1/faa90e30260d49bd_1785193387.webp', 1, 0, 14),
(33, 1, 'Combo Cut + Beard', 'Haircut', 'tenant_1/67e0b807bac9fa86_1785194422.webp', 5, 0, 15),
(34, 1, 'Textured Pomp', 'Haircut', 'tenant_1/7f43186a7f5b21b2_1785193376.webp', 2, 0, 16),
(35, 1, 'Messy Fringe', 'Haircut', 'tenant_1/49b50628f57d00bb_1785193489.webp', 1, 0, 17),
(36, 1, 'Brushback', 'Beard', 'tenant_1/3512e51c58aaa04c_1785193479.webp', 3, 0, 18);

-- --------------------------------------------------------

--
-- Table structure for table `tenants`
--

CREATE TABLE `tenants` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `subdomain` varchar(100) DEFAULT NULL,
  `custom_domain` varchar(255) DEFAULT NULL,
  `primary_color` varchar(7) DEFAULT '#1a1a1a',
  `secondary_color` varchar(7) DEFAULT '#c9a227',
  `font_pairing` varchar(50) DEFAULT 'modern_sans',
  `license_status` varchar(50) DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `tenants`
--

INSERT INTO `tenants` (`id`, `name`, `subdomain`, `custom_domain`, `primary_color`, `secondary_color`, `font_pairing`, `license_status`, `created_at`) VALUES
(1, 'Company Name Here', 'charlies', NULL, '#1c1410', '#d4a017', 'classic_serif', 'active', '2026-08-25 00:00:00');

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `tenant_id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `email` varchar(150) DEFAULT NULL,
  `username` varchar(80) DEFAULT NULL,
  `role` varchar(20) NOT NULL DEFAULT 'customer',
  `carrier_id` int(11) DEFAULT NULL,
  `custom_sms_domain` varchar(150) DEFAULT NULL,
  `password_hash` varchar(255) DEFAULT NULL,
  `login_token` varchar(64) DEFAULT NULL,
  `login_token_expires` datetime DEFAULT NULL,
  `sms_opt_in` tinyint(1) DEFAULT 1,
  `email_opt_in` tinyint(1) DEFAULT 1,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `tenant_id`, `name`, `phone`, `email`, `username`, `role`, `carrier_id`, `custom_sms_domain`, `password_hash`, `login_token`, `login_token_expires`, `sms_opt_in`, `email_opt_in`, `notes`, `created_at`, `updated_at`) VALUES
(1, 1, 'Shop Owner', '5550142218', 'owner@charlies.barber-shop.us', 'admin', 'owner', NULL, NULL, '$2y$10$uNBtWWIebUNFgZOwZulaT.QqwPgb8sH8zHMsgflXORWWdqD0fRdh.', NULL, NULL, 0, 1, 'Shop owner / admin', '2026-08-25 00:00:00', '2026-08-25 00:00:00'),
(2, 1, 'Sam Rivera', '5550101888', 'sam@charlies.barber-shop.us', NULL, 'customer', NULL, NULL, '$2y$10$QIz5icexJAMOrw5tQP8imuuZKtqmAZlQqUuM2UoFmZgO2hbCs/wJu', NULL, NULL, 1, 1, 'Test customer for the Android app', '2026-08-25 00:00:00', '2026-08-25 00:00:00');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `bookings`
--
ALTER TABLE `bookings`
  ADD PRIMARY KEY (`id`),
  ADD KEY `service_id` (`service_id`),
  ADD KEY `staff_id` (`staff_id`),
  ADD KEY `idx_bookings_tenant_starts` (`tenant_id`,`starts_at`),
  ADD KEY `idx_bookings_user` (`user_id`);

--
-- Indexes for table `booking_reminders`
--
ALTER TABLE `booking_reminders`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tenant_id` (`tenant_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `idx_reminders_due` (`status`,`scheduled_for`),
  ADD KEY `idx_reminders_booking` (`booking_id`,`channel`);

--
-- Indexes for table `client_policy`
--
ALTER TABLE `client_policy`
  ADD PRIMARY KEY (`tenant_id`);

--
-- Indexes for table `license_metrics`
--
ALTER TABLE `license_metrics`
  ADD PRIMARY KEY (`tenant_id`);

--
-- Indexes for table `media_assets`
--
ALTER TABLE `media_assets`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_media_tenant_tag` (`tenant_id`,`file_tag`);

--
-- Indexes for table `page_settings`
--
ALTER TABLE `page_settings`
  ADD PRIMARY KEY (`tenant_id`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_payments_tenant_ref` (`tenant_id`,`reference_type`,`reference_id`),
  ADD KEY `idx_payments_external` (`provider`,`external_id`),
  ADD KEY `idx_payments_status` (`tenant_id`,`status`);

--
-- Indexes for table `payment_settings`
--
ALTER TABLE `payment_settings`
  ADD PRIMARY KEY (`tenant_id`);

--
-- Indexes for table `products`
--
ALTER TABLE `products`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_products_tenant_slug` (`tenant_id`,`slug`),
  ADD KEY `idx_products_tenant_active` (`tenant_id`,`is_active`,`display_order`);

--
-- Indexes for table `reminder_settings`
--
ALTER TABLE `reminder_settings`
  ADD PRIMARY KEY (`tenant_id`);

--
-- Indexes for table `schema_migrations`
--
ALTER TABLE `schema_migrations`
  ADD PRIMARY KEY (`filename`);

--
-- Indexes for table `services`
--
ALTER TABLE `services`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_services_tenant_order` (`tenant_id`,`display_order`);

--
-- Indexes for table `shop_orders`
--
ALTER TABLE `shop_orders`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `idx_orders_tenant` (`tenant_id`,`created_at`);

--
-- Indexes for table `shop_order_items`
--
ALTER TABLE `shop_order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`),
  ADD KEY `product_id` (`product_id`);

--
-- Indexes for table `sms_carriers`
--
ALTER TABLE `sms_carriers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_carrier_name` (`name`);

--
-- Indexes for table `staff_barbers`
--
ALTER TABLE `staff_barbers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tenant_id` (`tenant_id`);

--
-- Indexes for table `staff_services`
--
ALTER TABLE `staff_services`
  ADD PRIMARY KEY (`staff_id`,`service_id`),
  ADD KEY `service_id` (`service_id`);

--
-- Indexes for table `staff_time_off`
--
ALTER TABLE `staff_time_off`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_staff_off_day` (`staff_id`,`off_date`),
  ADD KEY `idx_time_off_tenant_date` (`tenant_id`,`off_date`);

--
-- Indexes for table `style_gallery`
--
ALTER TABLE `style_gallery`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tenant_id` (`tenant_id`),
  ADD KEY `linked_service_id` (`linked_service_id`);

--
-- Indexes for table `tenants`
--
ALTER TABLE `tenants`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `subdomain` (`subdomain`),
  ADD UNIQUE KEY `custom_domain` (`custom_domain`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_users_tenant_username` (`tenant_id`,`username`),
  ADD KEY `idx_users_tenant_phone` (`tenant_id`,`phone`),
  ADD KEY `idx_users_tenant_email` (`tenant_id`,`email`),
  ADD KEY `idx_users_login_token` (`login_token`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `bookings`
--
ALTER TABLE `bookings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `booking_reminders`
--
ALTER TABLE `booking_reminders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `media_assets`
--
ALTER TABLE `media_assets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=44;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `services`
--
ALTER TABLE `services`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `shop_orders`
--
ALTER TABLE `shop_orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `shop_order_items`
--
ALTER TABLE `shop_order_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `sms_carriers`
--
ALTER TABLE `sms_carriers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT for table `staff_barbers`
--
ALTER TABLE `staff_barbers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `staff_time_off`
--
ALTER TABLE `staff_time_off`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `style_gallery`
--
ALTER TABLE `style_gallery`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=37;

--
-- AUTO_INCREMENT for table `tenants`
--
ALTER TABLE `tenants`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `bookings`
--
ALTER TABLE `bookings`
  ADD CONSTRAINT `bookings_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `bookings_ibfk_2` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `bookings_ibfk_3` FOREIGN KEY (`staff_id`) REFERENCES `staff_barbers` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `booking_reminders`
--
ALTER TABLE `booking_reminders`
  ADD CONSTRAINT `booking_reminders_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `booking_reminders_ibfk_2` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `booking_reminders_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `client_policy`
--
ALTER TABLE `client_policy`
  ADD CONSTRAINT `client_policy_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `license_metrics`
--
ALTER TABLE `license_metrics`
  ADD CONSTRAINT `license_metrics_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `media_assets`
--
ALTER TABLE `media_assets`
  ADD CONSTRAINT `media_assets_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `page_settings`
--
ALTER TABLE `page_settings`
  ADD CONSTRAINT `page_settings_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payment_settings`
--
ALTER TABLE `payment_settings`
  ADD CONSTRAINT `payment_settings_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `products`
--
ALTER TABLE `products`
  ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `reminder_settings`
--
ALTER TABLE `reminder_settings`
  ADD CONSTRAINT `reminder_settings_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `services`
--
ALTER TABLE `services`
  ADD CONSTRAINT `services_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `shop_orders`
--
ALTER TABLE `shop_orders`
  ADD CONSTRAINT `shop_orders_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `shop_orders_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `shop_order_items`
--
ALTER TABLE `shop_order_items`
  ADD CONSTRAINT `shop_order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `shop_orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `shop_order_items_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `staff_barbers`
--
ALTER TABLE `staff_barbers`
  ADD CONSTRAINT `staff_barbers_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `staff_services`
--
ALTER TABLE `staff_services`
  ADD CONSTRAINT `staff_services_ibfk_1` FOREIGN KEY (`staff_id`) REFERENCES `staff_barbers` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `staff_services_ibfk_2` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `staff_time_off`
--
ALTER TABLE `staff_time_off`
  ADD CONSTRAINT `staff_time_off_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `staff_time_off_ibfk_2` FOREIGN KEY (`staff_id`) REFERENCES `staff_barbers` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `style_gallery`
--
ALTER TABLE `style_gallery`
  ADD CONSTRAINT `style_gallery_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `style_gallery_ibfk_2` FOREIGN KEY (`linked_service_id`) REFERENCES `services` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `users`
--
ALTER TABLE `users`
  ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
