CREATE TABLE `stacktasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `notes` text DEFAULT NULL,
  `sorting` int(11) NOT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `done` tinyint(4) NOT NULL DEFAULT 0,
  `done_at` datetime DEFAULT NULL,
  `archived` tinyint(4) NOT NULL DEFAULT 0,
  `as_template` tinyint(4) NOT NULL DEFAULT 0,
  `due_date` datetime DEFAULT NULL,
  `estimation_minutes` int(10) unsigned DEFAULT NULL,
  `deleted` tinyint(1) NOT NULL DEFAULT 0,
  `workspace_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_deleted` (`deleted`),
  KEY `fk_stacktasks_workspace` (`workspace_id`),
  CONSTRAINT `fk_stacktasks_workspace` FOREIGN KEY (`workspace_id`) REFERENCES `workspaces` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
