Initial delta: full developer manual + DB bootstrap
Generated from finetuning-plattform develop @ 70b203c on 2026-05-14. Contents: - MANUAL.md — full developer manual, setup at front (28 sections) - bootstrap-db.sh — one-command DB initialization - db/01-schema.sql — MariaDB schema, no data - db/02-seed.sql — reference data (ACL, email templates, API registry) - db/03-default-users.sql — admin + test user, argon2id hashes Drop-in package for new developers joining the platform.
This commit is contained in:
639
db/01-schema.sql
Normal file
639
db/01-schema.sql
Normal file
@@ -0,0 +1,639 @@
|
||||
/*M!999999\- enable the sandbox mode */
|
||||
|
||||
/*!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 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `account` (
|
||||
`account_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`account_name` varchar(255) DEFAULT NULL,
|
||||
`account_active` tinyint(1) DEFAULT 1,
|
||||
`account_email` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `account_to_api_registry` (
|
||||
`account_id` int(11) NOT NULL,
|
||||
`api_registry_id` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`account_id`),
|
||||
KEY `account_to_api_registry_api_registry_api_registry_id_fk` (`api_registry_id`),
|
||||
CONSTRAINT `account_to_api_registry_account_account_id_fk` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`),
|
||||
CONSTRAINT `account_to_api_registry_api_registry_api_registry_id_fk` FOREIGN KEY (`api_registry_id`) REFERENCES `api_registry` (`api_registry_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `acl` (
|
||||
`acl_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`acl_role` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`acl_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `agent_templates` (
|
||||
`agent_templates_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`agent_templates_user_id` int(11) NOT NULL,
|
||||
`agent_templates_template_key` varchar(50) NOT NULL,
|
||||
`agent_templates_name` varchar(150) NOT NULL,
|
||||
`agent_templates_description` text DEFAULT NULL,
|
||||
`agent_templates_system_prompt` text DEFAULT NULL,
|
||||
`agent_templates_personality` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`agent_templates_personality`)),
|
||||
`agent_templates_knowledge_cats` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`agent_templates_knowledge_cats`)),
|
||||
`agent_templates_training_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`agent_templates_training_data`)),
|
||||
`agent_templates_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`agent_templates_config`)),
|
||||
`agent_templates_status` enum('draft','active','archived') DEFAULT 'draft',
|
||||
`agent_templates_created_at` datetime DEFAULT current_timestamp(),
|
||||
`agent_templates_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`agent_templates_id`),
|
||||
KEY `fk_agent_templates_user` (`agent_templates_user_id`),
|
||||
CONSTRAINT `fk_agent_templates_user` FOREIGN KEY (`agent_templates_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `api_keys` (
|
||||
`api_keys_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`api_keys_user_id` int(11) NOT NULL,
|
||||
`api_keys_name` varchar(100) NOT NULL,
|
||||
`api_keys_hash` varchar(255) NOT NULL,
|
||||
`api_keys_prefix` varchar(20) NOT NULL,
|
||||
`api_keys_permissions` longtext DEFAULT NULL,
|
||||
`api_keys_last_used` datetime DEFAULT NULL,
|
||||
`api_keys_status` enum('active','revoked') DEFAULT 'active',
|
||||
`api_keys_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`api_keys_id`),
|
||||
KEY `idx_user_id` (`api_keys_user_id`),
|
||||
KEY `idx_status` (`api_keys_status`),
|
||||
CONSTRAINT `fk_api_keys_user` FOREIGN KEY (`api_keys_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `api_registry` (
|
||||
`api_registry_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`api_name` varchar(255) DEFAULT NULL,
|
||||
`api_registered` tinyint(4) DEFAULT 0,
|
||||
PRIMARY KEY (`api_registry_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `chat_messages` (
|
||||
`chat_messages_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`chat_messages_session_id` int(11) NOT NULL,
|
||||
`chat_messages_user_id` int(11) NOT NULL,
|
||||
`chat_messages_role` enum('user','assistant','system') NOT NULL,
|
||||
`chat_messages_content` mediumtext NOT NULL,
|
||||
`chat_messages_rating` tinyint(4) DEFAULT NULL COMMENT 'NULL=unrated, 1=thumbs up, -1=thumbs down',
|
||||
`chat_messages_feedback_note` text DEFAULT NULL,
|
||||
`chat_messages_total_duration` bigint(20) DEFAULT NULL COMMENT 'Ollama total_duration in ns',
|
||||
`chat_messages_eval_count` int(11) DEFAULT NULL COMMENT 'Ollama eval_count (output tokens)',
|
||||
`chat_messages_regenerated` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`chat_messages_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`chat_messages_id`),
|
||||
KEY `idx_chat_messages_session` (`chat_messages_session_id`),
|
||||
KEY `idx_chat_messages_user` (`chat_messages_user_id`),
|
||||
KEY `idx_chat_messages_rating` (`chat_messages_rating`),
|
||||
CONSTRAINT `fk_chat_messages_session` FOREIGN KEY (`chat_messages_session_id`) REFERENCES `test_sessions` (`session_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_chat_messages_user` FOREIGN KEY (`chat_messages_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `chat_shares` (
|
||||
`chat_shares_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`chat_shares_session_id` int(11) NOT NULL,
|
||||
`chat_shares_user_id` int(11) NOT NULL,
|
||||
`chat_shares_token` varchar(64) NOT NULL,
|
||||
`chat_shares_expires_at` datetime DEFAULT NULL,
|
||||
`chat_shares_view_count` int(11) NOT NULL DEFAULT 0,
|
||||
`chat_shares_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`chat_shares_id`),
|
||||
UNIQUE KEY `uniq_chat_shares_token` (`chat_shares_token`),
|
||||
KEY `fk_chat_shares_user` (`chat_shares_user_id`),
|
||||
KEY `idx_chat_shares_session` (`chat_shares_session_id`),
|
||||
CONSTRAINT `fk_chat_shares_session` FOREIGN KEY (`chat_shares_session_id`) REFERENCES `test_sessions` (`session_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_chat_shares_user` FOREIGN KEY (`chat_shares_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `datasets` (
|
||||
`datasets_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`datasets_user_id` int(11) NOT NULL,
|
||||
`datasets_name` varchar(255) NOT NULL,
|
||||
`datasets_description` text DEFAULT NULL,
|
||||
`datasets_file_path` varchar(500) DEFAULT NULL,
|
||||
`datasets_file_format` enum('jsonl','csv','txt','parquet','pdf','docx') DEFAULT 'jsonl',
|
||||
`datasets_sample_count` int(11) DEFAULT 0,
|
||||
`datasets_file_size_bytes` bigint(20) DEFAULT 0,
|
||||
`datasets_status` enum('uploading','processing','ready','error') DEFAULT 'uploading',
|
||||
`datasets_validation_result` longtext DEFAULT NULL,
|
||||
`datasets_created_at` datetime DEFAULT current_timestamp(),
|
||||
`datasets_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`datasets_id`),
|
||||
KEY `idx_user_id` (`datasets_user_id`),
|
||||
KEY `idx_status` (`datasets_status`),
|
||||
CONSTRAINT `fk_datasets_user` FOREIGN KEY (`datasets_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `email_notification_preferences` (
|
||||
`email_notification_preferences_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email_notification_preferences_user_id` int(11) NOT NULL,
|
||||
`email_notification_preferences_type` varchar(50) NOT NULL COMMENT 'e.g. welcome, job-started, job-completed, job-failed, low-credits, security-alert',
|
||||
`email_notification_preferences_enabled` tinyint(1) DEFAULT 1,
|
||||
`email_notification_preferences_created_at` datetime DEFAULT current_timestamp(),
|
||||
`email_notification_preferences_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`email_notification_preferences_id`),
|
||||
UNIQUE KEY `unique_user_notification_type` (`email_notification_preferences_user_id`,`email_notification_preferences_type`),
|
||||
CONSTRAINT `fk_email_notif_pref_user` FOREIGN KEY (`email_notification_preferences_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `email_queue` (
|
||||
`email_queue_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email_queue_user_id` int(11) DEFAULT NULL,
|
||||
`email_queue_template_slug` varchar(100) DEFAULT NULL,
|
||||
`email_queue_to_email` varchar(255) NOT NULL,
|
||||
`email_queue_to_name` varchar(255) DEFAULT NULL,
|
||||
`email_queue_subject` varchar(255) NOT NULL,
|
||||
`email_queue_body_html` text NOT NULL,
|
||||
`email_queue_body_text` text DEFAULT NULL,
|
||||
`email_queue_status` enum('pending','sending','sent','failed') DEFAULT 'pending',
|
||||
`email_queue_priority` tinyint(4) DEFAULT 5 COMMENT '1=highest, 10=lowest',
|
||||
`email_queue_attempts` int(11) DEFAULT 0,
|
||||
`email_queue_max_attempts` int(11) DEFAULT 3,
|
||||
`email_queue_last_error` text DEFAULT NULL,
|
||||
`email_queue_scheduled_at` datetime DEFAULT NULL COMMENT 'NULL = send immediately',
|
||||
`email_queue_sent_at` datetime DEFAULT NULL,
|
||||
`email_queue_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`email_queue_id`),
|
||||
KEY `fk_email_queue_user` (`email_queue_user_id`),
|
||||
KEY `idx_email_queue_status` (`email_queue_status`),
|
||||
KEY `idx_email_queue_scheduled` (`email_queue_scheduled_at`),
|
||||
KEY `idx_email_queue_priority` (`email_queue_priority`),
|
||||
CONSTRAINT `fk_email_queue_user` FOREIGN KEY (`email_queue_user_id`) REFERENCES `user` (`user_id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `email_templates` (
|
||||
`email_templates_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email_templates_name` varchar(100) NOT NULL,
|
||||
`email_templates_slug` varchar(100) NOT NULL,
|
||||
`email_templates_subject` varchar(255) NOT NULL,
|
||||
`email_templates_body_html` text NOT NULL,
|
||||
`email_templates_body_text` text DEFAULT NULL,
|
||||
`email_templates_variables` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'JSON array of available template variables' CHECK (json_valid(`email_templates_variables`)),
|
||||
`email_templates_is_active` tinyint(1) DEFAULT 1,
|
||||
`email_templates_created_at` datetime DEFAULT current_timestamp(),
|
||||
`email_templates_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`email_templates_id`),
|
||||
UNIQUE KEY `unique_template_slug` (`email_templates_slug`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `gdpr_access_logs` (
|
||||
`gdpr_access_logs_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`gdpr_access_logs_user_id` int(11) DEFAULT NULL,
|
||||
`gdpr_access_logs_action` varchar(100) NOT NULL,
|
||||
`gdpr_access_logs_resource_type` varchar(100) DEFAULT NULL,
|
||||
`gdpr_access_logs_resource_id` int(11) DEFAULT NULL,
|
||||
`gdpr_access_logs_ip_address` varchar(45) DEFAULT NULL,
|
||||
`gdpr_access_logs_user_agent` text DEFAULT NULL,
|
||||
`gdpr_access_logs_metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`gdpr_access_logs_metadata`)),
|
||||
`gdpr_access_logs_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`gdpr_access_logs_id`),
|
||||
KEY `idx_gdpr_access_user` (`gdpr_access_logs_user_id`),
|
||||
KEY `idx_gdpr_access_action` (`gdpr_access_logs_action`),
|
||||
KEY `idx_gdpr_access_created` (`gdpr_access_logs_created_at`),
|
||||
CONSTRAINT `fk_gdpr_access_logs_user` FOREIGN KEY (`gdpr_access_logs_user_id`) REFERENCES `user` (`user_id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `gdpr_consent_records` (
|
||||
`gdpr_consent_records_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`gdpr_consent_records_user_id` int(11) NOT NULL,
|
||||
`gdpr_consent_records_type` enum('cookie_essential','cookie_analytics','cookie_marketing','data_processing','marketing_emails','terms_of_service') NOT NULL,
|
||||
`gdpr_consent_records_granted` tinyint(1) DEFAULT 0,
|
||||
`gdpr_consent_records_ip_address` varchar(45) DEFAULT NULL,
|
||||
`gdpr_consent_records_user_agent` text DEFAULT NULL,
|
||||
`gdpr_consent_records_version` varchar(20) DEFAULT '1.0',
|
||||
`gdpr_consent_records_created_at` datetime DEFAULT current_timestamp(),
|
||||
`gdpr_consent_records_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`gdpr_consent_records_id`),
|
||||
KEY `idx_gdpr_consent_user` (`gdpr_consent_records_user_id`),
|
||||
KEY `idx_gdpr_consent_type` (`gdpr_consent_records_type`),
|
||||
KEY `idx_gdpr_consent_user_type` (`gdpr_consent_records_user_id`,`gdpr_consent_records_type`),
|
||||
CONSTRAINT `fk_gdpr_consent_records_user` FOREIGN KEY (`gdpr_consent_records_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `gdpr_data_export_requests` (
|
||||
`gdpr_data_export_requests_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`gdpr_data_export_requests_user_id` int(11) NOT NULL,
|
||||
`gdpr_data_export_requests_status` enum('pending','processing','completed','failed','expired') DEFAULT 'pending',
|
||||
`gdpr_data_export_requests_format` enum('json') DEFAULT 'json',
|
||||
`gdpr_data_export_requests_file_path` varchar(512) DEFAULT NULL,
|
||||
`gdpr_data_export_requests_file_size` bigint(20) DEFAULT NULL,
|
||||
`gdpr_data_export_requests_expires_at` datetime DEFAULT NULL,
|
||||
`gdpr_data_export_requests_completed_at` datetime DEFAULT NULL,
|
||||
`gdpr_data_export_requests_created_at` datetime DEFAULT current_timestamp(),
|
||||
`gdpr_data_export_requests_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`gdpr_data_export_requests_id`),
|
||||
KEY `idx_gdpr_export_user` (`gdpr_data_export_requests_user_id`),
|
||||
KEY `idx_gdpr_export_status` (`gdpr_data_export_requests_status`),
|
||||
CONSTRAINT `fk_gdpr_data_export_requests_user` FOREIGN KEY (`gdpr_data_export_requests_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `gdpr_deletion_requests` (
|
||||
`gdpr_deletion_requests_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`gdpr_deletion_requests_user_id` int(11) NOT NULL,
|
||||
`gdpr_deletion_requests_status` enum('pending','grace_period','processing','completed','cancelled') DEFAULT 'pending',
|
||||
`gdpr_deletion_requests_reason` text DEFAULT NULL,
|
||||
`gdpr_deletion_requests_grace_until` datetime NOT NULL,
|
||||
`gdpr_deletion_requests_completed_at` datetime DEFAULT NULL,
|
||||
`gdpr_deletion_requests_cancelled_at` datetime DEFAULT NULL,
|
||||
`gdpr_deletion_requests_created_at` datetime DEFAULT current_timestamp(),
|
||||
`gdpr_deletion_requests_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`gdpr_deletion_requests_id`),
|
||||
KEY `idx_gdpr_deletion_user` (`gdpr_deletion_requests_user_id`),
|
||||
KEY `idx_gdpr_deletion_status` (`gdpr_deletion_requests_status`),
|
||||
KEY `idx_gdpr_deletion_grace` (`gdpr_deletion_requests_grace_until`),
|
||||
CONSTRAINT `fk_gdpr_deletion_requests_user` FOREIGN KEY (`gdpr_deletion_requests_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `handoff_messages` (
|
||||
`handoff_messages_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`handoff_messages_handoff_id` int(11) NOT NULL,
|
||||
`handoff_messages_sender_type` enum('user','agent','human') NOT NULL,
|
||||
`handoff_messages_sender_id` int(11) DEFAULT NULL,
|
||||
`handoff_messages_content` text NOT NULL,
|
||||
`handoff_messages_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`handoff_messages_id`),
|
||||
KEY `fk_handoff_messages_handoff` (`handoff_messages_handoff_id`),
|
||||
CONSTRAINT `fk_handoff_messages_handoff` FOREIGN KEY (`handoff_messages_handoff_id`) REFERENCES `handoff_requests` (`handoff_requests_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `handoff_requests` (
|
||||
`handoff_requests_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`handoff_requests_user_id` int(11) NOT NULL,
|
||||
`handoff_requests_agent_template_id` int(11) DEFAULT NULL,
|
||||
`handoff_requests_conversation_id` varchar(100) NOT NULL,
|
||||
`handoff_requests_reason` enum('user_requested','low_confidence','keyword_detected','failed_attempts','sensitive_topic') NOT NULL,
|
||||
`handoff_requests_reason_detail` text DEFAULT NULL,
|
||||
`handoff_requests_conversation_context` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`handoff_requests_conversation_context`)),
|
||||
`handoff_requests_status` enum('pending','assigned','in_progress','resolved','cancelled') DEFAULT 'pending',
|
||||
`handoff_requests_priority` enum('low','normal','high','urgent') DEFAULT 'normal',
|
||||
`handoff_requests_assigned_to` int(11) DEFAULT NULL,
|
||||
`handoff_requests_resolution_note` text DEFAULT NULL,
|
||||
`handoff_requests_created_at` datetime DEFAULT current_timestamp(),
|
||||
`handoff_requests_assigned_at` datetime DEFAULT NULL,
|
||||
`handoff_requests_resolved_at` datetime DEFAULT NULL,
|
||||
`handoff_requests_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`handoff_requests_id`),
|
||||
KEY `fk_handoff_requests_user` (`handoff_requests_user_id`),
|
||||
KEY `fk_handoff_requests_agent_template` (`handoff_requests_agent_template_id`),
|
||||
KEY `fk_handoff_requests_assigned_to` (`handoff_requests_assigned_to`),
|
||||
CONSTRAINT `fk_handoff_requests_agent_template` FOREIGN KEY (`handoff_requests_agent_template_id`) REFERENCES `agent_templates` (`agent_templates_id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_handoff_requests_assigned_to` FOREIGN KEY (`handoff_requests_assigned_to`) REFERENCES `user` (`user_id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_handoff_requests_user` FOREIGN KEY (`handoff_requests_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `handoff_triggers` (
|
||||
`handoff_triggers_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`handoff_triggers_user_id` int(11) NOT NULL,
|
||||
`handoff_triggers_name` varchar(100) NOT NULL,
|
||||
`handoff_triggers_type` enum('keyword','confidence_threshold','failed_attempts','sensitive_topic','user_request') NOT NULL,
|
||||
`handoff_triggers_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`handoff_triggers_config`)),
|
||||
`handoff_triggers_is_active` tinyint(1) DEFAULT 1,
|
||||
`handoff_triggers_created_at` datetime DEFAULT current_timestamp(),
|
||||
`handoff_triggers_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`handoff_triggers_id`),
|
||||
KEY `fk_handoff_triggers_user` (`handoff_triggers_user_id`),
|
||||
CONSTRAINT `fk_handoff_triggers_user` FOREIGN KEY (`handoff_triggers_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `jobs` (
|
||||
`jobs_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`jobs_user_id` int(11) NOT NULL,
|
||||
`jobs_name` varchar(255) NOT NULL,
|
||||
`jobs_base_model` varchar(100) NOT NULL,
|
||||
`jobs_dataset_id` int(11) DEFAULT NULL,
|
||||
`jobs_status` enum('queued','running','completed','failed','cancelled') DEFAULT 'queued',
|
||||
`jobs_progress` int(11) DEFAULT 0,
|
||||
`jobs_epochs` int(11) DEFAULT 3,
|
||||
`jobs_learning_rate` decimal(10,8) DEFAULT 0.00002000,
|
||||
`jobs_batch_size` int(11) DEFAULT 4,
|
||||
`jobs_hyperparameters` longtext DEFAULT NULL,
|
||||
`jobs_result_model_id` int(11) DEFAULT NULL,
|
||||
`jobs_error_message` text DEFAULT NULL,
|
||||
`jobs_started_at` datetime DEFAULT NULL,
|
||||
`jobs_completed_at` datetime DEFAULT NULL,
|
||||
`jobs_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`jobs_id`),
|
||||
KEY `idx_user_id` (`jobs_user_id`),
|
||||
KEY `idx_status` (`jobs_status`),
|
||||
KEY `idx_created_at` (`jobs_created_at`),
|
||||
KEY `fk_jobs_dataset` (`jobs_dataset_id`),
|
||||
KEY `fk_jobs_result_model` (`jobs_result_model_id`),
|
||||
CONSTRAINT `fk_jobs_dataset` FOREIGN KEY (`jobs_dataset_id`) REFERENCES `datasets` (`datasets_id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_jobs_result_model` FOREIGN KEY (`jobs_result_model_id`) REFERENCES `models` (`models_id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_jobs_user` FOREIGN KEY (`jobs_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `knowledge_base_chunks` (
|
||||
`knowledge_base_chunks_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`knowledge_base_chunks_document_id` int(11) NOT NULL,
|
||||
`knowledge_base_chunks_index` int(11) NOT NULL,
|
||||
`knowledge_base_chunks_content` text NOT NULL,
|
||||
`knowledge_base_chunks_token_count` int(11) DEFAULT 0,
|
||||
`knowledge_base_chunks_metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`knowledge_base_chunks_metadata`)),
|
||||
`knowledge_base_chunks_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`knowledge_base_chunks_id`),
|
||||
KEY `idx_kb_chunks_document_id` (`knowledge_base_chunks_document_id`),
|
||||
KEY `idx_kb_chunks_index` (`knowledge_base_chunks_document_id`,`knowledge_base_chunks_index`),
|
||||
CONSTRAINT `fk_kb_chunks_document` FOREIGN KEY (`knowledge_base_chunks_document_id`) REFERENCES `knowledge_base_documents` (`knowledge_base_documents_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `knowledge_base_documents` (
|
||||
`knowledge_base_documents_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`knowledge_base_documents_user_id` int(11) NOT NULL,
|
||||
`knowledge_base_documents_name` varchar(255) NOT NULL,
|
||||
`knowledge_base_documents_original_name` varchar(500) NOT NULL,
|
||||
`knowledge_base_documents_file_path` varchar(500) DEFAULT NULL,
|
||||
`knowledge_base_documents_file_format` enum('pdf','docx','doc','txt','csv','xlsx','md','html') NOT NULL,
|
||||
`knowledge_base_documents_file_size` bigint(20) DEFAULT 0,
|
||||
`knowledge_base_documents_status` enum('uploaded','processing','processed','error') DEFAULT 'uploaded',
|
||||
`knowledge_base_documents_error_message` text DEFAULT NULL,
|
||||
`knowledge_base_documents_extracted_text` longtext DEFAULT NULL,
|
||||
`knowledge_base_documents_chunk_count` int(11) DEFAULT 0,
|
||||
`knowledge_base_documents_metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`knowledge_base_documents_metadata`)),
|
||||
`knowledge_base_documents_created_at` datetime DEFAULT current_timestamp(),
|
||||
`knowledge_base_documents_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`knowledge_base_documents_id`),
|
||||
KEY `idx_kb_documents_user_id` (`knowledge_base_documents_user_id`),
|
||||
KEY `idx_kb_documents_status` (`knowledge_base_documents_status`),
|
||||
CONSTRAINT `fk_kb_documents_user` FOREIGN KEY (`knowledge_base_documents_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `migrations` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`version` int(11) NOT NULL,
|
||||
`filename` varchar(255) NOT NULL,
|
||||
`migrated` tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `model_pulls` (
|
||||
`pull_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL DEFAULT 0,
|
||||
`model_name` varchar(255) NOT NULL,
|
||||
`status` enum('pending','pulling','completed','failed') DEFAULT 'pending',
|
||||
`progress` int(11) DEFAULT 0,
|
||||
`total_size` bigint(20) DEFAULT 0,
|
||||
`downloaded_size` bigint(20) DEFAULT 0,
|
||||
`error_message` text DEFAULT NULL,
|
||||
`started_at` timestamp NULL DEFAULT current_timestamp(),
|
||||
`completed_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`pull_id`),
|
||||
KEY `idx_user_status` (`user_id`,`status`),
|
||||
KEY `idx_model_name` (`model_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `modelfiles` (
|
||||
`modelfiles_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`modelfiles_user_id` int(11) NOT NULL,
|
||||
`modelfiles_name` varchar(255) NOT NULL,
|
||||
`modelfiles_description` text DEFAULT NULL,
|
||||
`modelfiles_content` longtext NOT NULL,
|
||||
`modelfiles_base_model` varchar(255) DEFAULT NULL,
|
||||
`modelfiles_status` enum('draft','active','archived') DEFAULT 'draft',
|
||||
`modelfiles_is_template` tinyint(1) DEFAULT 0,
|
||||
`modelfiles_template_category` varchar(100) DEFAULT NULL,
|
||||
`modelfiles_metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`modelfiles_metadata`)),
|
||||
`modelfiles_created_at` datetime DEFAULT current_timestamp(),
|
||||
`modelfiles_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`modelfiles_id`),
|
||||
KEY `idx_modelfiles_user_id` (`modelfiles_user_id`),
|
||||
KEY `idx_modelfiles_status` (`modelfiles_status`),
|
||||
KEY `idx_modelfiles_is_template` (`modelfiles_is_template`),
|
||||
KEY `idx_modelfiles_base_model` (`modelfiles_base_model`),
|
||||
CONSTRAINT `fk_modelfiles_user` FOREIGN KEY (`modelfiles_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `models` (
|
||||
`models_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`models_user_id` int(11) NOT NULL,
|
||||
`models_job_id` int(11) DEFAULT NULL,
|
||||
`models_name` varchar(255) NOT NULL,
|
||||
`models_base_model` varchar(100) NOT NULL,
|
||||
`models_path` varchar(500) DEFAULT NULL,
|
||||
`models_modelfile_content` text DEFAULT NULL,
|
||||
`models_metrics` longtext DEFAULT NULL,
|
||||
`models_status` enum('training','ready','deployed','archived') DEFAULT 'training',
|
||||
`models_created_at` datetime DEFAULT current_timestamp(),
|
||||
`models_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`models_id`),
|
||||
KEY `idx_user_id` (`models_user_id`),
|
||||
KEY `idx_status` (`models_status`),
|
||||
KEY `fk_models_job` (`models_job_id`),
|
||||
CONSTRAINT `fk_models_job` FOREIGN KEY (`models_job_id`) REFERENCES `jobs` (`jobs_id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_models_user` FOREIGN KEY (`models_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `test_sessions` (
|
||||
`session_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`model_id` int(11) NOT NULL,
|
||||
`model_name` varchar(255) NOT NULL,
|
||||
`container_name` varchar(255) DEFAULT NULL,
|
||||
`container_port` int(11) DEFAULT NULL,
|
||||
`status` varchar(20) NOT NULL DEFAULT 'active',
|
||||
`timeout_seconds` int(11) NOT NULL DEFAULT 1800,
|
||||
`memory_limit` varchar(10) NOT NULL DEFAULT '8g',
|
||||
`cpu_limit` int(11) NOT NULL DEFAULT 4,
|
||||
`started_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`expires_at` datetime NOT NULL,
|
||||
`stopped_at` datetime DEFAULT NULL,
|
||||
`message_count` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`session_id`),
|
||||
KEY `fk_test_sessions_model` (`model_id`),
|
||||
KEY `idx_test_sessions_user_status` (`user_id`,`status`),
|
||||
KEY `idx_test_sessions_expires` (`expires_at`),
|
||||
KEY `idx_test_sessions_status` (`status`),
|
||||
CONSTRAINT `fk_test_sessions_model` FOREIGN KEY (`model_id`) REFERENCES `models` (`models_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_test_sessions_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `timeanddate` (
|
||||
`timeanddate_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`timeanddate_date` date NOT NULL DEFAULT current_timestamp(),
|
||||
`timeanddate_time` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`timeanddate_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `timeanddate_to_account` (
|
||||
`account_id` int(11) DEFAULT NULL,
|
||||
`timeanddate_id` int(11) DEFAULT NULL,
|
||||
KEY `account_to_timeanddate_account_account_id_fk` (`account_id`),
|
||||
KEY `account_to_timeanddate_timeanddate_timeanddate_id_fk` (`timeanddate_id`),
|
||||
CONSTRAINT `account_to_timeanddate_account_account_id_fk` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`),
|
||||
CONSTRAINT `account_to_timeanddate_timeanddate_timeanddate_id_fk` FOREIGN KEY (`timeanddate_id`) REFERENCES `timeanddate` (`timeanddate_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `timeanddate_to_user` (
|
||||
`timeanddate_id` int(11) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
KEY `timeanddate_to_user_timeanddate_timeanddate_id_fk` (`timeanddate_id`),
|
||||
KEY `timeanddate_to_user_user_user_id_fk` (`user_id`),
|
||||
CONSTRAINT `timeanddate_to_user_timeanddate_timeanddate_id_fk` FOREIGN KEY (`timeanddate_id`) REFERENCES `timeanddate` (`timeanddate_id`),
|
||||
CONSTRAINT `timeanddate_to_user_user_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `usage_logs` (
|
||||
`usage_logs_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`usage_logs_user_id` int(11) NOT NULL,
|
||||
`usage_logs_resource_type` enum('api_call','training','inference','storage') NOT NULL,
|
||||
`usage_logs_resource_id` int(11) DEFAULT NULL,
|
||||
`usage_logs_credits_used` decimal(10,4) DEFAULT 0.0000,
|
||||
`usage_logs_details` longtext DEFAULT NULL,
|
||||
`usage_logs_created_at` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`usage_logs_id`),
|
||||
KEY `idx_user_id` (`usage_logs_user_id`),
|
||||
KEY `idx_created_at` (`usage_logs_created_at`),
|
||||
KEY `idx_resource_type` (`usage_logs_resource_type`),
|
||||
CONSTRAINT `fk_usage_logs_user` FOREIGN KEY (`usage_logs_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user` (
|
||||
`user_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_firstname` varchar(255) DEFAULT NULL,
|
||||
`user_lastname` varchar(255) DEFAULT NULL,
|
||||
`user_email` varchar(255) DEFAULT NULL,
|
||||
`user_name` varchar(255) DEFAULT NULL,
|
||||
`user_pass` varbinary(50) DEFAULT NULL,
|
||||
`user_password_hash` varchar(255) DEFAULT NULL,
|
||||
`user_login` varchar(255) DEFAULT NULL,
|
||||
`user_account_active` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`user_created` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
UNIQUE KEY `user_pk` (`user_login`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_billing` (
|
||||
`user_billing_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_billing_user_id` int(11) NOT NULL,
|
||||
`user_billing_plan_type` enum('free','starter','professional','enterprise') DEFAULT 'free',
|
||||
`user_billing_credits_balance` decimal(12,4) DEFAULT 0.0000,
|
||||
`user_billing_credits_used_month` decimal(12,4) DEFAULT 0.0000,
|
||||
`user_billing_cycle_start` date DEFAULT NULL,
|
||||
`user_billing_cycle_end` date DEFAULT NULL,
|
||||
`user_billing_stripe_customer_id` varchar(100) DEFAULT NULL,
|
||||
`user_billing_paypal_customer_id` varchar(100) DEFAULT NULL,
|
||||
`user_billing_created_at` datetime DEFAULT current_timestamp(),
|
||||
`user_billing_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`user_billing_id`),
|
||||
UNIQUE KEY `user_id` (`user_billing_user_id`),
|
||||
CONSTRAINT `fk_user_billing_user` FOREIGN KEY (`user_billing_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_settings` (
|
||||
`user_settings_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_settings_user_id` int(11) NOT NULL,
|
||||
`user_settings_key` varchar(100) NOT NULL,
|
||||
`user_settings_value` text DEFAULT NULL,
|
||||
`user_settings_created_at` datetime DEFAULT current_timestamp(),
|
||||
`user_settings_updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`user_settings_id`),
|
||||
UNIQUE KEY `unique_user_setting` (`user_settings_user_id`,`user_settings_key`),
|
||||
CONSTRAINT `fk_user_settings_user` FOREIGN KEY (`user_settings_user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_to_account` (
|
||||
`account_id` int(11) DEFAULT NULL,
|
||||
`user_id` int(11) DEFAULT NULL,
|
||||
KEY `user_to_account_account_account_id_fk` (`account_id`),
|
||||
KEY `user_to_account_user_user_id_fk` (`user_id`),
|
||||
CONSTRAINT `user_to_account_account_account_id_fk` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`),
|
||||
CONSTRAINT `user_to_account_user_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_to_acl` (
|
||||
`user_id` int(11) NOT NULL,
|
||||
`acl_id` int(11) NOT NULL,
|
||||
KEY `user_to_acl_user_user_id_fk` (`user_id`),
|
||||
KEY `user_to_acl_acl_acl_id_fk` (`acl_id`),
|
||||
CONSTRAINT `user_to_acl_acl_acl_id_fk` FOREIGN KEY (`acl_id`) REFERENCES `acl` (`acl_id`),
|
||||
CONSTRAINT `user_to_acl_user_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!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 */;
|
||||
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
|
||||
|
||||
56
db/02-seed.sql
Normal file
56
db/02-seed.sql
Normal file
@@ -0,0 +1,56 @@
|
||||
/*M!999999\- enable the sandbox mode */
|
||||
|
||||
/*!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 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
|
||||
|
||||
SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0;
|
||||
LOCK TABLES `acl` WRITE;
|
||||
/*!40000 ALTER TABLE `acl` DISABLE KEYS */;
|
||||
INSERT INTO `acl` (`acl_id`, `acl_role`) VALUES (1,'superuser'),
|
||||
(2,'moderator'),
|
||||
(3,'user');
|
||||
/*!40000 ALTER TABLE `acl` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
COMMIT;
|
||||
SET AUTOCOMMIT=@OLD_AUTOCOMMIT;
|
||||
|
||||
SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0;
|
||||
LOCK TABLES `email_templates` WRITE;
|
||||
/*!40000 ALTER TABLE `email_templates` DISABLE KEYS */;
|
||||
INSERT INTO `email_templates` (`email_templates_id`, `email_templates_name`, `email_templates_slug`, `email_templates_subject`, `email_templates_body_html`, `email_templates_body_text`, `email_templates_variables`, `email_templates_is_active`, `email_templates_created_at`, `email_templates_updated_at`) VALUES (1,'Welcome Email','welcome','Welcome to Neuronetz Finetuning Platform','<h1>Welcome, {{user_name}}!</h1><p>Thank you for joining the Neuronetz Finetuning Platform. You can now start creating fine-tuning jobs, uploading datasets, and deploying models.</p><p>Get started at <a href=\"{{platform_url}}/dashboard\">your dashboard</a>.</p>','Welcome, {{user_name}}! Thank you for joining the Neuronetz Finetuning Platform.','[\"user_name\", \"user_email\", \"platform_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(2,'Email Verification','email-verification','Verify your email address','<h1>Email Verification</h1><p>Hi {{user_name}},</p><p>Please verify your email address by clicking the link below:</p><p><a href=\"{{verification_url}}\">Verify Email</a></p><p>This link expires in 24 hours.</p>','Hi {{user_name}}, please verify your email: {{verification_url}}','[\"user_name\", \"verification_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(3,'Password Reset','password-reset','Reset your password','<h1>Password Reset</h1><p>Hi {{user_name}},</p><p>We received a request to reset your password. Click the link below to set a new password:</p><p><a href=\"{{reset_url}}\">Reset Password</a></p><p>This link expires in 1 hour. If you did not request this, you can ignore this email.</p>','Hi {{user_name}}, reset your password here: {{reset_url}}','[\"user_name\", \"reset_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(4,'Job Started','job-started','Your fine-tuning job has started','<h1>Job Started</h1><p>Hi {{user_name}},</p><p>Your fine-tuning job <strong>{{job_name}}</strong> has started processing.</p><p>Base model: {{base_model}}<br>Epochs: {{epochs}}</p><p><a href=\"{{platform_url}}/jobs\">View progress</a></p>','Hi {{user_name}}, your job \"{{job_name}}\" has started.','[\"user_name\", \"job_name\", \"base_model\", \"epochs\", \"platform_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(5,'Job Completed','job-completed','Your fine-tuning job completed successfully','<h1>Job Completed!</h1><p>Hi {{user_name}},</p><p>Your fine-tuning job <strong>{{job_name}}</strong> has completed successfully.</p><p><a href=\"{{platform_url}}/jobs\">View results</a></p>','Hi {{user_name}}, your job \"{{job_name}}\" completed successfully.','[\"user_name\", \"job_name\", \"platform_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(6,'Job Failed','job-failed','Your fine-tuning job failed','<h1>Job Failed</h1><p>Hi {{user_name}},</p><p>Unfortunately, your fine-tuning job <strong>{{job_name}}</strong> has failed.</p><p>Error: {{error_message}}</p><p><a href=\"{{platform_url}}/jobs\">View details</a></p>','Hi {{user_name}}, your job \"{{job_name}}\" failed: {{error_message}}','[\"user_name\", \"job_name\", \"error_message\", \"platform_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(7,'Low Credits Alert','low-credits','Low credits warning','<h1>Low Credits</h1><p>Hi {{user_name}},</p><p>Your account credits are running low. You have <strong>{{credits_remaining}}</strong> credits remaining.</p><p><a href=\"{{platform_url}}/usage\">View usage</a> | <a href=\"{{platform_url}}/pricing\">Upgrade plan</a></p>','Hi {{user_name}}, you have {{credits_remaining}} credits remaining.','[\"user_name\", \"credits_remaining\", \"platform_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53'),
|
||||
(8,'Security Alert','security-alert','Security alert for your account','<h1>Security Alert</h1><p>Hi {{user_name}},</p><p>{{alert_message}}</p><p>If this was not you, please change your password immediately.</p><p><a href=\"{{platform_url}}/settings\">Account settings</a></p>','Hi {{user_name}}, security alert: {{alert_message}}','[\"user_name\", \"alert_message\", \"platform_url\"]',1,'2026-02-21 11:29:53','2026-02-21 11:29:53');
|
||||
/*!40000 ALTER TABLE `email_templates` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
COMMIT;
|
||||
SET AUTOCOMMIT=@OLD_AUTOCOMMIT;
|
||||
|
||||
SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0;
|
||||
LOCK TABLES `api_registry` WRITE;
|
||||
/*!40000 ALTER TABLE `api_registry` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `api_registry` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
COMMIT;
|
||||
SET AUTOCOMMIT=@OLD_AUTOCOMMIT;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!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 */;
|
||||
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
|
||||
|
||||
25
db/03-default-users.sql
Normal file
25
db/03-default-users.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- Default users for a fresh local install.
|
||||
-- Run AFTER 01-schema.sql and 02-seed.sql.
|
||||
--
|
||||
-- Credentials:
|
||||
-- admin@finetune.ai / admin123 (id=1, role=superuser via user_to_acl)
|
||||
-- testuser@example.com / test123 (id=2, role=user)
|
||||
--
|
||||
-- Hashes below are argon2id (PHP password_hash, PASSWORD_ARGON2ID).
|
||||
-- Regenerate with: docker compose exec fpm php -r "echo password_hash('YOUR_PASS', PASSWORD_ARGON2ID);"
|
||||
-- IMPORTANT: change these passwords on any deployment that's not strictly local dev.
|
||||
|
||||
INSERT INTO `user`
|
||||
(`user_id`, `user_login`, `user_email`, `user_name`, `user_password_hash`, `user_account_active`)
|
||||
VALUES
|
||||
(1, 'admin@finetune.ai', 'admin@finetune.ai', 'Admin',
|
||||
'$argon2id$v=19$m=65536,t=4,p=1$eXRQVHBNaFFLTmZYZC9pSQ$0iMhgsJVOo1D4U8XNrcDFdkIUCJEf2yY1Tmf8G9zKM0',
|
||||
1),
|
||||
(2, 'testuser@example.com', 'testuser@example.com', 'Test User',
|
||||
'$argon2id$v=19$m=65536,t=4,p=1$YmxWaHpqaHRsU1dmZHFUOA$k8veR56hGcoTsciZGVYv/NuPJSyQ3wgzSTyryW/ynto',
|
||||
1);
|
||||
|
||||
-- Grant admin user superuser ACL (acl_id=1 from the acl seed data)
|
||||
INSERT INTO `user_to_acl` (`user_to_acl_user_id`, `user_to_acl_acl_id`) VALUES
|
||||
(1, 1), -- admin → superuser
|
||||
(2, 3); -- testuser → user
|
||||
Reference in New Issue
Block a user