-- https://www.phpmyadmin.net/
--
-- إصدار الخادم: 10.4.28-MariaDB

START TRANSACTION;



--
-- Database: `asana_clone`
--

-- --------------------------------------------------------

--
-- بنية الجدول `activities`
--

CREATE TABLE `activities` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `company_id` bigint(20) UNSIGNED NOT NULL,
  `subject_type` varchar(255) NOT NULL,
  `subject_id` bigint(20) UNSIGNED NOT NULL,
  `causer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `description` varchar(255) NOT NULL,
  `action` varchar(255) NOT NULL,
  `properties` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`properties`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `activities`
--

INSERT INTO `activities` (`id`, `company_id`, `subject_type`, `subject_id`, `causer_id`, `description`, `action`, `properties`, `created_at`, `updated_at`) VALUES
(1, 1, 'App\\Models\\Project', 1, 2, 'created project \"Website Redesign\"', 'created', NULL, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 1, 'App\\Models\\Task', 1, 4, 'changed task status to \"Completed\"', 'status_changed', NULL, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(3, 1, 'App\\Models\\Task', 4, 4, 'started working on \"Implement navigation header\"', 'status_changed', NULL, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(4, 1, 'App\\Models\\Task', 11, 2, 'created task \"Fix header dropdown bug\"', 'created', NULL, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(5, 1, 'App\\Models\\Project', 3, 5, 'created project \"Brand Identity Update\"', 'created', NULL, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(6, 1, 'App\\Models\\Task', 6, 1, 'completed task \"Create about page\"', 'completed', NULL, '2026-03-08 23:35:35', '2026-03-08 23:35:35'),
(7, 1, 'App\\Models\\Task', 6, 1, 'changed status from \"todo\" to \"completed\"', 'status_changed', '{\"old_status\":\"todo\",\"new_status\":\"completed\"}', '2026-03-08 23:35:35', '2026-03-08 23:35:35'),
(8, 1, 'App\\Models\\Task', 15, 1, 'created task \"فثسف\"', 'created', NULL, '2026-03-08 23:47:45', '2026-03-08 23:47:45'),
(9, 1, 'App\\Models\\Task', 8, 3, 'commented on task \"Add responsive design\"', 'commented', NULL, '2026-03-09 14:57:23', '2026-03-09 14:57:23'),
(10, 1, 'App\\Models\\Task', 15, 1, 'commented on task \"فثسف\"', 'commented', NULL, '2026-03-11 06:31:00', '2026-03-11 06:31:00'),
(11, 1, 'App\\Models\\Task', 16, 1, 'created task \"ahmed\"', 'created', NULL, '2026-03-11 06:35:35', '2026-03-11 06:35:35'),
(12, 1, 'App\\Models\\Task', 8, 1, 'moved task \"Add responsive design\" to in_progress', 'status_changed', '{\"old_status\":\"todo\",\"new_status\":\"in_progress\"}', '2026-03-11 06:48:59', '2026-03-11 06:48:59'),
(13, 1, 'App\\Models\\Task', 8, 1, 'moved task \"Add responsive design\" to todo', 'status_changed', '{\"old_status\":\"in_progress\",\"new_status\":\"todo\"}', '2026-03-11 06:49:10', '2026-03-11 06:49:10'),
(14, 1, 'App\\Models\\Task', 15, 1, 'completed task \"فثسف\"', 'completed', NULL, '2026-03-18 15:06:08', '2026-03-18 15:06:08'),
(15, 1, 'App\\Models\\Task', 15, 1, 'reopened task \"فثسف\"', 'status_changed', NULL, '2026-03-18 15:06:10', '2026-03-18 15:06:10'),
(16, 1, 'App\\Models\\Task', 15, 1, 'updated subtask \"فثسف\"', 'updated', NULL, '2026-03-18 15:06:30', '2026-03-18 15:06:30'),
(17, 1, 'App\\Models\\Task', 17, 1, 'created task \"test1\"', 'created', NULL, '2026-03-24 18:28:58', '2026-03-24 18:28:58'),
(18, 1, 'App\\Models\\Task', 15, 1, 'changed status from \"todo\" to \"in_progress\"', 'status_changed', '{\"old_status\":\"todo\",\"new_status\":\"in_progress\"}', '2026-03-24 18:29:25', '2026-03-24 18:29:25'),
(19, 1, 'App\\Models\\Task', 1, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(20, 1, 'App\\Models\\Task', 2, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(21, 1, 'App\\Models\\Task', 3, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(22, 1, 'App\\Models\\Task', 4, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(23, 1, 'App\\Models\\Task', 5, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(24, 1, 'App\\Models\\Task', 6, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(25, 1, 'App\\Models\\Task', 7, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(26, 1, 'App\\Models\\Task', 8, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(27, 1, 'App\\Models\\Task', 9, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(28, 1, 'App\\Models\\Task', 10, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(29, 1, 'App\\Models\\Task', 11, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(30, 1, 'App\\Models\\Task', 12, 1, 'bulk changed status to \"in_progress\"', 'status_changed', NULL, '2026-03-26 01:33:53', '2026-03-26 01:33:53'),
(31, 1, 'App\\Models\\Task', 1, 1, 'added dependency on \"Build hero section\"', 'updated', NULL, '2026-03-26 01:34:42', '2026-03-26 01:34:42'),
(32, 1, 'App\\Models\\Task', 1, 1, 'removed dependency on \"Build hero section\"', 'updated', NULL, '2026-03-26 01:35:00', '2026-03-26 01:35:00'),
(33, 1, 'App\\Models\\Task', 1, 1, 'added dependency on \"Create about page\"', 'updated', NULL, '2026-03-26 01:35:13', '2026-03-26 01:35:13'),
(34, 1, 'App\\Models\\Task', 18, 1, 'created task \"Design UI\"', 'created', NULL, '2026-03-26 01:51:48', '2026-03-26 01:51:48');

-- --------------------------------------------------------

--
-- بنية الجدول `attachments`
--

CREATE TABLE `attachments` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `task_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `filename` varchar(255) NOT NULL,
  `original_filename` varchar(255) NOT NULL,
  `path` varchar(255) NOT NULL,
  `mime_type` varchar(255) DEFAULT NULL,
  `size` bigint(20) UNSIGNED DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `comments`
