-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1:3306
-- Généré le : mar. 03 fév. 2026 à 13:28
-- Version du serveur : 11.8.3-MariaDB-log
-- Version de PHP : 7.2.34

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 */;

--
-- Base de données : `u461727434_hyppAppManager`
--

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

--
-- Structure de la table `hy_cron_logs`
--

CREATE TABLE `hy_cron_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `app_name` varchar(80) NOT NULL,
  `cron_name` varchar(255) NOT NULL,
  `shop_id` int(10) UNSIGNED DEFAULT NULL,
  `start_time` datetime NOT NULL,
  `end_time` datetime DEFAULT NULL,
  `duration_ms` int(10) UNSIGNED DEFAULT NULL,
  `actions_count` int(11) NOT NULL DEFAULT 0,
  `status` enum('success','error') NOT NULL DEFAULT 'success',
  `error_message` varchar(500) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_permissions`
--

CREATE TABLE `hy_permissions` (
  `id` smallint(5) UNSIGNED NOT NULL,
  `permission_name` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_assets`
--

CREATE TABLE `hy_pg_assets` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `type` enum('image') NOT NULL DEFAULT 'image',
  `src_url` text NOT NULL,
  `alt_text` varchar(255) DEFAULT NULL,
  `link_url` text DEFAULT NULL,
  `open_in_new_tab` tinyint(1) NOT NULL DEFAULT 0,
  `utm_source` varchar(80) DEFAULT NULL,
  `utm_medium` varchar(80) DEFAULT NULL,
  `utm_campaign` varchar(120) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_asset_i18n`
--

CREATE TABLE `hy_pg_asset_i18n` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `asset_id` bigint(20) UNSIGNED NOT NULL,
  `locale` varchar(10) NOT NULL,
  `alt_text` varchar(255) DEFAULT NULL,
  `link_url` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_audit_logs`
--

CREATE TABLE `hy_pg_audit_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED DEFAULT NULL,
  `action` varchar(80) NOT NULL,
  `entity` varchar(80) NOT NULL,
  `entity_id` bigint(20) UNSIGNED NOT NULL,
  `diff_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (`diff_json` is null or json_valid(`diff_json`)),
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_campaigns`
--

CREATE TABLE `hy_pg_campaigns` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(150) NOT NULL,
  `status` enum('draft','active','paused','archived') NOT NULL DEFAULT 'draft',
  `start_at` datetime DEFAULT NULL,
  `end_at` datetime DEFAULT NULL,
  `priority` int(11) NOT NULL DEFAULT 100,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_placements`
--

CREATE TABLE `hy_pg_placements` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `campaign_id` bigint(20) UNSIGNED NOT NULL,
  `asset_id` bigint(20) UNSIGNED NOT NULL,
  `target_type` enum('collection_handle','collection_id','all_collections') NOT NULL DEFAULT 'collection_handle',
  `collection_handle` varchar(255) DEFAULT NULL,
  `collection_id` bigint(20) UNSIGNED DEFAULT NULL,
  `insert_mode` enum('after_product_index','every_n_products') NOT NULL DEFAULT 'after_product_index',
  `insert_after_index` int(10) UNSIGNED DEFAULT 4,
  `repeat_every_n` int(10) UNSIGNED DEFAULT NULL,
  `device` enum('all','mobile','desktop') NOT NULL DEFAULT 'all',
  `enabled` tinyint(1) NOT NULL DEFAULT 1,
  `start_at` datetime DEFAULT NULL,
  `end_at` datetime DEFAULT NULL,
  `max_width_px` int(10) UNSIGNED DEFAULT NULL,
  `border_radius_px` int(10) UNSIGNED DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_shop_settings`
--

CREATE TABLE `hy_pg_shop_settings` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `settings_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`settings_json`)),
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_pg_stats_daily`
--

CREATE TABLE `hy_pg_stats_daily` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `placement_id` bigint(20) UNSIGNED NOT NULL,
  `day` date NOT NULL,
  `impressions` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `clicks` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_roles`
--

CREATE TABLE `hy_roles` (
  `id` smallint(5) UNSIGNED NOT NULL,
  `role_name` varchar(50) NOT NULL,
  `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_role_permissions`
--

CREATE TABLE `hy_role_permissions` (
  `role_id` smallint(5) UNSIGNED NOT NULL,
  `permission_id` smallint(5) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_services_logs`
--

CREATE TABLE `hy_services_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED DEFAULT NULL,
  `app_name` varchar(80) DEFAULT NULL,
  `service_name` varchar(100) DEFAULT NULL,
  `status` enum('success','error','info') DEFAULT 'success',
  `confirmation` tinyint(1) DEFAULT 0,
  `action` varchar(255) NOT NULL,
  `json_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`json_data`)),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_shops`
--

CREATE TABLE `hy_shops` (
  `id` int(10) UNSIGNED NOT NULL,
  `shop_domain` varchar(255) NOT NULL,
  `shop_name` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Déchargement des données de la table `hy_shops`
--

INSERT INTO `hy_shops` (`id`, `shop_domain`, `shop_name`, `email`, `created_at`, `updated_at`) VALUES
(2, 'hypp-dev-store.myshopify.com', 'Hypp Dev Store', 'julien@hypp.agency', '2025-12-18 11:19:09', '2026-01-27 11:26:34');

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

--
-- Structure de la table `hy_shop_installs`
--

CREATE TABLE `hy_shop_installs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(80) NOT NULL,
  `access_token` varchar(255) NOT NULL,
  `scope` varchar(512) DEFAULT NULL,
  `plan_name` varchar(64) DEFAULT NULL,
  `billing_status` enum('none','pending','active','paused') NOT NULL DEFAULT 'none',
  `charge_id` bigint(20) UNSIGNED DEFAULT NULL,
  `installed_at` datetime NOT NULL DEFAULT current_timestamp(),
  `uninstalled_at` datetime DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Déchargement des données de la table `hy_shop_installs`
