-- --------------------------------------------------------
-- Server OS:                    Win64
-- HeidiSQL Version:             12.5.0.6677
-- --------------------------------------------------------


-- Dumping structure for table piezimu_bloks.categories
CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `categories_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table piezimu_bloks.categories: ~2 rows (approximately)
INSERT IGNORE INTO `categories` (`id`, `user_id`, `name`) VALUES
	(1, 1, 'Elvis'),
	(2, 2, 'Sentis'),
	(3, 1, 'nigga');

-- Dumping structure for table piezimu_bloks.tasks
CREATE TABLE IF NOT EXISTS `tasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','deleted') DEFAULT 'active',
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `category_id` (`category_id`),
  CONSTRAINT `tasks_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `tasks_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table piezimu_bloks.tasks: ~4 rows (approximately)
INSERT IGNORE INTO `tasks` (`id`, `user_id`, `category_id`, `title`, `description`, `status`, `created_at`, `updated_at`) VALUES
	(1, 1, 1, 'sasit elvi', 'jo vins neko nedara', 'deleted', '2025-06-06 20:31:50', '2025-06-06 20:32:02'),
	(2, 2, 2, 'Sentim palidzet', 'negribu', 'active', '2025-06-06 20:33:13', '2025-06-06 20:33:13'),
	(3, 1, 1, 'elvis', 'stulbais', 'active', '2025-06-06 20:34:10', '2025-06-06 20:34:10'),
	(4, 1, 3, 'danik', 'cornij', 'active', '2025-06-06 20:38:17', '2025-06-06 20:38:17');

-- Dumping structure for table piezimu_bloks.task_files
CREATE TABLE IF NOT EXISTS `task_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `task_id` int(11) NOT NULL,
  `filename` varchar(255) NOT NULL,
  `filepath` varchar(255) NOT NULL,
  `uploaded_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `task_id` (`task_id`),
  CONSTRAINT `task_files_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table piezimu_bloks.task_files: ~0 rows (approximately)

-- Dumping structure for table piezimu_bloks.task_history
CREATE TABLE IF NOT EXISTS `task_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `task_id` int(11) NOT NULL,
  `changed_by` int(11) NOT NULL,
  `change_type` varchar(50) NOT NULL,
  `old_value` text DEFAULT NULL,
  `new_value` text DEFAULT NULL,
  `changed_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `task_id` (`task_id`),
  KEY `changed_by` (`changed_by`),
  CONSTRAINT `task_history_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  CONSTRAINT `task_history_ibfk_2` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table piezimu_bloks.task_history: ~0 rows (approximately)
INSERT IGNORE INTO `task_history` (`id`, `task_id`, `changed_by`, `change_type`, `old_value`, `new_value`, `changed_at`) VALUES
	(1, 1, 1, 'delete', '{"id":1,"user_id":1,"category_id":1,"title":"sasit elvi","description":"jo vins neko nedara","status":"active","created_at":"2025-06-06T17:31:50.000Z","updated_at":"2025-06-06T17:31:50.000Z"}', NULL, '2025-06-06 20:32:02');

-- Dumping structure for table piezimu_bloks.task_shares
CREATE TABLE IF NOT EXISTS `task_shares` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `task_id` int(11) NOT NULL,
  `shared_with_user_id` int(11) NOT NULL,
  `shared_by_user_id` int(11) NOT NULL,
  `shared_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `task_id` (`task_id`),
  KEY `shared_with_user_id` (`shared_with_user_id`),
  KEY `shared_by_user_id` (`shared_by_user_id`),
  CONSTRAINT `task_shares_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  CONSTRAINT `task_shares_ibfk_2` FOREIGN KEY (`shared_with_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `task_shares_ibfk_3` FOREIGN KEY (`shared_by_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table piezimu_bloks.task_shares: ~2 rows (approximately)
INSERT IGNORE INTO `task_shares` (`id`, `task_id`, `shared_with_user_id`, `shared_by_user_id`, `shared_at`) VALUES
	(1, 3, 2, 1, '2025-06-06 20:34:22'),
	(2, 2, 1, 2, '2025-06-06 20:36:07'),
	(3, 4, 2, 1, '2025-06-06 20:38:28');