--

CREATE TABLE `comments` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `task_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `body` text NOT NULL,
  `mentions` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`mentions`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `companies`
--

CREATE TABLE `companies` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `slug` varchar(255) NOT NULL,
  `logo` varchar(255) DEFAULT NULL,
  `subscription_plan` varchar(255) DEFAULT 'free',
  `description` text DEFAULT NULL,
  `website` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `companies`
--

INSERT INTO `companies` (`id`, `name`, `slug`, `logo`, `subscription_plan`, `description`, `website`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Acme Corporation', 'acme-corporation', NULL, 'enterprise', 'Leading technology and innovation company', NULL, 1, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 'Test Corp', 'test-corp', NULL, 'free', NULL, NULL, 1, '2026-03-08 23:26:57', '2026-03-08 23:26:57');

-- --------------------------------------------------------

--
-- بنية الجدول `forms`
--

CREATE TABLE `forms` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `project_id` bigint(20) UNSIGNED DEFAULT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `slug` varchar(255) NOT NULL,
  `is_public` tinyint(1) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `settings` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`settings`)),
  `template_category` varchar(255) DEFAULT NULL,
  `task_mapping` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`task_mapping`)),
  `sla_hours` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `forms`
--

INSERT INTO `forms` (`id`, `project_id`, `user_id`, `title`, `description`, `slug`, `is_public`, `is_active`, `settings`, `template_category`, `task_mapping`, `sla_hours`, `created_at`, `updated_at`) VALUES
(1, NULL, 1, 'IT Support Request', 'Submit IT support requests', 'it-support-request-ajKb5Zcq', 1, 1, '{\"accent_color\":\"#6366f1\",\"success_message\":\"Thank you for your submission!\"}', 'it_support', '{\"title_field\":\"title\",\"description_fields\":[\"description\"]}', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(2, NULL, 1, 'it', NULL, 'it-jE2HcTXq', 1, 1, '{\"accent_color\":\"#6366f1\",\"success_message\":\"Thank you for your submission!\"}', 'it_support', '{\"title_field\":\"title\",\"description_fields\":[\"description\"]}', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(3, NULL, 1, 'aaaa', 'aa', 'aaaa-XK84ThXL', 1, 1, '{\"accent_color\":\"#6366f1\",\"success_message\":\"Thank you for your submission!\"}', 'it_support', '{\"title_field\":\"title\",\"description_fields\":[\"description\"]}', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(4, NULL, 1, 'aaaa (Copy)', 'aa', 'aaaa-copy-ZebY4vmf', 1, 1, '{\"accent_color\":\"#6366f1\",\"success_message\":\"Thank you for your submission!\"}', 'it_support', '{\"title_field\":\"title\",\"description_fields\":[\"description\"],\"project_id\":null}', NULL, '2026-04-20 17:10:17', '2026-04-20 17:22:20');

-- --------------------------------------------------------

--
-- بنية الجدول `form_escalation_rules`
--

CREATE TABLE `form_escalation_rules` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `form_id` bigint(20) UNSIGNED NOT NULL,
  `trigger_type` varchar(255) NOT NULL,
  `trigger_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`trigger_config`)),
  `action_type` varchar(255) NOT NULL,
  `action_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`action_config`)),
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `form_fields`
--

CREATE TABLE `form_fields` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `form_id` bigint(20) UNSIGNED NOT NULL,
  `field_key` varchar(255) NOT NULL,
  `type` varchar(255) NOT NULL,
  `label` varchar(255) NOT NULL,
  `placeholder` varchar(255) DEFAULT NULL,
  `help_text` varchar(255) DEFAULT NULL,
  `options` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`options`)),
  `validations` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`validations`)),
  `is_required` tinyint(1) NOT NULL DEFAULT 0,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `section_title` varchar(255) DEFAULT NULL,
  `width` varchar(255) NOT NULL DEFAULT 'full',
  `conditional_rules` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`conditional_rules`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `form_fields`
--

INSERT INTO `form_fields` (`id`, `form_id`, `field_key`, `type`, `label`, `placeholder`, `help_text`, `options`, `validations`, `is_required`, `sort_order`, `section_title`, `width`, `conditional_rules`, `created_at`, `updated_at`) VALUES
(1, 1, 'issue_heading', 'section', 'Issue Details', NULL, NULL, NULL, NULL, 0, 0, 'Issue Details', 'full', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(2, 1, 'title', 'text', 'Issue Title', NULL, NULL, NULL, NULL, 1, 1, NULL, 'full', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(3, 1, 'department', 'select', 'Department', NULL, NULL, '[{\"value\":\"engineering\",\"label\":\"Engineering\"},{\"value\":\"design\",\"label\":\"Design\"},{\"value\":\"marketing\",\"label\":\"Marketing\"},{\"value\":\"hr\",\"label\":\"HR\"},{\"value\":\"finance\",\"label\":\"Finance\"}]', NULL, 1, 2, NULL, 'full', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(4, 1, 'urgency', 'select', 'Urgency', NULL, NULL, '[{\"value\":\"urgent\",\"label\":\"Urgent\"},{\"value\":\"high\",\"label\":\"High\"},{\"value\":\"medium\",\"label\":\"Medium\"},{\"value\":\"low\",\"label\":\"Low\"}]', NULL, 1, 3, NULL, 'full', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(5, 1, 'description', 'textarea', 'Details', NULL, NULL, NULL, NULL, 1, 4, NULL, 'full', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(6, 1, 'attachment', 'file', 'Attachment', NULL, NULL, NULL, NULL, 0, 5, NULL, 'full', NULL, '2026-03-26 02:39:55', '2026-03-26 02:39:55'),
(7, 2, 'issue_heading', 'section', 'Issue Details', NULL, NULL, NULL, NULL, 0, 0, 'Issue Details', 'full', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(8, 2, 'title', 'text', 'Issue Title', NULL, NULL, NULL, NULL, 1, 1, NULL, 'full', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(9, 2, 'department', 'select', 'Department', NULL, NULL, '[{\"value\":\"engineering\",\"label\":\"Engineering\"},{\"value\":\"design\",\"label\":\"Design\"},{\"value\":\"marketing\",\"label\":\"Marketing\"},{\"value\":\"hr\",\"label\":\"HR\"},{\"value\":\"finance\",\"label\":\"Finance\"}]', NULL, 1, 2, NULL, 'full', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(10, 2, 'urgency', 'select', 'Urgency', NULL, NULL, '[{\"value\":\"urgent\",\"label\":\"Urgent\"},{\"value\":\"high\",\"label\":\"High\"},{\"value\":\"medium\",\"label\":\"Medium\"},{\"value\":\"low\",\"label\":\"Low\"}]', NULL, 1, 3, NULL, 'full', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(11, 2, 'description', 'textarea', 'Details', NULL, NULL, NULL, NULL, 1, 4, NULL, 'full', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(12, 2, 'attachment', 'file', 'Attachment', NULL, NULL, NULL, NULL, 0, 5, NULL, 'full', NULL, '2026-03-26 02:44:24', '2026-03-26 02:44:24'),
(13, 3, 'issue_heading', 'section', 'Issue Details', NULL, NULL, NULL, NULL, 0, 0, 'Issue Details', 'full', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(14, 3, 'title', 'text', 'Issue Title', NULL, NULL, NULL, NULL, 1, 1, NULL, 'full', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(15, 3, 'department', 'select', 'Department', NULL, NULL, '[{\"value\":\"engineering\",\"label\":\"Engineering\"},{\"value\":\"design\",\"label\":\"Design\"},{\"value\":\"marketing\",\"label\":\"Marketing\"},{\"value\":\"hr\",\"label\":\"HR\"},{\"value\":\"finance\",\"label\":\"Finance\"}]', NULL, 1, 2, NULL, 'full', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(16, 3, 'urgency', 'select', 'Urgency', NULL, NULL, '[{\"value\":\"urgent\",\"label\":\"Urgent\"},{\"value\":\"high\",\"label\":\"High\"},{\"value\":\"medium\",\"label\":\"Medium\"},{\"value\":\"low\",\"label\":\"Low\"}]', NULL, 1, 3, NULL, 'full', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(17, 3, 'description', 'textarea', 'Details', NULL, NULL, NULL, NULL, 1, 4, NULL, 'full', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(18, 3, 'attachment', 'file', 'Attachment', NULL, NULL, NULL, NULL, 0, 5, NULL, 'full', NULL, '2026-03-29 19:09:58', '2026-03-29 19:09:58'),
(19, 4, 'issue_heading', 'section', 'Issue Details', NULL, NULL, NULL, NULL, 0, 0, 'Issue Details', 'full', NULL, '2026-04-20 17:10:17', '2026-04-20 17:10:17'),
(20, 4, 'title', 'text', 'Issue Title', NULL, NULL, NULL, NULL, 1, 1, NULL, 'full', NULL, '2026-04-20 17:10:17', '2026-04-20 17:10:17'),
(21, 4, 'department', 'select', 'Department', NULL, NULL, '[{\"value\":\"engineering\",\"label\":\"Engineering\"},{\"value\":\"design\",\"label\":\"Design\"},{\"value\":\"marketing\",\"label\":\"Marketing\"},{\"value\":\"hr\",\"label\":\"HR\"},{\"value\":\"finance\",\"label\":\"Finance\"}]', NULL, 1, 2, NULL, 'full', NULL, '2026-04-20 17:10:17', '2026-04-20 17:10:17'),
(22, 4, 'urgency', 'select', 'Urgency', NULL, NULL, '[{\"value\":\"urgent\",\"label\":\"Urgent\"},{\"value\":\"high\",\"label\":\"High\"},{\"value\":\"medium\",\"label\":\"Medium\"},{\"value\":\"low\",\"label\":\"Low\"}]', NULL, 1, 3, NULL, 'full', NULL, '2026-04-20 17:10:17', '2026-04-20 17:10:17'),
(23, 4, 'description', 'textarea', 'Details', NULL, NULL, NULL, NULL, 1, 4, NULL, 'full', NULL, '2026-04-20 17:10:17', '2026-04-20 17:10:17'),
(24, 4, 'attachment', 'file', 'Attachment', NULL, NULL, NULL, NULL, 0, 5, NULL, 'full', NULL, '2026-04-20 17:10:17', '2026-04-20 17:10:17');

-- --------------------------------------------------------

--
-- بنية الجدول `form_submissions`
--

CREATE TABLE `form_submissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `form_id` bigint(20) UNSIGNED NOT NULL,
  `task_id` bigint(20) UNSIGNED DEFAULT NULL,
  `submitted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`data`)),
  `ip_address` varchar(255) DEFAULT NULL,
  `ticket_id` varchar(255) NOT NULL,
  `status` varchar(255) NOT NULL DEFAULT 'new',
  `submitted_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `sla_deadline_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `form_submissions`
--

INSERT INTO `form_submissions` (`id`, `form_id`, `task_id`, `submitted_by`, `data`, `ip_address`, `ticket_id`, `status`, `submitted_at`, `sla_deadline_at`, `created_at`, `updated_at`) VALUES
(1, 1, NULL, 1, '{\"title\":\"\\u0634\\u0627\\u0648\\u062b\\u064a \\u0641\\u0648\\u0631\\u0645\",\"department\":\"finance\",\"urgency\":\"urgent\",\"description\":\"\\u062a\\u0628\\u0639\\u0628\\u0639\",\"attachment\":null}', '127.0.0.1', 'TKT-ITS-20260326-0001', 'new', '2026-03-26 02:43:44', NULL, '2026-03-26 02:43:44', '2026-03-26 02:43:44');

-- --------------------------------------------------------

--
-- بنية الجدول `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2024_01_01_000012_create_settings_table', 1),
(2, '2024_01_01_000013_create_task_dependencies_table', 2),
(3, '2024_01_01_000014_create_form_tables', 3);