--

INSERT INTO `hy_shop_installs` (`id`, `shop_id`, `app_name`, `access_token`, `scope`, `plan_name`, `billing_status`, `charge_id`, `installed_at`, `uninstalled_at`, `updated_at`) VALUES
(2, 2, 'hypp_section_scheduler', 'shpua_9353bcad48f3ffda0605057bab86d4ee', 'read_themes,write_themes,read_shop', 'partner_test', 'none', NULL, '2025-12-18 11:19:09', NULL, '2025-12-18 11:19:09'),
(3, 2, 'gridpush', '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', 'write_theme_code,write_themes', NULL, 'none', NULL, '2026-01-27 11:26:34', NULL, '2026-01-27 11:26:34');

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

--
-- Structure de la table `hy_ss_activation_logs`
--

CREATE TABLE `hy_ss_activation_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(100) NOT NULL,
  `integration_id` bigint(20) UNSIGNED NOT NULL,
  `schedule_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action` enum('show','hide') NOT NULL,
  `decided_at` datetime NOT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `meta_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`meta_json`))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_ss_audit_logs`
--

CREATE TABLE `hy_ss_audit_logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(100) NOT NULL,
  `actor` varchar(255) DEFAULT NULL,
  `event` varchar(100) NOT NULL,
  `meta_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`meta_json`)),
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_ss_integrations`
--

CREATE TABLE `hy_ss_integrations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(100) NOT NULL,
  `template_key` varchar(255) NOT NULL,
  `section_id` varchar(255) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `status` enum('active','disabled','deleted') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_ss_schedules`
--

CREATE TABLE `hy_ss_schedules` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(80) NOT NULL DEFAULT 'section_scheduler',
  `theme_id` bigint(20) UNSIGNED DEFAULT NULL,
  `template_key` varchar(255) NOT NULL DEFAULT 'templates/index.json',
  `section_id` varchar(255) NOT NULL,
  `start_at` datetime NOT NULL,
  `end_at` datetime NOT NULL,
  `status` enum('scheduled','applied','expired','error') NOT NULL DEFAULT 'scheduled',
  `last_run_at` datetime DEFAULT NULL,
  `last_error` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_ss_section_schedules`
--

CREATE TABLE `hy_ss_section_schedules` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(100) NOT NULL,
  `section_id` varchar(255) NOT NULL,
  `block_id` varchar(255) NOT NULL,
  `template_key` varchar(255) DEFAULT NULL,
  `path` varchar(255) DEFAULT NULL,
  `enable_schedule` tinyint(1) NOT NULL DEFAULT 0,
  `start_at` datetime DEFAULT NULL,
  `end_at` datetime DEFAULT NULL,
  `status` enum('disabled','scheduled','active','expired','quota_exceeded') NOT NULL DEFAULT 'disabled',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_ss_shop_subscriptions`
