-- TaskBoard Schema Dump
-- Host: 192.168.1.9:3306
-- Database: taskboard
-- Date: 25.02.2026 17:21:02

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for accounts
-- ----------------------------
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_department` int DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `username` varchar(255) DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `avatar_url` varchar(255) DEFAULT NULL,
  `telegram` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for accounts_session
-- ----------------------------
DROP TABLE IF EXISTS `accounts_session`;
CREATE TABLE `accounts_session` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_accounts` varchar(255) DEFAULT NULL,
  `keycookies` varchar(255) DEFAULT NULL,
  `data_create` datetime DEFAULT NULL,
  `data_closed` datetime DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `user_agent` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for cards_task
-- ----------------------------
DROP TABLE IF EXISTS `cards_task`;
CREATE TABLE `cards_task` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_department` int DEFAULT NULL,
  `id_label` int DEFAULT NULL,
  `id_account` int DEFAULT NULL,
  `order` int DEFAULT NULL,
  `column_id` int DEFAULT NULL,
  `archive` tinyint DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  `date_create` datetime DEFAULT NULL,
  `date_closed` datetime DEFAULT NULL,
  `file_img` json DEFAULT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `descript` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `descript_full` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
  `id_project` int DEFAULT NULL,
  `create_id_account` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for columns
-- ----------------------------
DROP TABLE IF EXISTS `columns`;
CREATE TABLE `columns` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name_columns` varchar(255) DEFAULT NULL,
  `color` varchar(7) DEFAULT NULL,
  `id_project` int DEFAULT NULL,
  `id_order` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for comments
-- ----------------------------
DROP TABLE IF EXISTS `comments`;
CREATE TABLE `comments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_task` int DEFAULT NULL,
  `id_accounts` int DEFAULT NULL,
  `id_answer` int DEFAULT NULL,
  `text` text,
  `date_create` datetime DEFAULT NULL,
  `file_img` json DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for departments
-- ----------------------------
DROP TABLE IF EXISTS `departments`;
CREATE TABLE `departments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name_departments` varchar(255) DEFAULT NULL,
  `color` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `id_project` int DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for labels
-- ----------------------------
DROP TABLE IF EXISTS `labels`;
CREATE TABLE `labels` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name_labels` varchar(255) DEFAULT NULL,
  `icon` varchar(10) DEFAULT NULL,
  `color` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for project
-- ----------------------------
DROP TABLE IF EXISTS `project`;
CREATE TABLE `project` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_order` int DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `id_ready` int DEFAULT NULL,
  `id_admin` json DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for project_invites
-- ----------------------------
DROP TABLE IF EXISTS `project_invites`;
CREATE TABLE `project_invites` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_project` int NOT NULL,
  `id_from_user` int NOT NULL,
  `id_to_user` int NOT NULL,
  `status` enum('pending','accepted','declined') DEFAULT 'pending',
  `permissions` json DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `responded_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_to_user` (`id_to_user`,`status`),
  KEY `idx_project` (`id_project`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for project_members
-- ----------------------------
DROP TABLE IF EXISTS `project_members`;
CREATE TABLE `project_members` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_project` int NOT NULL,
  `id_user` int NOT NULL,
  `is_admin` tinyint(1) DEFAULT '0',
  `permissions` json DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_member` (`id_project`,`id_user`),
  KEY `idx_project` (`id_project`),
  KEY `idx_user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

SET FOREIGN_KEY_CHECKS = 1;