-- --------------------------------------------------------

--
-- بنية الجدول `model_has_permissions`
--

CREATE TABLE `model_has_permissions` (
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `model_has_roles`
--

CREATE TABLE `model_has_roles` (
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `model_has_roles`
--

INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES
(1, 'App\\Models\\User', 1),
(2, 'App\\Models\\User', 7),
(3, 'App\\Models\\User', 2),
(4, 'App\\Models\\User', 3),
(5, 'App\\Models\\User', 4),
(5, 'App\\Models\\User', 5),
(6, 'App\\Models\\User', 6);

-- --------------------------------------------------------

--
-- بنية الجدول `notifications`
--

CREATE TABLE `notifications` (
  `id` char(36) NOT NULL,
  `type` varchar(255) NOT NULL,
  `notifiable_type` varchar(255) NOT NULL,
  `notifiable_id` bigint(20) UNSIGNED NOT NULL,
  `data` text NOT NULL,
  `read_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `notifications`
--

INSERT INTO `notifications` (`id`, `type`, `notifiable_type`, `notifiable_id`, `data`, `read_at`, `created_at`, `updated_at`) VALUES
('0fbf19f4-0fe5-4d80-a2bd-3657724b425a', 'App\\Notifications\\TaskAssignedNotification', 'App\\Models\\User', 1, '{\"title\":\"Task Assigned to You\",\"message\":\"Admin User assigned you \\\"test1\\\"\",\"url\":\"http:\\/\\/127.0.0.1:8000\\/tasks\\/17\",\"task_id\":17,\"project_id\":1}', '2026-03-24 18:29:05', '2026-03-24 18:28:58', '2026-03-24 18:29:05');

-- --------------------------------------------------------

--
-- بنية الجدول `permissions`
--

CREATE TABLE `permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `guard_name` varchar(255) DEFAULT 'web',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `permissions`
--

INSERT INTO `permissions` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
(1, 'create_project', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 'edit_project', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(3, 'delete_project', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(4, 'create_task', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(5, 'assign_task', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(6, 'update_task_status', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(7, 'comment_task', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(8, 'manage_users', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(9, 'manage_teams', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(10, 'view_reports', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(11, 'view_projects', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(12, 'archive_project', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(13, 'view_tasks', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(14, 'edit_task', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(15, 'delete_task', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(16, 'view_teams', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(17, 'create_team', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(18, 'edit_team', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(19, 'delete_team', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(20, 'view_users', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(21, 'create_user', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(22, 'edit_user', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(23, 'delete_user', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(24, 'view_roles', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(25, 'manage_roles', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(26, 'view_forms', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(27, 'create_form', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(28, 'edit_form', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(29, 'delete_form', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(30, 'view_tags', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(31, 'create_tag', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(32, 'edit_tag', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(33, 'delete_tag', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(34, 'view_activity_log', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13'),
(35, 'manage_settings', 'web', '2026-04-20 17:35:13', '2026-04-20 17:35:13');

-- --------------------------------------------------------

--
-- بنية الجدول `projects`
--

CREATE TABLE `projects` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `team_id` bigint(20) UNSIGNED DEFAULT NULL,
  `company_id` bigint(20) UNSIGNED NOT NULL,
  `owner_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('not_started','in_progress','on_hold','completed','cancelled') DEFAULT 'not_started',
  `priority` enum('low','medium','high','urgent') DEFAULT 'medium',
  `color` varchar(7) DEFAULT '#6366f1',
  `start_date` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `progress` tinyint(3) UNSIGNED DEFAULT 0,
  `is_archived` tinyint(1) DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `project_user`
--

CREATE TABLE `project_user` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `project_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `role` varchar(255) DEFAULT 'member',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `roles`
--

CREATE TABLE `roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `guard_name` varchar(255) DEFAULT 'web',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `roles`
--

INSERT INTO `roles` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
(1, 'Super Admin', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 'Company Admin', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(3, 'Manager', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(4, 'Team Leader', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(5, 'Employee', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(6, 'Viewer', 'web', '2026-03-09 01:12:28', '2026-03-09 01:12:28');

-- --------------------------------------------------------

--
-- بنية الجدول `role_has_permissions`
--

CREATE TABLE `role_has_permissions` (
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `role_has_permissions`
--

INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES
(1, 1),
(1, 2),
(1, 3),
(1, 4),
(2, 1),
(2, 2),
(2, 3),
(2, 4),
(3, 1),
(3, 2),
(4, 1),
(4, 2),
(4, 3),
(4, 4),
(4, 5),
(5, 1),
(5, 2),
(5, 3),
(5, 4),
(6, 1),
(6, 2),
(6, 3),
(6, 4),
(6, 5),
(7, 1),
(7, 2),
(7, 3),
(7, 4),
(7, 5),
(7, 6),
(8, 1),
(8, 2),
(9, 1),
(9, 2),
(9, 3),
(10, 1),
(10, 2),
(10, 3),
(10, 4),
(11, 1),
(12, 1),
(13, 1),
(14, 1),
(15, 1),
(16, 1),
(17, 1),
(18, 1),
(19, 1),
(20, 1),
(21, 1),
(22, 1),
(23, 1),
(24, 1),
(25, 1),
(26, 1),
(27, 1),
(28, 1),
(29, 1),
(30, 1),
(31, 1),
(32, 1),
(33, 1),
(34, 1),
(35, 1);

-- --------------------------------------------------------

--
-- بنية الجدول `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` longtext NOT NULL,
  `last_activity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `tags`
--

CREATE TABLE `tags` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `company_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `color` varchar(7) DEFAULT '#6366f1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `tags`
--

INSERT INTO `tags` (`id`, `company_id`, `name`, `color`, `created_at`, `updated_at`) VALUES
(1, 1, 'Bug', '#ef4444', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 1, 'Feature', '#3b82f6', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(3, 1, 'Urgent', '#f97316', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(4, 1, 'Design', '#ec4899', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(5, 1, 'Backend', '#8b5cf6', '2026-03-09 01:12:28', '2026-03-09 01:12:28');

-- --------------------------------------------------------

--
-- بنية الجدول `tag_task`
--

CREATE TABLE `tag_task` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `task_id` bigint(20) UNSIGNED NOT NULL,
  `tag_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `tasks`
--

CREATE TABLE `tasks` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `project_id` bigint(20) UNSIGNED NOT NULL,
  `assignee_id` bigint(20) UNSIGNED DEFAULT NULL,
  `creator_id` bigint(20) UNSIGNED NOT NULL,
  `parent_id` bigint(20) UNSIGNED DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('todo','in_progress','review','completed') DEFAULT 'todo',
  `priority` enum('low','medium','high','urgent') DEFAULT 'medium',
  `due_date` date DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `position` int(10) UNSIGNED DEFAULT 0,
  `estimated_hours` int(10) UNSIGNED DEFAULT NULL,
  `is_completed` tinyint(1) DEFAULT 0,
  `completed_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `task_dependencies`
--

CREATE TABLE `task_dependencies` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `task_id` bigint(20) UNSIGNED NOT NULL,
  `dependency_id` bigint(20) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `teams`
--

CREATE TABLE `teams` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `company_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `department` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `color` varchar(7) DEFAULT '#6366f1',
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `teams`
--

INSERT INTO `teams` (`id`, `company_id`, `name`, `department`, `description`, `color`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 1, 'Engineering', 'Technology', 'Software development team', '#6366f1', 1, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 1, 'Design', 'Creative', 'UI/UX and graphic design team', '#ec4899', 1, '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(3, 1, 'Marketing', 'Marketing', 'Digital marketing and growth team', '#f59e0b', 1, '2026-03-09 01:12:28', '2026-03-09 01:12:28');

-- --------------------------------------------------------

--
-- بنية الجدول `team_user`
--

CREATE TABLE `team_user` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `team_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `role` varchar(255) DEFAULT 'member',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `team_user`
--

INSERT INTO `team_user` (`id`, `team_id`, `user_id`, `role`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 'lead', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(2, 1, 3, 'lead', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(3, 1, 4, 'member', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(4, 2, 5, 'lead', '2026-03-09 01:12:28', '2026-03-09 01:12:28'),
(5, 2, 2, 'member', '2026-03-08 23:38:12', '2026-03-08 23:38:12'),
(6, 2, 1, 'member', '2026-03-08 23:38:15', '2026-03-08 23:38:15');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `activities`
--
ALTER TABLE `activities`
  ADD PRIMARY KEY (`id`),
  ADD KEY `activities_subject` (`subject_type`,`subject_id`),
  ADD KEY `company_id` (`company_id`),
  ADD KEY `causer_id` (`causer_id`);

--
-- Indexes for table `attachments`
--
ALTER TABLE `attachments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `task_id` (`task_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `comments`
--
ALTER TABLE `comments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `task_id` (`task_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `companies`
--
ALTER TABLE `companies`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `forms`
--
ALTER TABLE `forms`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `forms_slug_unique` (`slug`),
  ADD KEY `forms_project_id_foreign` (`project_id`),
  ADD KEY `forms_user_id_foreign` (`user_id`);

--
-- Indexes for table `form_escalation_rules`
--
ALTER TABLE `form_escalation_rules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `form_escalation_rules_form_id_foreign` (`form_id`);

--
-- Indexes for table `form_fields`
--
ALTER TABLE `form_fields`
  ADD PRIMARY KEY (`id`),
  ADD KEY `form_fields_form_id_foreign` (`form_id`);

--
-- Indexes for table `form_submissions`
--
ALTER TABLE `form_submissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `form_submissions_ticket_id_unique` (`ticket_id`),
  ADD KEY `form_submissions_form_id_foreign` (`form_id`),
  ADD KEY `form_submissions_task_id_foreign` (`task_id`),
  ADD KEY `form_submissions_submitted_by_foreign` (`submitted_by`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `model_has_permissions`
--
ALTER TABLE `model_has_permissions`
  ADD PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  ADD KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`);

--
-- Indexes for table `model_has_roles`
--
ALTER TABLE `model_has_roles`
  ADD PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  ADD KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`),
  ADD KEY `notifications_notifiable` (`notifiable_type`,`notifiable_id`);

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `permissions_name_guard_unique` (`name`,`guard_name`);

--
-- Indexes for table `projects`
--
ALTER TABLE `projects`
  ADD PRIMARY KEY (`id`),
  ADD KEY `team_id` (`team_id`),
  ADD KEY `company_id` (`company_id`),
  ADD KEY `owner_id` (`owner_id`);

--
-- Indexes for table `project_user`
--
ALTER TABLE `project_user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `project_user_unique` (`project_id`,`user_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `roles_name_guard_unique` (`name`,`guard_name`);

--
-- Indexes for table `role_has_permissions`
--
ALTER TABLE `role_has_permissions`
  ADD PRIMARY KEY (`permission_id`,`role_id`),
  ADD KEY `role_id` (`role_id`);

--
-- Indexes for table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sessions_user_id_index` (`user_id`),
  ADD KEY `sessions_last_activity_index` (`last_activity`);

--
-- Indexes for table `tags`
--
ALTER TABLE `tags`
  ADD PRIMARY KEY (`id`),
  ADD KEY `company_id` (`company_id`);

--
-- Indexes for table `tag_task`
--
ALTER TABLE `tag_task`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `task_tag_unique` (`task_id`,`tag_id`),
  ADD KEY `tag_id` (`tag_id`);

--
-- Indexes for table `tasks`
--
ALTER TABLE `tasks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `creator_id` (`creator_id`),
  ADD KEY `parent_id` (`parent_id`),
  ADD KEY `tasks_project_status` (`project_id`,`status`),
  ADD KEY `tasks_assignee_status` (`assignee_id`,`status`);

--
-- Indexes for table `task_dependencies`
--
ALTER TABLE `task_dependencies`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `task_dependencies_task_id_dependency_id_unique` (`task_id`,`dependency_id`),
  ADD KEY `task_dependencies_dependency_id_foreign` (`dependency_id`);

--
-- Indexes for table `teams`
--
ALTER TABLE `teams`
  ADD PRIMARY KEY (`id`),
  ADD KEY `company_id` (`company_id`);

--
-- Indexes for table `team_user`
--
ALTER TABLE `team_user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `team_user_unique` (`team_id`,`user_id`),
  ADD KEY `user_id` (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `activities`
--
ALTER TABLE `activities`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;

--
-- AUTO_INCREMENT for table `attachments`
--
ALTER TABLE `attachments`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `comments`
--
ALTER TABLE `comments`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `companies`
--
ALTER TABLE `companies`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `forms`
--
ALTER TABLE `forms`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `form_escalation_rules`
--
ALTER TABLE `form_escalation_rules`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `form_fields`
--
ALTER TABLE `form_fields`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT for table `form_submissions`
--
ALTER TABLE `form_submissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;

--
-- AUTO_INCREMENT for table `projects`
--
ALTER TABLE `projects`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `project_user`
--
ALTER TABLE `project_user`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `tags`
--
ALTER TABLE `tags`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `tag_task`
--
ALTER TABLE `tag_task`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `tasks`
--
ALTER TABLE `tasks`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;

--
-- AUTO_INCREMENT for table `task_dependencies`
--
ALTER TABLE `task_dependencies`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `teams`
--
ALTER TABLE `teams`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `team_user`
--
ALTER TABLE `team_user`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- قيود الجداول المُلقاة.
--

--
-- قيود الجداول `activities`
--
ALTER TABLE `activities`
  ADD CONSTRAINT `activities_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `activities_ibfk_2` FOREIGN KEY (`causer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `attachments`
--
ALTER TABLE `attachments`
  ADD CONSTRAINT `attachments_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `attachments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `comments`
--
ALTER TABLE `comments`
  ADD CONSTRAINT `comments_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `comments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `forms`
--
ALTER TABLE `forms`
  ADD CONSTRAINT `forms_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `forms_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `form_escalation_rules`
--
ALTER TABLE `form_escalation_rules`
  ADD CONSTRAINT `form_escalation_rules_form_id_foreign` FOREIGN KEY (`form_id`) REFERENCES `forms` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `form_fields`
--
ALTER TABLE `form_fields`
  ADD CONSTRAINT `form_fields_form_id_foreign` FOREIGN KEY (`form_id`) REFERENCES `forms` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `form_submissions`
--
ALTER TABLE `form_submissions`
  ADD CONSTRAINT `form_submissions_form_id_foreign` FOREIGN KEY (`form_id`) REFERENCES `forms` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `form_submissions_submitted_by_foreign` FOREIGN KEY (`submitted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `form_submissions_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `model_has_permissions`
--
ALTER TABLE `model_has_permissions`
  ADD CONSTRAINT `model_has_permissions_ibfk_1` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `model_has_roles`
--
ALTER TABLE `model_has_roles`
  ADD CONSTRAINT `model_has_roles_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `projects`
--
ALTER TABLE `projects`
  ADD CONSTRAINT `projects_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `projects_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `projects_ibfk_3` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `project_user`
--
ALTER TABLE `project_user`
  ADD CONSTRAINT `project_user_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `project_user_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `role_has_permissions`
--
ALTER TABLE `role_has_permissions`
  ADD CONSTRAINT `role_has_permissions_ibfk_1` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `role_has_permissions_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `tags`
--
ALTER TABLE `tags`
  ADD CONSTRAINT `tags_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `tag_task`
--
ALTER TABLE `tag_task`
  ADD CONSTRAINT `tag_task_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `tag_task_ibfk_2` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `tasks`
--
ALTER TABLE `tasks`
  ADD CONSTRAINT `tasks_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `tasks_ibfk_2` FOREIGN KEY (`assignee_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `tasks_ibfk_3` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `tasks_ibfk_4` FOREIGN KEY (`parent_id`) REFERENCES `tasks` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `task_dependencies`
--
ALTER TABLE `task_dependencies`
  ADD CONSTRAINT `task_dependencies_dependency_id_foreign` FOREIGN KEY (`dependency_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `task_dependencies_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `teams`
--
ALTER TABLE `teams`
  ADD CONSTRAINT `teams_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `team_user`
--
ALTER TABLE `team_user`
  ADD CONSTRAINT `team_user_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `team_user_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;