--

CREATE TABLE `hy_ss_shop_subscriptions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `shop_id` int(10) UNSIGNED NOT NULL,
  `app_name` varchar(100) NOT NULL,
  `plan_code` enum('starter','essential','pro','plus') NOT NULL,
  `status` enum('active','cancelled','past_due','inactive') NOT NULL DEFAULT 'active',
  `shopify_charge_id` varchar(64) DEFAULT NULL,
  `current_period_end` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_users`
--

CREATE TABLE `hy_users` (
  `id` int(10) UNSIGNED NOT NULL,
  `civilite` enum('femme','homme','iel') DEFAULT 'homme',
  `username` varchar(50) NOT NULL,
  `nom` varchar(100) NOT NULL,
  `prenom` varchar(100) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` char(60) NOT NULL,
  `img_id` int(10) UNSIGNED DEFAULT NULL,
  `color` char(7) DEFAULT NULL CHECK (`color` regexp '^#[0-9A-Fa-f]{6}$'),
  `company_id` smallint(5) UNSIGNED DEFAULT NULL,
  `statut` enum('admin','manager','banned','utilisateur') DEFAULT 'utilisateur',
  `confirmation` tinyint(1) DEFAULT 0,
  `new_user` tinyint(1) DEFAULT 1,
  `failed_attempts` tinyint(3) UNSIGNED DEFAULT 0,
  `last_login` datetime DEFAULT NULL,
  `token` varchar(64) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_users_2fa`
--

CREATE TABLE `hy_users_2fa` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `channel` enum('email','totp') NOT NULL DEFAULT 'email',
  `code_hash` char(64) DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL,
  `attempts` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `consumed_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `hy_user_roles`
--

CREATE TABLE `hy_user_roles` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `role_id` smallint(5) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Index pour les tables déchargées
--

--
-- Index pour la table `hy_cron_logs`
--
ALTER TABLE `hy_cron_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_app_cron` (`app_name`,`cron_name`),
  ADD KEY `idx_shop` (`shop_id`);

--
-- Index pour la table `hy_permissions`
--
ALTER TABLE `hy_permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `permission_name` (`permission_name`);

--
-- Index pour la table `hy_pg_assets`
--
ALTER TABLE `hy_pg_assets`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop` (`shop_id`);

--
-- Index pour la table `hy_pg_asset_i18n`
--
ALTER TABLE `hy_pg_asset_i18n`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_asset_locale` (`asset_id`,`locale`);

--
-- Index pour la table `hy_pg_audit_logs`
--
ALTER TABLE `hy_pg_audit_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_time` (`shop_id`,`created_at`),
  ADD KEY `idx_entity` (`entity`,`entity_id`),
  ADD KEY `fk_pg_audit_user` (`user_id`);

--
-- Index pour la table `hy_pg_campaigns`
--
ALTER TABLE `hy_pg_campaigns`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_status` (`shop_id`,`status`),
  ADD KEY `idx_shop_window` (`shop_id`,`start_at`,`end_at`);

--
-- Index pour la table `hy_pg_placements`
--
ALTER TABLE `hy_pg_placements`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_enabled` (`shop_id`,`enabled`),
  ADD KEY `idx_campaign` (`campaign_id`),
  ADD KEY `idx_target` (`shop_id`,`target_type`,`collection_handle`),
  ADD KEY `fk_pg_place_asset` (`asset_id`);

--
-- Index pour la table `hy_pg_shop_settings`
--
ALTER TABLE `hy_pg_shop_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_shop` (`shop_id`);

--
-- Index pour la table `hy_pg_stats_daily`
--
ALTER TABLE `hy_pg_stats_daily`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_day` (`placement_id`,`day`),
  ADD KEY `idx_shop_day` (`shop_id`,`day`);

--
-- Index pour la table `hy_roles`
--
ALTER TABLE `hy_roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `role_name` (`role_name`);

--
-- Index pour la table `hy_role_permissions`
--
ALTER TABLE `hy_role_permissions`
  ADD PRIMARY KEY (`role_id`,`permission_id`),
  ADD KEY `fk_role_permission_perm` (`permission_id`);

--
-- Index pour la table `hy_services_logs`
--
ALTER TABLE `hy_services_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_id` (`shop_id`),
  ADD KEY `idx_app_name` (`app_name`);

--
-- Index pour la table `hy_shops`
--
ALTER TABLE `hy_shops`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `shop_domain` (`shop_domain`);

--
-- Index pour la table `hy_shop_installs`
--
ALTER TABLE `hy_shop_installs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_shop_app` (`shop_id`,`app_name`),
  ADD KEY `idx_app_name` (`app_name`);

--
-- Index pour la table `hy_ss_activation_logs`
--
ALTER TABLE `hy_ss_activation_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_app` (`shop_id`,`app_name`),
  ADD KEY `idx_integration` (`integration_id`),
  ADD KEY `idx_schedule` (`schedule_id`);

--
-- Index pour la table `hy_ss_audit_logs`
--
ALTER TABLE `hy_ss_audit_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_app` (`shop_id`,`app_name`),
  ADD KEY `idx_event` (`event`);

--
-- Index pour la table `hy_ss_integrations`
--
ALTER TABLE `hy_ss_integrations`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_shop_section` (`shop_id`,`app_name`,`template_key`,`section_id`),
  ADD KEY `idx_shop_app` (`shop_id`,`app_name`),
  ADD KEY `idx_template` (`template_key`);

--
-- Index pour la table `hy_ss_schedules`
--
ALTER TABLE `hy_ss_schedules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_shop_time` (`shop_id`,`start_at`,`end_at`),
  ADD KEY `idx_status` (`status`);

--
-- Index pour la table `hy_ss_section_schedules`
--
ALTER TABLE `hy_ss_section_schedules`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_shop_block` (`shop_id`,`app_name`,`block_id`),
  ADD KEY `idx_shop` (`shop_id`,`app_name`),
  ADD KEY `idx_section` (`section_id`),
  ADD KEY `idx_status` (`status`),
  ADD KEY `idx_start_end` (`start_at`,`end_at`);

--
-- Index pour la table `hy_ss_shop_subscriptions`
--
ALTER TABLE `hy_ss_shop_subscriptions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_shop_app` (`shop_id`,`app_name`),
  ADD KEY `idx_plan` (`plan_code`,`status`);

--
-- Index pour la table `hy_users`
--
ALTER TABLE `hy_users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`),
  ADD UNIQUE KEY `email` (`email`),
  ADD UNIQUE KEY `token` (`token`),
  ADD KEY `idx_users_email` (`email`),
  ADD KEY `idx_users_username` (`username`);

