-- https://www.phpmyadmin.net/
--

START TRANSACTION;



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

--
-- Table structure for table `companies`
--

CREATE TABLE `companies` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `company_registration_id` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `address` text NOT NULL,
  `phone_number` varchar(255) NOT NULL,
  `supervisor_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `companies`
--

INSERT INTO `companies` (`id`, `company_registration_id`, `name`, `address`, `phone_number`, `supervisor_user_id`, `created_at`, `updated_at`) VALUES
(1, 'TSB001', 'Tech Solutions Sdn Bhd', '123 Jalan Teknologi, Cyberjaya, Selangor 63000', '03-8888-1111', 3, '2026-08-04 16:12:30', '2026-08-04 16:12:30'),
(2, 'DCS002', 'DataCore Systems', '456 Jalan Data, Petaling Jaya, Selangor 47500', '03-7777-2222', 4, '2026-08-04 16:12:30', '2026-08-04 16:12:30'),
(3, 'CWT003', 'CloudWave Technologies', '789 Jalan Cloud, KLCC, Kuala Lumpur 50450', '03-6666-3333', 5, '2026-08-04 16:12:30', '2026-08-04 16:12:30');

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

--
-- Table structure for table `evaluations`
--

CREATE TABLE `evaluations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `student_id` bigint(20) UNSIGNED NOT NULL,
  `evaluator_id` bigint(20) UNSIGNED NOT NULL,
  `evaluator_role` enum('company_supervisor','lecturer') NOT NULL,
  `assessment_code` varchar(80) DEFAULT NULL,
  `rubric_template_id` bigint(20) UNSIGNED DEFAULT NULL,
  `rubric_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`rubric_data`)),
  `rubric_snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`rubric_snapshot`)),
  `total_marks` decimal(5,2) DEFAULT NULL,
  `weightage` decimal(5,2) DEFAULT NULL,
  `final_comments` text DEFAULT NULL,
  `attachment_path` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `jobs`
--

CREATE TABLE `jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `queue` varchar(255) NOT NULL,
  `payload` longtext NOT NULL,
  `attempts` tinyint(3) UNSIGNED NOT NULL,
  `reserved_at` int(10) UNSIGNED DEFAULT NULL,
  `available_at` int(10) UNSIGNED NOT NULL,
  `created_at` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `job_batches`
--

CREATE TABLE `job_batches` (
  `id` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `total_jobs` int(11) NOT NULL,
  `pending_jobs` int(11) NOT NULL,
  `failed_jobs` int(11) NOT NULL,
  `failed_job_ids` longtext NOT NULL,
  `options` mediumtext DEFAULT NULL,
  `cancelled_at` int(11) DEFAULT NULL,
  `created_at` int(11) NOT NULL,
  `finished_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `logbooks`
--

