-- MySQL dump 10.13  Distrib 8.0.45, for Linux (x86_64)
--
-- Host: localhost    Database: playpay
-- ------------------------------------------------------
-- Server version	8.0.45-0ubuntu0.24.04.1

/*!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 */;
/*!50503 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' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `chat_threads`
--

DROP TABLE IF EXISTS `chat_threads`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `chat_threads` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `buyer_id` bigint unsigned NOT NULL,
  `seller_id` bigint unsigned NOT NULL,
  `marketplace_listing_id` bigint unsigned DEFAULT NULL,
  `subject` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_message_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `chat_threads_buyer_id_created_at_index` (`buyer_id`,`created_at`),
  KEY `chat_threads_seller_id_created_at_index` (`seller_id`,`created_at`),
  KEY `chat_threads_marketplace_listing_id_buyer_id_index` (`marketplace_listing_id`,`buyer_id`),
  CONSTRAINT `chat_threads_buyer_id_foreign` FOREIGN KEY (`buyer_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chat_threads_marketplace_listing_id_foreign` FOREIGN KEY (`marketplace_listing_id`) REFERENCES `marketplace_listings` (`id`) ON DELETE SET NULL,
  CONSTRAINT `chat_threads_seller_id_foreign` FOREIGN KEY (`seller_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `chat_threads`
--

LOCK TABLES `chat_threads` WRITE;
/*!40000 ALTER TABLE `chat_threads` DISABLE KEYS */;
INSERT INTO `chat_threads` VALUES (1,12,2,1,'Вопрос по объявлению: фортнайт','2026-05-17 06:26:41','2026-05-14 04:04:36','2026-05-17 06:26:41'),(2,3,2,1,'Вопрос по объявлению: фортнайт','2026-05-17 02:54:03','2026-05-16 16:46:33','2026-05-17 02:54:03'),(3,5,2,1,'фортнайт','2026-05-18 00:04:35','2026-05-17 02:20:25','2026-05-18 00:04:35'),(4,2,5,NULL,'Диалог: snanelx и Saniak0','2026-05-17 23:07:02','2026-05-17 23:07:02','2026-05-17 23:07:02');
/*!40000 ALTER TABLE `chat_threads` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `chat_messages`
--

DROP TABLE IF EXISTS `chat_messages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `chat_messages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `thread_id` bigint unsigned NOT NULL,
  `sender_id` bigint unsigned NOT NULL,
  `body` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_read` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `chat_messages_sender_id_foreign` (`sender_id`),
  KEY `chat_messages_thread_id_created_at_index` (`thread_id`,`created_at`),
  CONSTRAINT `chat_messages_sender_id_foreign` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chat_messages_thread_id_foreign` FOREIGN KEY (`thread_id`) REFERENCES `chat_threads` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `chat_messages`
--

LOCK TABLES `chat_messages` WRITE;
/*!40000 ALTER TABLE `chat_messages` DISABLE KEYS */;
INSERT INTO `chat_messages` VALUES (1,1,12,'Здравствуйте! Есть вопрос по объявлению: фортнайт',1,'2026-05-14 04:04:36','2026-05-14 04:05:00'),(2,1,2,'чо такое',0,'2026-05-14 04:05:05','2026-05-14 04:05:05'),(3,2,3,'Здравствуйте! Есть вопрос по объявлению: фортнайт',1,'2026-05-16 16:46:33','2026-05-17 00:35:57'),(4,2,2,'гуляй',1,'2026-05-17 00:36:02','2026-05-17 02:32:15'),(5,2,2,'вацок',1,'2026-05-17 00:36:04','2026-05-17 02:32:15'),(6,3,5,'Здравствуйте! Есть вопрос по объявлению: фортнайт',1,'2026-05-17 02:20:25','2026-05-17 02:20:32'),(7,3,2,'пук',1,'2026-05-17 02:20:35','2026-05-17 02:20:44'),(8,3,5,'привет',1,'2026-05-17 02:21:19','2026-05-17 02:25:59'),(9,3,2,'привит',1,'2026-05-17 02:26:07','2026-05-17 02:54:21'),(10,3,2,'пук',1,'2026-05-17 02:26:13','2026-05-17 02:54:21'),(11,3,2,'как дила',1,'2026-05-17 02:31:42','2026-05-17 02:54:21'),(12,2,2,'как дела',1,'2026-05-17 02:32:30','2026-05-17 02:32:30'),(13,2,3,'Привет',1,'2026-05-17 02:33:46','2026-05-17 02:39:19'),(14,2,2,'че делаешь',1,'2026-05-17 02:39:23','2026-05-17 02:40:29'),(15,2,3,'Спатки надо',1,'2026-05-17 02:40:47','2026-05-17 02:43:43'),(16,2,3,'Сегодня с Матвеем и Артуриком в субнаутику сыграли',1,'2026-05-17 02:41:41','2026-05-17 02:43:43'),(17,2,2,'о имба я видел',1,'2026-05-17 02:43:50','2026-05-17 02:44:51'),(18,2,3,'Я кста сегодня Винду переустановил',1,'2026-05-17 02:45:27','2026-05-17 02:53:56'),(19,2,3,'У меня синий экран вылез и в инете решения не было',1,'2026-05-17 02:45:50','2026-05-17 02:53:56'),(20,2,2,'хахаха жеесть',1,'2026-05-17 02:54:03','2026-05-17 03:02:38'),(21,3,5,'пока не родила',1,'2026-05-17 02:54:29','2026-05-17 02:54:32'),(22,3,2,'ты совсем',1,'2026-05-17 02:54:36','2026-05-17 02:54:36'),(23,3,5,'нит',1,'2026-05-17 02:54:40','2026-05-17 02:54:41'),(24,3,2,'дыт',1,'2026-05-17 06:23:22','2026-05-18 00:04:36'),(25,1,2,'пукан',0,'2026-05-17 06:26:40','2026-05-17 06:26:40'),(26,4,2,'Здравствуйте! Хотел(а) уточнить детали сотрудничества.',1,'2026-05-17 23:07:02','2026-05-18 00:04:42'),(27,3,5,'пись',1,'2026-05-18 00:04:35','2026-05-18 02:02:32');
/*!40000 ALTER TABLE `chat_messages` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `chat_message_reports`
--

DROP TABLE IF EXISTS `chat_message_reports`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `chat_message_reports` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `chat_message_id` bigint unsigned NOT NULL,
  `chat_thread_id` bigint unsigned NOT NULL,
  `reporter_id` bigint unsigned NOT NULL,
  `reported_user_id` bigint unsigned NOT NULL,
  `reason` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `admin_note` text COLLATE utf8mb4_unicode_ci,
  `resolved_by` bigint unsigned DEFAULT NULL,
  `resolved_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `chat_message_reports_chat_message_id_foreign` (`chat_message_id`),
  KEY `chat_message_reports_chat_thread_id_foreign` (`chat_thread_id`),
  KEY `chat_message_reports_reported_user_id_foreign` (`reported_user_id`),
  KEY `chat_message_reports_resolved_by_foreign` (`resolved_by`),
  KEY `chat_message_reports_status_created_at_index` (`status`,`created_at`),
  KEY `chat_message_reports_reporter_id_chat_message_id_index` (`reporter_id`,`chat_message_id`),
  CONSTRAINT `chat_message_reports_chat_message_id_foreign` FOREIGN KEY (`chat_message_id`) REFERENCES `chat_messages` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chat_message_reports_chat_thread_id_foreign` FOREIGN KEY (`chat_thread_id`) REFERENCES `chat_threads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chat_message_reports_reported_user_id_foreign` FOREIGN KEY (`reported_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chat_message_reports_reporter_id_foreign` FOREIGN KEY (`reporter_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `chat_message_reports_resolved_by_foreign` FOREIGN KEY (`resolved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `chat_message_reports`
--

LOCK TABLES `chat_message_reports` WRITE;
/*!40000 ALTER TABLE `chat_message_reports` DISABLE KEYS */;
/*!40000 ALTER TABLE `chat_message_reports` ENABLE KEYS */;
UNLOCK TABLES;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-05-18  0:11:10