--
-- Index pour la table `hy_users_2fa`
--
ALTER TABLE `hy_users_2fa`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_user` (`user_id`),
  ADD KEY `idx_expires` (`expires_at`);

--
-- Index pour la table `hy_user_roles`
--
ALTER TABLE `hy_user_roles`
  ADD PRIMARY KEY (`user_id`,`role_id`),
  ADD KEY `fk_user_role_role` (`role_id`);

--
-- AUTO_INCREMENT pour les tables déchargées
--

--
-- AUTO_INCREMENT pour la table `hy_cron_logs`
--
ALTER TABLE `hy_cron_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_permissions`
--
ALTER TABLE `hy_permissions`
  MODIFY `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_assets`
--
ALTER TABLE `hy_pg_assets`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_asset_i18n`
--
ALTER TABLE `hy_pg_asset_i18n`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_audit_logs`
--
ALTER TABLE `hy_pg_audit_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_campaigns`
--
ALTER TABLE `hy_pg_campaigns`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_placements`
--
ALTER TABLE `hy_pg_placements`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_shop_settings`
--
ALTER TABLE `hy_pg_shop_settings`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_pg_stats_daily`
--
ALTER TABLE `hy_pg_stats_daily`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_roles`
--
ALTER TABLE `hy_roles`
  MODIFY `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_services_logs`
--
ALTER TABLE `hy_services_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_shops`
--
ALTER TABLE `hy_shops`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT pour la table `hy_shop_installs`
--
ALTER TABLE `hy_shop_installs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT pour la table `hy_ss_activation_logs`
--
ALTER TABLE `hy_ss_activation_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_ss_audit_logs`
--
ALTER TABLE `hy_ss_audit_logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_ss_integrations`
--
ALTER TABLE `hy_ss_integrations`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_ss_schedules`
--
ALTER TABLE `hy_ss_schedules`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_ss_section_schedules`
--
ALTER TABLE `hy_ss_section_schedules`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_ss_shop_subscriptions`
--
ALTER TABLE `hy_ss_shop_subscriptions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_users`
--
ALTER TABLE `hy_users`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `hy_users_2fa`
--
ALTER TABLE `hy_users_2fa`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- Contraintes pour les tables déchargées
--

--
-- Contraintes pour la table `hy_cron_logs`
--
ALTER TABLE `hy_cron_logs`
  ADD CONSTRAINT `fk_cron_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE SET NULL;