CREATE TABLE `logbooks` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `student_id` bigint(20) UNSIGNED NOT NULL,
  `entry_type` varchar(255) NOT NULL,
  `date_of_entry` date NOT NULL,
  `activity_description` text NOT NULL,
  `evidence_file_path` varchar(255) DEFAULT NULL,
  `status` enum('pending','reviewed','approved','rejected') NOT NULL DEFAULT 'pending',
  `company_supervisor_comment` text DEFAULT NULL,
  `lecturer_comment` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `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;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '0001_01_01_000000_create_users_table', 1),
(2, '0001_01_01_000001_create_cache_table', 1),
(3, '0001_01_01_000002_create_jobs_table', 1),
(4, '2026_05_29_063614_create_companies_table', 1),
(5, '2026_05_29_063854_create_student_profiles_table', 1),
(6, '2026_05_29_063941_create_logbooks_table', 1),
(7, '2026_05_29_064030_create_evaluations_table', 1),
(8, '2026_05_30_000001_add_content_to_student_profiles_table', 1),
(9, '2026_07_27_000000_make_company_supervisor_nullable', 1),
(10, '2026_07_27_000001_replace_duration_with_dates_on_student_profiles', 1),
(11, '2026_07_27_000002_add_attachments_to_logbooks_table', 1),
(12, '2026_07_27_000003_add_attachment_to_evaluations_table', 1),
(13, '2026_07_27_000004_create_settings_table', 1),
(14, '2026_08_03_000001_create_rubric_tables', 1),
(15, '2026_08_04_000001_expand_user_roles_and_constraints', 1),
(16, '2026_08_16_000001_create_student_documents_table', 2),
(17, '2026_08_16_000002_align_official_internship_assessments', 2);

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

--
-- Table structure for table `rubric_items`
--

CREATE TABLE `rubric_items` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `rubric_template_id` bigint(20) UNSIGNED NOT NULL,
  `criterion` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `max_score` decimal(6,2) NOT NULL DEFAULT 100.00,
  `weight` decimal(6,2) NOT NULL DEFAULT 0.00,
  `sort_order` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `rubric_items`
--

INSERT INTO `rubric_items` (`id`, `rubric_template_id`, `criterion`, `description`, `max_score`, `weight`, `sort_order`, `created_at`, `updated_at`) VALUES
(1, 1, 'Attendance and punctuality', NULL, 100.00, 12.50, 1, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(2, 1, 'Professional attitude and ethics', NULL, 100.00, 12.50, 2, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(3, 1, 'Technical knowledge and skills', NULL, 100.00, 12.50, 3, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(4, 1, 'Quality and accuracy of work', NULL, 100.00, 12.50, 4, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(5, 1, 'Initiative and problem-solving', NULL, 100.00, 12.50, 5, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(6, 1, 'Communication skills', NULL, 100.00, 12.50, 6, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(7, 1, 'Teamwork and cooperation', NULL, 100.00, 12.50, 7, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(8, 1, 'Adaptability and willingness to learn', NULL, 100.00, 12.50, 8, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(9, 2, 'Quality of internship report', NULL, 100.00, 20.00, 1, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(10, 2, 'Application of academic knowledge', NULL, 100.00, 20.00, 2, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(11, 2, 'Reflection and critical thinking', NULL, 100.00, 20.00, 3, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(12, 2, 'Presentation and communication', NULL, 100.00, 20.00, 4, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(13, 2, 'Achievement of internship learning outcomes', NULL, 100.00, 20.00, 5, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(14, 3, 'Work Discipline - Punctuality and sense of time', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 0, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(15, 3, 'Work Discipline - Acceptance of duty and responsibility', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 1, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(16, 3, 'Work Discipline - Attitude towards work and people', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 2, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(17, 3, 'Work Discipline - Quality of work', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 3, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(18, 3, 'Technical / Analytical Skills - Logical and analytical skills', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 4, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(19, 3, 'Technical / Analytical Skills - Ability to express and defend ideas', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 5, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(20, 3, 'Technical / Analytical Skills - Willingness to learn new skills', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 6, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(21, 3, 'Leadership Skills - Ability to lead people', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 7, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(22, 3, 'Leadership Skills - Ability to work in group', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 8, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(23, 3, 'Leadership Skills - Initiatives and independence', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 9, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(24, 3, 'Leadership Skills - Dedicated towards work and team', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 10, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(25, 3, 'Personality and Professionalism - Appearance and personality', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 11, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(26, 3, 'Personality and Professionalism - Ethics and confidence', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 12, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(27, 3, 'Personality and Professionalism - Communication with superior', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 13, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(28, 3, 'Personality and Professionalism - Communication with peers and staff', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 14, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(29, 3, 'Communication Skills - Oral', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.88, 15, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(30, 3, 'Communication Skills - Writing', 'Rate 1 (Unsatisfactory) to 5 (Excellent).', 5.00, 5.92, 16, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(31, 4, 'Neatness of daily activity record', NULL, 10.00, 10.00, 0, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(32, 4, 'Update on daily activity record', NULL, 20.00, 20.00, 1, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(33, 4, 'Content - concept, procedure and explanation', 'Concept, procedure and explanation on the system or equipment used.', 50.00, 50.00, 2, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(34, 4, 'Comments from industrial supervisor', NULL, 20.00, 20.00, 3, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(35, 5, 'Internship Project', 'Relevance to BITNS and technical challenge.', 20.00, 40.00, 0, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(36, 5, 'Oral Delivery', 'Clarity, subject knowledge, time management and audience communication.', 20.00, 40.00, 1, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(37, 5, 'Presentation Materials', 'Quality of the materials presented.', 10.00, 20.00, 2, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(38, 6, 'Company / organization background', NULL, 10.00, 10.00, 0, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(39, 6, 'Internship project / task / training', NULL, 50.00, 50.00, 1, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(40, 6, 'Conclusion', NULL, 20.00, 20.00, 2, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(41, 6, 'Clarity (grammar / spelling)', NULL, 10.00, 10.00, 3, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(42, 6, 'Presentation / Structure of Report', NULL, 10.00, 10.00, 4, '2026-08-15 17:34:45', '2026-08-15 17:34:45');

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

--
-- Table structure for table `rubric_templates`
--

CREATE TABLE `rubric_templates` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `assessment_code` varchar(80) DEFAULT NULL,
  `evaluator_role` enum('company_supervisor','lecturer') NOT NULL,
  `assessment_weight` decimal(5,2) NOT NULL DEFAULT 0.00,
  `description` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `rubric_templates`
--

INSERT INTO `rubric_templates` (`id`, `name`, `assessment_code`, `evaluator_role`, `assessment_weight`, `description`, `is_active`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 'Company Supervisor Evaluation', NULL, 'company_supervisor', 0.00, 'Default workplace performance evaluation rubric.', 0, NULL, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(2, 'Lecturer Evaluation', NULL, 'lecturer', 0.00, 'Default academic internship evaluation rubric.', 0, NULL, '2026-08-04 00:00:56', '2026-08-04 00:00:56'),
(3, 'Industry Supervisor Evaluation', 'industry_supervisor', 'company_supervisor', 30.00, 'Official Industry Supervisor Evaluation Form - 30% of the internship final mark. Raw total: 85 marks.', 1, NULL, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(4, 'Log Book Evaluation', 'log_book', 'lecturer', 15.00, 'Official Industrial Training Log Book Feedback Form - 15% of the internship final mark.', 1, NULL, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(5, 'Presentation Evaluation', 'presentation', 'lecturer', 15.00, 'Official Industrial Training Presentation Evaluation Form - 15% of the internship final mark. Raw total: 50 marks.', 1, NULL, '2026-08-15 17:34:45', '2026-08-15 17:34:45'),
(6, 'Internship Report Evaluation', 'report', 'lecturer', 40.00, 'Official Training Report Feedback Form - 40% of the internship final mark.', 1, NULL, '2026-08-15 17:34:45', '2026-08-15 17:34:45');

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

--
-- Table structure for table `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;

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

