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

START TRANSACTION;



--
-- Database: `chatting_app_db`
--

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

--
-- Table structure for table `ci_sessions`
--

CREATE TABLE `ci_sessions` (
  `id` varchar(128) NOT NULL,
  `ip_address` varchar(45) NOT NULL,
  `timestamp` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `data` blob NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `ci_sessions`
--

INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES
('ci_session:3745e97aed6914b121708d52bf215210', '::1', 4294967295, 0x5f5f63695f6c6173745f726567656e65726174657c693a313737363334333535363b5f63695f70726576696f75735f75726c7c733a35313a22687474703a2f2f6c6f63616c686f73742f6368617474696e672d6170702f7075626c69632f696e6465782e7068702f63686174223b7573657249647c733a313a2232223b6e616d657c733a363a22416e6a616c69223b656d61696c7c733a31343a22616e6a7540676d61696c2e636f6d223b6176617461725f75726c7c733a37333a22687474703a2f2f6c6f63616c686f73743a383038302f75706c6f6164732f617661746172732f313737353831333330375f38316561353962366563646638356462613532612e6a7067223b69734c6f67676564496e7c623a313b6c6173745f70756c73657c693a313737363334343230333b),
('ci_session:482870ebf6a7768aa67990f461e9eed9', '::1', 4294967295, 0x5f5f63695f6c6173745f726567656e65726174657c693a313737363431373531303b5f63695f70726576696f75735f75726c7c733a35313a22687474703a2f2f6c6f63616c686f73742f6368617474696e672d6170702f7075626c69632f696e6465782e7068702f63686174223b7573657249647c733a313a2232223b6e616d657c733a363a22416e6a616c69223b656d61696c7c733a31343a22616e6a7540676d61696c2e636f6d223b6176617461725f75726c7c733a38393a22687474703a2f2f6c6f63616c686f73742f6368617474696e672d6170702f7075626c69632f75706c6f6164732f70726f66696c65732f313737363431373632345f64633638306135326330616161386165313830642e6a7067223b69734c6f67676564496e7c623a313b6c6173745f70756c73657c693a313737363431373834363b),
('ci_session:785ec51ea60dcd61b421507d3840320b', '::1', 4294967295, 0x5f5f63695f6c6173745f726567656e65726174657c693a313737363334333537333b5f63695f70726576696f75735f75726c7c733a35313a22687474703a2f2f6c6f63616c686f73742f6368617474696e672d6170702f7075626c69632f696e6465782e7068702f63686174223b7573657249647c733a313a2231223b6e616d657c733a363a22506979757368223b656d61696c7c733a32353a227069797573682e72756e706169736140676d61696c2e636f6d223b6176617461725f75726c7c733a39303a22687474703a2f2f6c6f63616c686f73742f6368617474696e672d6170702f7075626c69632f75706c6f6164732f70726f66696c65732f313737363431373831355f31363131613633616531346331323763633032622e6a706567223b69734c6f67676564496e7c623a313b6c6173745f70756c73657c693a313737363431373835373b);

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

--
-- Table structure for table `friends`
--

CREATE TABLE `friends` (
  `id` int(11) UNSIGNED NOT NULL,
  `user_id_1` int(11) UNSIGNED NOT NULL,
  `user_id_2` int(11) UNSIGNED NOT NULL,
  `status` enum('pending','accepted') NOT NULL DEFAULT 'pending',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `friends`
--

INSERT INTO `friends` (`id`, `user_id_1`, `user_id_2`, `status`, `created_at`, `updated_at`) VALUES
(2, 2, 1, 'accepted', '2026-04-10 09:30:18', '2026-04-10 12:17:15');

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

--
-- Table structure for table `messages`
--

CREATE TABLE `messages` (
  `id` int(11) UNSIGNED NOT NULL,
  `sender_id` int(11) UNSIGNED NOT NULL,
  `receiver_id` int(11) UNSIGNED NOT NULL,
  `message` text NOT NULL,
  `attachment_url` varchar(255) DEFAULT NULL,
  `message_type` enum('text','image','file','video','call') DEFAULT 'text',
  `status` enum('sent','delivered','seen','deleted') NOT NULL DEFAULT 'sent',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_by_sender` tinyint(1) DEFAULT 0,
  `deleted_by_receiver` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `version` varchar(255) NOT NULL,
  `class` varchar(255) NOT NULL,
  `group` varchar(255) NOT NULL,
  `namespace` varchar(255) NOT NULL,
  `time` int(11) NOT NULL,
  `batch` int(11) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `migrations` (`id`, `version`, `class`, `group`, `namespace`, `time`, `batch`) VALUES
(1, '2026-04-10-083449', 'App\\Database\\Migrations\\CreateUsersTable', 'default', 'App', 1775810846, 1),
(2, '2026-04-10-083450', 'App\\Database\\Migrations\\CreateMessagesTable', 'default', 'App', 1775810846, 1),
(3, '2026-04-10-083635', 'App\\Database\\Migrations\\CreateCiSessionsTable', 'default', 'App', 1775810846, 1),
(4, '2026-04-10-090603', 'App\\Database\\Migrations\\AlterMessagesTable', 'default', 'App', 1775811996, 2),
(5, '2026-04-10-090603', 'App\\Database\\Migrations\\CreateFriendsTable', 'default', 'App', 1775811996, 2),
(6, '2026-04-10-090604', 'App\\Database\\Migrations\\CreateStatusesTable', 'default', 'App', 1775811996, 2),
(7, '2026-04-10-091734', 'App\\Database\\Migrations\\AlterUsersAddAvatar', 'default', 'App', 1775812684, 3),
(8, '2026-04-15-091944', 'App\\Database\\Migrations\\AddUpdatedAtToMessages', 'default', 'App', 1776244810, 4);

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

--
-- Table structure for table `statuses`
--

CREATE TABLE `statuses` (
  `id` int(11) UNSIGNED NOT NULL,
  `user_id` int(11) UNSIGNED NOT NULL,
  `media_url` varchar(255) NOT NULL,
  `caption` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `statuses`
--

INSERT INTO `statuses` (`id`, `user_id`, `media_url`, `caption`, `created_at`, `expires_at`) VALUES
(1, 2, '', 'hi status', '2026-04-17 14:51:48', '2026-04-18 14:51:48'),
(2, 2, 'uploads/status/1776417736_cb43e67a9ccaeb1ddd4a.webm', NULL, '2026-04-17 14:52:16', '2026-04-18 14:52:16');

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

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `otp` varchar(10) DEFAULT NULL,
  `avatar_url` varchar(255) DEFAULT NULL,
  `verified` tinyint(1) NOT NULL DEFAULT 0,
  `status` enum('online','offline') NOT NULL DEFAULT 'offline',
  `last_seen` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `name`, `email`, `password`, `otp`, `avatar_url`, `verified`, `status`, `last_seen`, `created_at`, `updated_at`) VALUES
(1, 'Piyush', 'piyush.runpaisa@gmail.com', '$2y$10$aFZ5gqojTgIxO8sLVToEo.0KwRYDhhZ0py7lIJYdcuwsYtSaLysB2', NULL, 'uploads/profiles/1776417815_1611a63ae14c127cc02b.jpeg', 1, 'online', '2026-04-16 18:18:15', '2026-04-10 08:49:48', '2026-04-17 14:53:35'),
(2, 'Anjali', 'anju@gmail.com', '$2y$10$Y2EVk1eeEezAVvR6D23tMuFCmH25.qUEINWdSWe/.2GgaRhgeaIT.', NULL, 'uploads/profiles/1776417624_dc680a52c0aaa8ae180d.jpg', 1, 'online', '2026-04-17 14:50:03', '2026-04-10 08:57:44', '2026-04-17 14:50:24');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `ci_sessions`
--
ALTER TABLE `ci_sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `timestamp` (`timestamp`);

--
-- Indexes for table `friends`
--
ALTER TABLE `friends`
  ADD PRIMARY KEY (`id`),
  ADD KEY `friends_user_id_1_foreign` (`user_id_1`),
  ADD KEY `friends_user_id_2_foreign` (`user_id_2`);

--
-- Indexes for table `messages`
--
ALTER TABLE `messages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `messages_sender_id_foreign` (`sender_id`),
  ADD KEY `messages_receiver_id_foreign` (`receiver_id`);

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `friends`
--
ALTER TABLE `friends`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `messages`
--
ALTER TABLE `messages`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;

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

--
-- AUTO_INCREMENT for table `statuses`
--
ALTER TABLE `statuses`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `friends`
--
ALTER TABLE `friends`
  ADD CONSTRAINT `friends_user_id_1_foreign` FOREIGN KEY (`user_id_1`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `friends_user_id_2_foreign` FOREIGN KEY (`user_id_2`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `messages`
--
ALTER TABLE `messages`
  ADD CONSTRAINT `messages_receiver_id_foreign` FOREIGN KEY (`receiver_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `messages_sender_id_foreign` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `statuses`
--
ALTER TABLE `statuses`
  ADD CONSTRAINT `statuses_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

