-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost:3306
-- Généré le : dim. 04 oct. 2026 à 09:49
-- Version du serveur : 11.4.13-MariaDB
-- Version de PHP : 8.4.25

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 : `pobi2991_vulcanocloud`
--

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

--
-- Structure de la table `documents`
--

CREATE TABLE `documents` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `title` varchar(190) NOT NULL,
  `original_name` varchar(255) NOT NULL,
  `stored_name` varchar(255) NOT NULL,
  `size` bigint(20) UNSIGNED NOT NULL,
  `mime` varchar(100) NOT NULL,
  `category` varchar(50) NOT NULL,
  `favorite` tinyint(1) NOT NULL DEFAULT 0,
  `deleted_at` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `documents` (`id`, `user_id`, `title`, `original_name`, `stored_name`, `size`, `mime`, `category`, `favorite`, `deleted_at`, `created_at`) VALUES
(4, 3, 'test', 'Des2[1] (1).pdf', '87509bdac30e4d6645ce6a15ff07fa2bbca43a2205b64f1a.pdf', 141807, 'application/pdf', 'Identité', 0, NULL, '2026-07-28 07:29:29'),
(6, 4, 'test', 'tombe alic4e et fille.jpeg', '5410061202f5300df8af166f5e8264d578fcc57a8d40d5c6.jpg', 195669, 'image/jpeg', 'Identité', 0, NULL, '2026-07-28 08:06:58'),
(8, 7, 'test', '64055c4a-de41-4eea-9475-9e16ecb4770f.jpeg', 'a8bc7670dc786d18d6d9c73ac1c7d3466d0d12a54e3335e4.jpg', 263891, 'image/jpeg', 'Identité', 0, NULL, '2026-07-30 13:42:47');

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

--
-- Structure de la table `document_shares`
--

CREATE TABLE `document_shares` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `document_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `token_hash` char(64) NOT NULL,
  `password_hash` varchar(255) DEFAULT NULL,
  `expires_at` datetime NOT NULL,
  `revoked_at` datetime DEFAULT NULL,
  `access_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `last_accessed_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 `file_deletion_queue`
--

CREATE TABLE `file_deletion_queue` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `stored_name` varchar(255) NOT NULL,
  `reason` varchar(64) NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `document_id` bigint(20) UNSIGNED DEFAULT NULL,
  `attempts` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `last_error` varchar(1000) DEFAULT NULL,
  `next_attempt_at` datetime NOT NULL DEFAULT current_timestamp(),
  `completed_at` datetime 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 `password_reset_tokens`
--

CREATE TABLE `password_reset_tokens` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `token_hash` char(64) NOT NULL,
  `expires_at` datetime NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `used_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Structure de la table `security_events`
--

CREATE TABLE `security_events` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `event_type` varchar(64) NOT NULL,
  `ip_address` varchar(45) NOT NULL,
  `user_agent` varchar(255) NOT NULL DEFAULT '',
  `context_data` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `security_events` (`id`, `user_id`, `event_type`, `ip_address`, `user_agent`, `context_data`, `created_at`) VALUES