--
-- Table structure for table `student_documents`
--

CREATE TABLE `student_documents` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `student_id` bigint(20) UNSIGNED NOT NULL,
  `category` varchar(80) NOT NULL DEFAULT 'Other',
  `title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `original_name` varchar(255) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `mime_type` varchar(150) DEFAULT NULL,
  `file_size` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `submitted_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;

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

--
-- Table structure for table `student_profiles`
--

CREATE TABLE `student_profiles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `company_id` bigint(20) UNSIGNED DEFAULT NULL,
  `company_supervisor_id` bigint(20) UNSIGNED DEFAULT NULL,
  `lecturer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `internship_start_date` date DEFAULT NULL,
  `internship_end_date` date DEFAULT NULL,
  `extra_information` text DEFAULT NULL,
  `internship_memo` text DEFAULT NULL,
  `internship_memo_path` varchar(255) DEFAULT NULL,
  `internship_rules` text DEFAULT NULL,
  `internship_rules_path` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `student_profiles`
--

INSERT INTO `student_profiles` (`id`, `user_id`, `company_id`, `company_supervisor_id`, `lecturer_id`, `internship_start_date`, `internship_end_date`, `extra_information`, `internship_memo`, `internship_memo_path`, `internship_rules`, `internship_rules_path`, `created_at`, `updated_at`) VALUES
(1, 9, 1, 3, 6, '2026-07-06', '2026-10-04', 'Test student for development purposes.', NULL, NULL, NULL, NULL, '2026-08-04 16:12:31', '2026-08-04 16:12:31'),
(2, 10, 2, 4, 6, '2026-07-06', '2026-10-04', 'Test student for development purposes.', NULL, NULL, NULL, NULL, '2026-08-04 16:12:31', '2026-08-04 16:12:31');

