-- https://www.phpmyadmin.net/
--
-- Erstellungszeit: 03. Apr 2025 um 13:51
-- Server-Version: 8.0.36
-- PHP-Version: 7.4.33

START TRANSACTION;



--
-- Datenbank: `dbs14050060`
--

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

--
-- Tabellenstruktur für Tabelle `admins`
--

CREATE TABLE `admins` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `role` enum('super_admin','admin','support') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'admin',
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Daten für Tabelle `admins`
--

INSERT INTO `admins` (`id`, `user_id`, `role`, `created_at`) VALUES
(1, 1, 'super_admin', '2025-03-24 14:21:07');

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

--
-- Tabellenstruktur für Tabelle `documents`
--

CREATE TABLE `documents` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `filename` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `original_filename` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `file_path` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `is_signed` tinyint(1) DEFAULT '0',
  `signature_data` text COLLATE utf8mb4_general_ci,
  `uploaded_at` datetime NOT NULL,
  `signed_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Daten für Tabelle `documents`
--

INSERT INTO `documents` (`id`, `user_id`, `filename`, `original_filename`, `file_path`, `is_signed`, `signature_data`, `uploaded_at`, `signed_at`) VALUES
(1, 1, '67e1954983e1b.pdf', 'Invoice-E860C555-0001.pdf', '/uploads/documents/1/67e1954983e1b.pdf', 0, NULL, '2025-03-24 18:24:25', NULL),
(2, 1, '67e1a4cc1530c.pdf', '240917_ZEN-5056_Hillebrand_green_25_A4_1499_v2.pdf', '/uploads/documents/1/67e1a4cc1530c.pdf', 0, NULL, '2025-03-24 19:30:36', NULL),
(3, 1, '67e1ae797eb6b.pdf', 'HRA DTec GmbH & Co. KG.pdf', '/uploads/documents/1/67e1ae797eb6b.pdf', 0, NULL, '2025-03-24 20:11:53', NULL),
(4, 1, '67e2eaa7a086f.pdf', '240917_ZEN-5056_Hillebrand_green_25_A4_1499_v2.pdf', '/uploads/documents/1/67e2eaa7a086f.pdf', 0, NULL, '2025-03-25 18:40:55', NULL),
(5, 1, '67ee8e1cafa8c.pdf', 'Invoice-E860C555-0001.pdf', '/uploads/documents/1/67ee8e1cafa8c.pdf', 0, NULL, '2025-04-03 15:33:16', NULL),
(6, 1, '67ee8ed0f1635.pdf', 'Invoice-E860C555-0001.pdf', '/uploads/documents/1/67ee8ed0f1635.pdf', 0, NULL, '2025-04-03 15:36:16', NULL),
(7, 1, '67ee8ed987640.pdf', 'Invoice-E860C555-0001.pdf', '/uploads/documents/1/67ee8ed987640.pdf', 0, NULL, '2025-04-03 15:36:25', NULL),
(8, 1, '67ee8f25861a0.pdf', 'Invoice-E860C555-0001.pdf', '/uploads/documents/1/67ee8f25861a0.pdf', 0, NULL, '2025-04-03 15:37:41', NULL);

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

--
-- Tabellenstruktur für Tabelle `document_comments`
--

CREATE TABLE `document_comments` (
  `id` int NOT NULL,
  `document_id` int NOT NULL,
  `user_id` int NOT NULL,
  `comment` text COLLATE utf8mb4_general_ci NOT NULL,
  `page_number` int DEFAULT NULL,
  `position_x` int DEFAULT NULL,
  `position_y` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `document_requests`
--

CREATE TABLE `document_requests` (
  `id` int NOT NULL,
  `requested_by` int NOT NULL,
  `requested_to` int NOT NULL,
  `user_id` int DEFAULT NULL,
  `subject` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `message` text COLLATE utf8mb4_general_ci,
  `status` varchar(20) COLLATE utf8mb4_general_ci DEFAULT 'pending',
  `document_id` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `document_usage`
--

CREATE TABLE `document_usage` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `subscription_id` int NOT NULL,
  `count` int DEFAULT '0',
  `month` int NOT NULL,
  `year` int NOT NULL,
  `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_general_ci;

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

--
-- Tabellenstruktur für Tabelle `document_versions`
--