(1, 7, 'login_refused', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"reason\":\"invalid_credentials\"}', '2026-07-30 15:30:56'),
(2, 7, 'login_success', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"two_factor\":true}', '2026-07-30 15:33:43'),
(3, 7, 'login_refused', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"reason\":\"invalid_credentials\"}', '2026-07-30 15:36:29'),
(4, 7, 'two_factor_success', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', NULL, '2026-07-30 15:36:49'),
(5, 7, 'login_success', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"two_factor\":true}', '2026-07-30 15:36:49'),
(6, 7, 'login_refused', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"reason\":\"invalid_credentials\"}', '2026-07-30 15:40:27'),
(7, 7, 'two_factor_failed', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"reason\":\"invalid_code\",\"attempt_count\":1}', '2026-07-30 15:40:39'),
(8, 7, 'two_factor_success', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', NULL, '2026-07-30 15:40:50'),
(9, 7, 'login_success', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"two_factor\":true}', '2026-07-30 15:40:50'),
(10, 7, 'document_uploaded', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"document_id\":8,\"category\":\"Identité\",\"mime\":\"image/jpeg\",\"size\":263891}', '2026-07-30 15:42:47'),
(11, 7, 'document_downloaded', '95.75.175.193', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36', '{\"document_id\":8,\"mime\":\"image/jpeg\",\"size\":263891}', '2026-07-30 15:44:39');

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

--
-- Structure de la table `share_password_attempts`
--

CREATE TABLE `share_password_attempts` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `share_id` bigint(20) UNSIGNED NOT NULL,
  `ip_hash` char(64) NOT NULL,
  `attempt_count` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `window_started_at` datetime NOT NULL DEFAULT current_timestamp(),
  `blocked_until` datetime 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 `users`
--

CREATE TABLE `users` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `email` varchar(190) NOT NULL,
  `pending_email` varchar(190) DEFAULT NULL,
  `pending_email_token_hash` char(64) DEFAULT NULL,
  `pending_email_expires_at` datetime DEFAULT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `email_verified_at` datetime DEFAULT NULL,
  `two_factor_enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  `session_version` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `email_verification_token_hash` char(64) DEFAULT NULL,
  `email_verification_expires_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `users` (`id`, `name`, `email`, `pending_email`, `pending_email_token_hash`, `pending_email_expires_at`, `password`, `created_at`, `email_verified_at`, `two_factor_enabled`, `session_version`, `email_verification_token_hash`, `email_verification_expires_at`) VALUES
(3, 'test.v3', 'luc.meillan@aefe.fr', NULL, NULL, NULL, '$2y$10$IhVFWPdmtDuWUSExVu7Lt.QRg1xpRt7yXeu.6L92PJ0r8H7zMsVs2', '2026-07-28 07:29:00', '2026-07-28 11:49:32', 0, 1, NULL, NULL),
(4, 'testv3', 'lucky86525499@vhugo.org', NULL, NULL, NULL, '$2y$10$VJnVjcPhTXaCtPnf.aaY3.5qLKlWnImQobmTM7ujaZ0h5vnv1TYNm', '2026-07-28 07:47:23', '2026-07-28 11:49:32', 0, 1, NULL, NULL),
(5, 'memo examen', 'meillan.l.fr@gmail.com', NULL, NULL, NULL, '$2y$10$sNOZWt0VWwut7t1L.zooqO4KeE2YFG2jUzC71lrIRAXrDWDiUdT5K', '2026-07-28 08:44:56', '2026-07-28 11:49:32', 0, 1, NULL, NULL),
(6, 'testv4', 'russtorm@ik.me', NULL, NULL, NULL, '$2y$10$L4Xn//eTmT.wTCwvmvzLz.h14p.gsVGQxj4Nzy5GJi5qDhy2D9rIW', '2026-07-28 09:59:59', '2026-07-28 12:00:17', 0, 1, NULL, NULL),
(7, 'testv5', 'luc@vhugo.org', NULL, NULL, NULL, '$2y$10$GWdkUYzOevGGhNr7pXi.YesDgb60DFKNV4CTeVmOw0DsfWLkbusv6', '2026-07-30 13:12:27', '2026-07-30 15:13:32', 1, 1, NULL, NULL);

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

--
-- Structure de la table `user_two_factor_codes`
--

CREATE TABLE `user_two_factor_codes` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `code_hash` varchar(255) NOT NULL,
  `expires_at` datetime NOT NULL,
  `attempt_count` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
  `used_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Index pour la table `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `stored_name` (`stored_name`),
  ADD KEY `idx_documents_user` (`user_id`),
  ADD KEY `idx_documents_deleted` (`deleted_at`);

--
-- Index pour la table `document_shares`
--
ALTER TABLE `document_shares`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_document_shares_token_hash` (`token_hash`),
  ADD KEY `idx_document_shares_user_id` (`user_id`),
  ADD KEY `idx_document_shares_document_id` (`document_id`),
  ADD KEY `idx_document_shares_expires_at` (`expires_at`);

--
-- Index pour la table `file_deletion_queue`
--
ALTER TABLE `file_deletion_queue`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_file_deletion_queue_stored_name` (`stored_name`),
  ADD KEY `idx_file_deletion_queue_due` (`completed_at`,`next_attempt_at`),
  ADD KEY `idx_file_deletion_queue_user_id` (`user_id`),
  ADD KEY `idx_file_deletion_queue_document_id` (`document_id`);

--
-- Index pour la table `password_reset_tokens`
--
ALTER TABLE `password_reset_tokens`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_password_reset_token_hash` (`token_hash`),
  ADD KEY `idx_password_reset_user_id` (`user_id`),
  ADD KEY `idx_password_reset_expires_at` (`expires_at`);

--
-- Index pour la table `security_events`
--
ALTER TABLE `security_events`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_security_events_user_created` (`user_id`,`created_at`),
  ADD KEY `idx_security_events_type` (`event_type`),
  ADD KEY `idx_security_events_created_at` (`created_at`);

--
-- Index pour la table `share_password_attempts`
--
ALTER TABLE `share_password_attempts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_share_password_attempts_share_ip` (`share_id`,`ip_hash`),
  ADD KEY `idx_share_password_attempts_blocked_until` (`blocked_until`),
  ADD KEY `idx_share_password_attempts_updated_at` (`updated_at`);

--
-- Index pour la table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`),
  ADD UNIQUE KEY `uq_users_email_verification_token_hash` (`email_verification_token_hash`),
  ADD UNIQUE KEY `uq_users_pending_email` (`pending_email`),
  ADD UNIQUE KEY `uq_users_pending_email_token_hash` (`pending_email_token_hash`),
  ADD KEY `idx_users_pending_email_expires_at` (`pending_email_expires_at`);

--
-- Index pour la table `user_two_factor_codes`
--
ALTER TABLE `user_two_factor_codes`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_two_factor_user_id` (`user_id`),
  ADD KEY `idx_two_factor_expires_at` (`expires_at`),
  ADD KEY `idx_two_factor_user_created` (`user_id`,`created_at`);

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

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

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

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

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

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

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

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

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

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

--
-- Contraintes pour la table `documents`
--
ALTER TABLE `documents`
  ADD CONSTRAINT `fk_documents_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `security_events`
--
ALTER TABLE `security_events`
  ADD CONSTRAINT `fk_security_events_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Contraintes pour la table `user_two_factor_codes`
--
ALTER TABLE `user_two_factor_codes`
  ADD CONSTRAINT `fk_two_factor_user` FOREIGN KEY (`user_id`) REFERENCES `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 */;