--
-- Indexes for table `companies`
--
ALTER TABLE `companies`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `companies_company_registration_id_unique` (`company_registration_id`),
  ADD UNIQUE KEY `companies_supervisor_user_id_unique` (`supervisor_user_id`);

--
-- Indexes for table `evaluations`
--
ALTER TABLE `evaluations`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `evaluations_student_evaluator_unique` (`student_id`,`evaluator_id`),
  ADD KEY `evaluations_evaluator_id_foreign` (`evaluator_id`),
  ADD KEY `evaluations_rubric_template_id_foreign` (`rubric_template_id`),
  ADD KEY `evaluations_student_id_assessment_code_index` (`student_id`,`assessment_code`);

--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indexes for table `jobs`
--
ALTER TABLE `jobs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `jobs_queue_index` (`queue`);

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

--
-- Indexes for table `logbooks`
--
ALTER TABLE `logbooks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `logbooks_student_id_foreign` (`student_id`);

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

--
-- Indexes for table `rubric_items`
--
ALTER TABLE `rubric_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `rubric_items_rubric_template_id_foreign` (`rubric_template_id`);

--
-- Indexes for table `rubric_templates`
--
ALTER TABLE `rubric_templates`
  ADD PRIMARY KEY (`id`),
  ADD KEY `rubric_templates_created_by_foreign` (`created_by`);

--
-- 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 `student_documents`
--
ALTER TABLE `student_documents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `student_documents_student_id_category_index` (`student_id`,`category`);

--
-- Indexes for table `student_profiles`
--
ALTER TABLE `student_profiles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `student_profiles_user_id_unique` (`user_id`),
  ADD KEY `student_profiles_company_id_foreign` (`company_id`),
  ADD KEY `student_profiles_company_supervisor_id_foreign` (`company_supervisor_id`),
  ADD KEY `student_profiles_lecturer_id_foreign` (`lecturer_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `companies`
--
ALTER TABLE `companies`
  ADD CONSTRAINT `companies_supervisor_user_id_foreign` FOREIGN KEY (`supervisor_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `evaluations`
--
ALTER TABLE `evaluations`
  ADD CONSTRAINT `evaluations_evaluator_id_foreign` FOREIGN KEY (`evaluator_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `evaluations_rubric_template_id_foreign` FOREIGN KEY (`rubric_template_id`) REFERENCES `rubric_templates` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `evaluations_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `logbooks`
--
ALTER TABLE `logbooks`
  ADD CONSTRAINT `logbooks_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `rubric_items`
--
ALTER TABLE `rubric_items`
  ADD CONSTRAINT `rubric_items_rubric_template_id_foreign` FOREIGN KEY (`rubric_template_id`) REFERENCES `rubric_templates` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `rubric_templates`
--
ALTER TABLE `rubric_templates`
  ADD CONSTRAINT `rubric_templates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `student_documents`
--
ALTER TABLE `student_documents`
  ADD CONSTRAINT `student_documents_student_id_foreign` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `student_profiles`
--
ALTER TABLE `student_profiles`
  ADD CONSTRAINT `student_profiles_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `student_profiles_company_supervisor_id_foreign` FOREIGN KEY (`company_supervisor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `student_profiles_lecturer_id_foreign` FOREIGN KEY (`lecturer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `student_profiles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;