CREATE TABLE `document_versions` (
  `id` int NOT NULL,
  `document_id` int NOT NULL,
  `version_number` int NOT NULL,
  `file_path` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `created_by` int NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `email_templates`
--

CREATE TABLE `email_templates` (
  `id` int NOT NULL,
  `name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `subject` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `body` text COLLATE utf8mb4_general_ci NOT NULL,
  `type` enum('verification','reset_password','welcome','invoice','otp') COLLATE utf8mb4_general_ci NOT NULL,
  `is_default` tinyint(1) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Daten für Tabelle `email_templates`
--

INSERT INTO `email_templates` (`id`, `name`, `subject`, `body`, `type`, `is_default`) VALUES
(1, 'Kontobestätigung', 'Bestätigen Sie Ihr Konto', '<h1>Willkommen bei unserem Service!</h1><p>Bitte klicken Sie auf den folgenden Link, um Ihr Konto zu bestätigen: {{verification_link}}</p>', 'verification', 1),
(2, 'Passwort zurücksetzen', 'Passwort zurücksetzen', '<h1>Passwort zurücksetzen</h1><p>Klicken Sie auf den folgenden Link, um Ihr Passwort zurückzusetzen: {{reset_link}}</p>', 'reset_password', 1),
(3, 'Willkommen', 'Willkommen bei unserem Service', '<h1>Willkommen bei unserem Service!</h1><p>Vielen Dank für Ihre Registrierung. Wir freuen uns, Sie an Bord zu haben!</p>', 'welcome', 1),
(4, 'Rechnung', 'Ihre Rechnung', '<h1>Rechnung</h1><p>Anbei finden Sie Ihre Rechnung für den Zeitraum {{billing_period}}.</p>', 'invoice', 1),
(5, 'OTP-Code', 'Ihr Einmalpasswort', '<h1>Ihr Einmalpasswort</h1><p>Hier ist Ihr Einmalpasswort für die Anmeldung: {{otp_code}}</p><p>Dieser Code ist 10 Minuten gültig.</p>', 'otp', 1);

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

--
-- Tabellenstruktur für Tabelle `email_usage`
--

CREATE TABLE `email_usage` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `subscription_id` int NOT NULL,
  `count` int DEFAULT '0',
  `month` int NOT NULL,
  `year` int NOT NULL,
  `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_general_ci;

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

--
-- Tabellenstruktur für Tabelle `invoices`
--

CREATE TABLE `invoices` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `payment_id` int NOT NULL,
  `invoice_number` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `invoice_date` date NOT NULL,
  `due_date` date NOT NULL,
  `total_amount` decimal(10,2) NOT NULL,
  `status` enum('paid','unpaid','cancelled') COLLATE utf8mb4_general_ci DEFAULT 'unpaid',
  `pdf_path` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `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_general_ci;

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

--
-- Tabellenstruktur für Tabelle `login_attempts`
--

CREATE TABLE `login_attempts` (
  `id` int NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_general_ci NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `payments`
--

CREATE TABLE `payments` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `subscription_id` int NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `currency` varchar(3) COLLATE utf8mb4_general_ci DEFAULT 'EUR',
  `payment_method` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `transaction_id` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `status` enum('pending','completed','failed','refunded') COLLATE utf8mb4_general_ci DEFAULT 'pending',
  `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_general_ci;

--
-- Daten für Tabelle `payments`
--

INSERT INTO `payments` (`id`, `user_id`, `subscription_id`, `amount`, `currency`, `payment_method`, `transaction_id`, `status`, `created_at`) VALUES
(1, 1, 1, '9.99', 'EUR', 'credit_card', 'TX17429463309054', 'completed', '2025-03-25 23:45:30');

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

--
-- Tabellenstruktur für Tabelle `signatures`
--

CREATE TABLE `signatures` (
  `id` int NOT NULL,
  `document_id` int NOT NULL,
  `user_id` int NOT NULL,
  `signature_image` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `signature_data` text COLLATE utf8mb4_general_ci,
  `position_x` int DEFAULT NULL,
  `position_y` int DEFAULT NULL,
  `page_number` int DEFAULT '1',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `subscription_plans`
--

CREATE TABLE `subscription_plans` (
  `id` int NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `description` text COLLATE utf8mb4_general_ci,
  `price` decimal(10,2) NOT NULL,
  `billing_cycle` enum('monthly','yearly') COLLATE utf8mb4_general_ci DEFAULT 'monthly',
  `is_active` tinyint(1) DEFAULT '1',
  `is_featured` tinyint(1) DEFAULT '0',
  `max_documents` int DEFAULT '10',
  `max_emails` int DEFAULT '50',
  `emails_per_month` int DEFAULT '50',
  `documents_per_month` int DEFAULT '10',
  `features` text COLLATE utf8mb4_general_ci,
  `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_general_ci;

--
-- Daten für Tabelle `subscription_plans`
--

INSERT INTO `subscription_plans` (`id`, `name`, `description`, `price`, `billing_cycle`, `is_active`, `is_featured`, `max_documents`, `max_emails`, `emails_per_month`, `documents_per_month`, `features`, `created_at`) VALUES
(1, 'Basic', 'Grundlegende Funktionen für kleine Teams', '9.99', 'monthly', 1, 0, 10, 50, 50, 10, '{\"signature\": true, \"templates\": false, \"api_access\": false}', '2025-03-25 16:46:07'),
(2, 'Professional', 'Erweiterte Funktionen für wachsende Unternehmen', '19.99', 'monthly', 1, 1, 50, 200, 200, 50, '{\"signature\": true, \"templates\": true, \"api_access\": false}', '2025-03-25 16:46:07'),
(3, 'Enterprise', 'Umfassende Lösung für große Unternehmen', '49.99', 'monthly', 1, 0, 200, 1000, 1000, 200, '{\"signature\": true, \"templates\": true, \"api_access\": true}', '2025-03-25 16:46:07');

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

--
-- Tabellenstruktur für Tabelle `system_logs`
--

CREATE TABLE `system_logs` (
  `id` int NOT NULL,
  `user_id` int DEFAULT NULL,
  `action` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `description` text COLLATE utf8mb4_general_ci,
  `ip_address` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_agent` text COLLATE utf8mb4_general_ci,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `system_settings`
--

CREATE TABLE `system_settings` (
  `id` int NOT NULL,
  `setting_key` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `setting_value` text COLLATE utf8mb4_general_ci,
  `setting_description` text COLLATE utf8mb4_general_ci,
  `is_public` tinyint(1) DEFAULT '0',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Daten für Tabelle `system_settings`
--

INSERT INTO `system_settings` (`id`, `setting_key`, `setting_value`, `setting_description`, `is_public`, `created_at`) VALUES
(1, 'site_name', 'SignaturePro', 'Name der Website', 1, '2025-03-25 16:23:12'),
(2, 'site_description', 'Digitale Signaturen leicht gemacht', 'Beschreibung der Website', 1, '2025-03-25 16:23:12'),
(3, 'admin_email', 'h.kahraman@dtec-group.de', 'Administrator E-Mail-Adresse', 0, '2025-03-25 16:23:12'),
(4, 'max_upload_size', '10', 'Maximale Upload-Größe in MB', 1, '2025-03-25 16:23:12'),
(5, 'allow_registration', '1', 'Registrierung erlauben (0/1)', 1, '2025-03-25 16:23:12'),
(6, 'require_email_verification', '1', 'E-Mail-Verifizierung erforderlich (0/1)', 0, '2025-03-25 16:23:12'),
(7, 'enable_2fa', '1', 'Zwei-Faktor-Authentifizierung aktivieren (0/1)', 0, '2025-03-25 16:23:12'),
(8, 'maintenance_mode', '0', 'Wartungsmodus aktivieren (0/1)', 0, '2025-03-25 16:23:12'),
(9, 'maintenance_message', 'Die Website wird derzeit gewartet. Bitte versuchen Sie es später erneut.', 'Wartungsmeldung', 0, '2025-03-25 16:23:12'),
(10, 'default_language', 'de', 'Standardsprache', 1, '2025-03-25 16:23:12'),
(11, 'default_timezone', 'Europe/Berlin', 'Standardzeitzone', 0, '2025-03-25 16:23:12'),
(13, 'app_name', 'Dokument-Management-System', NULL, 0, '2025-03-25 17:02:18'),
(14, 'app_url', 'http://localhost', NULL, 0, '2025-03-25 17:02:18'),
(15, 'company_name', 'Meine Firma GmbH', NULL, 0, '2025-03-25 17:02:18'),
(16, 'company_email', 'info@example.com', NULL, 0, '2025-03-25 17:02:18'),
(17, 'allowed_file_types', 'pdf,doc,docx,jpg,jpeg,png', NULL, 0, '2025-03-25 17:02:18'),
(18, 'enable_registration', '1', NULL, 0, '2025-03-25 17:02:18'),
(19, 'document_expiry_days', '30', NULL, 0, '2025-03-25 17:02:18'),
(20, 'enable_document_preview', '1', NULL, 0, '2025-03-25 17:02:18'),
(21, 'enable_document_download', '1', NULL, 0, '2025-03-25 17:02:18'),
(22, 'enable_document_sharing', '1', NULL, 0, '2025-03-25 17:02:18'),
(23, 'enable_document_templates', '1', NULL, 0, '2025-03-25 17:02:18'),
(24, 'enable_document_signing', '1', NULL, 0, '2025-03-25 17:02:18');

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

--
-- Tabellenstruktur für Tabelle `team_members`
--

CREATE TABLE `team_members` (
  `id` int NOT NULL,
  `owner_id` int NOT NULL,
  `member_id` int NOT NULL,
  `role` enum('admin','user') COLLATE utf8mb4_general_ci DEFAULT 'user',
  `invited_at` datetime NOT NULL,
  `joined_at` datetime DEFAULT NULL,
  `status` enum('pending','active','inactive') COLLATE utf8mb4_general_ci DEFAULT 'pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `user_settings`
--

CREATE TABLE `user_settings` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `theme` varchar(20) COLLATE utf8mb4_general_ci DEFAULT 'light',
  `language` varchar(10) COLLATE utf8mb4_general_ci DEFAULT 'de',
  `notifications_enabled` tinyint(1) DEFAULT '1',
  `signature_image` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `signature_data` text COLLATE utf8mb4_general_ci,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Tabellenstruktur für Tabelle `user_subscriptions`
--

CREATE TABLE `user_subscriptions` (
  `id` int NOT NULL,
  `user_id` int NOT NULL,
  `plan_id` int NOT NULL,
  `status` enum('active','cancelled','expired') COLLATE utf8mb4_general_ci DEFAULT 'active',
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `is_auto_renew` tinyint(1) DEFAULT '1',
  `is_custom` tinyint(1) DEFAULT '0',
  `custom_documents_limit` int DEFAULT NULL,
  `custom_emails_limit` int DEFAULT NULL,
  `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_general_ci;

--
-- Daten für Tabelle `user_subscriptions`
--

INSERT INTO `user_subscriptions` (`id`, `user_id`, `plan_id`, `status`, `start_date`, `end_date`, `is_auto_renew`, `is_custom`, `custom_documents_limit`, `custom_emails_limit`, `created_at`) VALUES
(1, 1, 1, 'active', '2025-03-26', '2025-04-26', 1, 0, NULL, NULL, '2025-03-25 23:45:30');

--
-- Indizes der exportierten Tabellen
--

--
-- Indizes für die Tabelle `admins`
--
ALTER TABLE `admins`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indizes für die Tabelle `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indizes für die Tabelle `document_comments`
--
ALTER TABLE `document_comments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `document_id` (`document_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indizes für die Tabelle `document_requests`
--
ALTER TABLE `document_requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `requested_by` (`requested_by`),
  ADD KEY `requested_to` (`requested_to`),
  ADD KEY `document_id` (`document_id`);

--
-- Indizes für die Tabelle `document_usage`
--
ALTER TABLE `document_usage`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `subscription_id` (`subscription_id`);

--
-- Indizes für die Tabelle `document_versions`
--
ALTER TABLE `document_versions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `document_id` (`document_id`),
  ADD KEY `created_by` (`created_by`);

--
-- Indizes für die Tabelle `email_templates`
--
ALTER TABLE `email_templates`
  ADD PRIMARY KEY (`id`);

--
-- Indizes für die Tabelle `email_usage`
--
ALTER TABLE `email_usage`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `subscription_id` (`subscription_id`);

--
-- Indizes für die Tabelle `invoices`
--
ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `payment_id` (`payment_id`);

--
-- Indizes für die Tabelle `login_attempts`
--
ALTER TABLE `login_attempts`
  ADD PRIMARY KEY (`id`);

--
-- Indizes für die Tabelle `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `subscription_id` (`subscription_id`);

--
-- Indizes für die Tabelle `signatures`
--
ALTER TABLE `signatures`
  ADD PRIMARY KEY (`id`),
  ADD KEY `document_id` (`document_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indizes für die Tabelle `subscription_plans`
--
ALTER TABLE `subscription_plans`
  ADD PRIMARY KEY (`id`);

--
-- Indizes für die Tabelle `system_logs`
--
ALTER TABLE `system_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `action` (`action`),
  ADD KEY `created_at` (`created_at`);

--
-- Indizes für die Tabelle `system_settings`
--
ALTER TABLE `system_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `setting_key` (`setting_key`);

--
-- Indizes für die Tabelle `team_members`
--
ALTER TABLE `team_members`
  ADD PRIMARY KEY (`id`),
  ADD KEY `owner_id` (`owner_id`),
  ADD KEY `member_id` (`member_id`);

--
-- Indizes für die Tabelle `user_settings`
--
ALTER TABLE `user_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_id` (`user_id`);

--
-- Indizes für die Tabelle `user_subscriptions`
--
ALTER TABLE `user_subscriptions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `plan_id` (`plan_id`);

--
-- AUTO_INCREMENT für exportierte Tabellen
--

--
-- AUTO_INCREMENT für Tabelle `admins`
--
ALTER TABLE `admins`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT für Tabelle `documents`
--
ALTER TABLE `documents`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT für Tabelle `document_comments`
--
ALTER TABLE `document_comments`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `document_requests`
--
ALTER TABLE `document_requests`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `document_usage`
--
ALTER TABLE `document_usage`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `document_versions`
--
ALTER TABLE `document_versions`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `email_templates`
--
ALTER TABLE `email_templates`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT für Tabelle `email_usage`
--
ALTER TABLE `email_usage`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `invoices`
--
ALTER TABLE `invoices`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `login_attempts`
--
ALTER TABLE `login_attempts`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT für Tabelle `signatures`
--
ALTER TABLE `signatures`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `subscription_plans`
--
ALTER TABLE `subscription_plans`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT für Tabelle `system_logs`
--
ALTER TABLE `system_logs`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `system_settings`
--
ALTER TABLE `system_settings`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT für Tabelle `team_members`
--
ALTER TABLE `team_members`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `user_settings`
--
ALTER TABLE `user_settings`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `user_subscriptions`
--
ALTER TABLE `user_subscriptions`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- Constraints der exportierten Tabellen
--

--
-- Constraints der Tabelle `admins`
--
ALTER TABLE `admins`
  ADD CONSTRAINT `admins_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `documents`
--
ALTER TABLE `documents`
  ADD CONSTRAINT `documents_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `document_comments`
--
ALTER TABLE `document_comments`
  ADD CONSTRAINT `document_comments_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `document_comments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `document_requests`
--
ALTER TABLE `document_requests`
  ADD CONSTRAINT `document_requests_ibfk_1` FOREIGN KEY (`requested_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `document_requests_ibfk_2` FOREIGN KEY (`requested_to`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `document_requests_ibfk_3` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE SET NULL;

--
-- Constraints der Tabelle `document_usage`
--
ALTER TABLE `document_usage`
  ADD CONSTRAINT `document_usage_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `document_usage_ibfk_2` FOREIGN KEY (`subscription_id`) REFERENCES `user_subscriptions` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `document_versions`
--
ALTER TABLE `document_versions`
  ADD CONSTRAINT `document_versions_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `document_versions_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `email_usage`
--
ALTER TABLE `email_usage`
  ADD CONSTRAINT `email_usage_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `email_usage_ibfk_2` FOREIGN KEY (`subscription_id`) REFERENCES `user_subscriptions` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `invoices`
--
ALTER TABLE `invoices`
  ADD CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `invoices_ibfk_2` FOREIGN KEY (`payment_id`) REFERENCES `payments` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `payments_ibfk_2` FOREIGN KEY (`subscription_id`) REFERENCES `user_subscriptions` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `signatures`
--
ALTER TABLE `signatures`
  ADD CONSTRAINT `signatures_ibfk_1` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `signatures_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `team_members`
--
ALTER TABLE `team_members`
  ADD CONSTRAINT `team_members_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `team_members_ibfk_2` FOREIGN KEY (`member_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `user_settings`
--
ALTER TABLE `user_settings`
  ADD CONSTRAINT `user_settings_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints der Tabelle `user_subscriptions`
--
ALTER TABLE `user_subscriptions`
  ADD CONSTRAINT `user_subscriptions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `user_subscriptions_ibfk_2` FOREIGN KEY (`plan_id`) REFERENCES `subscription_plans` (`id`);
COMMIT;