--
-- Contraintes pour la table `hy_pg_assets`
--
ALTER TABLE `hy_pg_assets`
  ADD CONSTRAINT `fk_pg_asset_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_pg_asset_i18n`
--
ALTER TABLE `hy_pg_asset_i18n`
  ADD CONSTRAINT `fk_pg_asset_i18n_asset` FOREIGN KEY (`asset_id`) REFERENCES `hy_pg_assets` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_pg_audit_logs`
--
ALTER TABLE `hy_pg_audit_logs`
  ADD CONSTRAINT `fk_pg_audit_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pg_audit_user` FOREIGN KEY (`user_id`) REFERENCES `hy_users` (`id`) ON DELETE SET NULL;

--
-- Contraintes pour la table `hy_pg_campaigns`
--
ALTER TABLE `hy_pg_campaigns`
  ADD CONSTRAINT `fk_pg_campaign_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_pg_placements`
--
ALTER TABLE `hy_pg_placements`
  ADD CONSTRAINT `fk_pg_place_asset` FOREIGN KEY (`asset_id`) REFERENCES `hy_pg_assets` (`id`),
  ADD CONSTRAINT `fk_pg_place_campaign` FOREIGN KEY (`campaign_id`) REFERENCES `hy_pg_campaigns` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pg_place_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_pg_shop_settings`
--
ALTER TABLE `hy_pg_shop_settings`
  ADD CONSTRAINT `fk_pg_settings_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_pg_stats_daily`
--
ALTER TABLE `hy_pg_stats_daily`
  ADD CONSTRAINT `fk_pg_stats_place` FOREIGN KEY (`placement_id`) REFERENCES `hy_pg_placements` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pg_stats_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_role_permissions`
--
ALTER TABLE `hy_role_permissions`
  ADD CONSTRAINT `fk_role_permission_perm` FOREIGN KEY (`permission_id`) REFERENCES `hy_permissions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_role_permission_role` FOREIGN KEY (`role_id`) REFERENCES `hy_roles` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_services_logs`
--
ALTER TABLE `hy_services_logs`
  ADD CONSTRAINT `fk_shop_log` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE SET NULL;

--
-- Contraintes pour la table `hy_shop_installs`
--
ALTER TABLE `hy_shop_installs`
  ADD CONSTRAINT `fk_install_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_ss_schedules`
--
ALTER TABLE `hy_ss_schedules`
  ADD CONSTRAINT `fk_ss_schedule_shop` FOREIGN KEY (`shop_id`) REFERENCES `hy_shops` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_users_2fa`
--
ALTER TABLE `hy_users_2fa`
  ADD CONSTRAINT `fk_2fa_user` FOREIGN KEY (`user_id`) REFERENCES `hy_users` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `hy_user_roles`
--
ALTER TABLE `hy_user_roles`
  ADD CONSTRAINT `fk_user_role_role` FOREIGN KEY (`role_id`) REFERENCES `hy_roles` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_user_role_user` FOREIGN KEY (`user_id`) REFERENCES `hy_users` (`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 */;
