-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 25, 2022 at 06:03 PM
-- Server version: 10.4.22-MariaDB
-- PHP Version: 8.1.1

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `eld`
--

DELIMITER $$
--
-- Procedures
--
CREATE DEFINER=`root`@`localhost` PROCEDURE `getOtp` (IN `emailPar` VARCHAR(100))  BEGIN
SELECT otp FROM users WHERE emailPar = users.email;
END$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `saveUser` (IN `emailPar` VARCHAR(255), IN `firstNamePar` VARCHAR(255), IN `lastNamePar` VARCHAR(255), IN `dobPar` VARCHAR(255), IN `uuidPar` VARCHAR(255), IN `otpPar` INT(100))  BEGIN
INSERT INTO users (uuid, email, first_name, last_name, avatar, about, password, date_of_birth, createdAt, updatedAt, deletedAt, otp) 
VALUES ( uuidPar, emailPar, firstNamePar, lastNamePar, null, null, null, dobPar, CURRENT_DATE(), CURRENT_DATE(), null, otpPar);
END$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `setOtp` (IN `otpPar` INT(100), IN `emailPar` VARCHAR(100))  BEGIN
UPDATE users SET users.otp = otpPar where emailPar = users.email;
END$$

DELIMITER ;

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

--
-- Table structure for table `activities`
--

CREATE TABLE `activities` (
  `id` int(11) NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `address` text NOT NULL,
  `latitude` varchar(255) NOT NULL,
  `longitude` varchar(255) NOT NULL,
  `max_capacity` int(11) NOT NULL,
  `start_time` datetime NOT NULL,
  `end_time` datetime NOT NULL,
  `is_done` tinyint(1) NOT NULL DEFAULT 0,
  `is_public` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) NOT NULL,
  `code` varchar(255) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `activity_interests`
--

CREATE TABLE `activity_interests` (
  `id` int(11) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `interest_id` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `activity_invitations`
--

CREATE TABLE `activity_invitations` (
  `id` int(11) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `accepted` tinyint(1) DEFAULT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `activity_messages`
--

CREATE TABLE `activity_messages` (
  `id` int(11) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `message_body` text NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `activity_users`
--

CREATE TABLE `activity_users` (
  `id` int(11) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `chatgroups`
--

CREATE TABLE `chatgroups` (
  `id` int(11) NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` mediumtext DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `is_public` tinyint(1) NOT NULL DEFAULT 1,
  `max_capacity` int(11) DEFAULT NULL,
  `latitude` varchar(255) DEFAULT NULL,
  `longitude` varchar(255) DEFAULT NULL,
  `code` varchar(255) NOT NULL,
  `created_by` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `chatgroup_interests`
--

CREATE TABLE `chatgroup_interests` (
  `id` int(11) NOT NULL,
  `chatgroup_id` int(11) NOT NULL,
  `interest_id` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `chatgroup_invitations`
--

CREATE TABLE `chatgroup_invitations` (
  `id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `accepted` tinyint(1) DEFAULT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `chatgroup_messages`
--

CREATE TABLE `chatgroup_messages` (
  `id` int(11) NOT NULL,
  `text` mediumtext NOT NULL,
  `sent_by` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `chatgroup_users`
--

CREATE TABLE `chatgroup_users` (
  `id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `email_confirm`
--

CREATE TABLE `email_confirm` (
  `id` int(11) NOT NULL,
  `user_email` varchar(255) NOT NULL,
  `activation_code` varchar(255) NOT NULL,
  `was_used` tinyint(1) DEFAULT 0,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `email_confirm`
--

INSERT INTO `email_confirm` (`id`, `user_email`, `activation_code`, `was_used`, `createdAt`, `updatedAt`, `deletedAt`) VALUES
(5, 'uqba.usman@techxpert.io', '265719', 0, '2022-01-19 16:09:59', '2022-01-19 16:09:59', NULL);

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

--
-- Table structure for table `friends_list`
--

CREATE TABLE `friends_list` (
  `id` int(11) NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `user1_id` int(11) NOT NULL,
  `user2_id` int(11) NOT NULL,
  `chat_started` tinyint(1) DEFAULT NULL,
  `request_id` int(11) NOT NULL,
  `deleted_by` int(11) DEFAULT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `friends_messages`
--

CREATE TABLE `friends_messages` (
  `id` int(11) NOT NULL,
  `friends_id` int(11) NOT NULL,
  `sent_by` int(11) NOT NULL,
  `message_body` mediumtext NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `friend_requests`
--

CREATE TABLE `friend_requests` (
  `id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `receiver_id` int(11) NOT NULL,
  `is_accepted` tinyint(1) DEFAULT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `interests`
--

CREATE TABLE `interests` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `interests`
--

INSERT INTO `interests` (`id`, `name`, `createdAt`, `updatedAt`, `deletedAt`) VALUES
(1, 'Football', '2022-01-19 16:30:02', '2022-01-19 16:30:02', '2022-01-19 16:30:02'),
(2, 'Cricket', '2022-01-19 16:30:02', '2022-01-19 16:30:02', '2022-01-19 16:30:02'),
(3, 'Eating', '2022-01-19 16:31:10', '2022-01-19 16:31:10', '2022-01-19 16:31:10'),
(4, 'Enjoying', '2022-01-19 16:31:10', '2022-01-19 16:31:10', '2022-01-19 16:31:10');

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

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

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `avatar` varchar(255) DEFAULT NULL,
  `about` text DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `date_of_birth` varchar(255) NOT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL,
  `otp` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

INSERT INTO `users` (`id`, `uuid`, `email`, `first_name`, `last_name`, `avatar`, `about`, `password`, `date_of_birth`, `is_active`, `createdAt`, `updatedAt`, `deletedAt`, `otp`) VALUES
(6, '3eb03cee-ae67-47ad-985b-cd512807e5b0', 'hectorgreycb@gmail.com', 'demo', 'shemo', NULL, NULL, 'onetwothree', '2021-04-18T23:51:28Z', 1, '2022-01-19 15:33:25', '2022-01-19 15:33:25', NULL, 0),
(7, '9c7701e8-72d4-47e6-b0bf-7d0620f0eae4', 'uqba.usman@techxpert.io', 'demo', 'shemo', NULL, NULL, 'onetwothree', '2021-04-18T23:51:28Z', 1, '2022-01-19 15:37:54', '2022-01-19 15:37:54', NULL, 4455),
(8, '1222', 'zaid.haroon@techxpert.io', 'zaid', 'haroon', NULL, NULL, NULL, '25-10-2022', 1, '2022-02-15 00:00:00', '2022-02-15 00:00:00', NULL, 2222),
(9, 'a6b9b50c-8433-4bdb-888d-6b243f47e1ed', 'muqba@gmail.com', 'Muhammad', 'Uqba', NULL, NULL, NULL, '28-11-2000', 1, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL, 538779),
(11, '55965b6a-4584-4d9c-9d4f-76bf35c01f63', 'test123@gmail.com', 'Muhammad', 'Uqba', NULL, NULL, NULL, '28-11-2000', 1, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL, 799268),
(12, '0881188c-71b0-4dc5-a742-ff496bfa6e14', 'test1234@gmail.com', 'Muhammad', 'Uqba', NULL, NULL, NULL, '28-11-2000', 1, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL, 412312),
(13, '3154f408-a682-47aa-8538-cc7af43d1cc7', 'muqbausman@gmail.com', 'Muhammad', 'Uqba', NULL, NULL, '$2a$10$O8qhV9O/kWH3ukrclm67Q.6qU2GEmt3.vAeNcWavVMANJoMIjKpdu', '28-11-2000', 1, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL, 933616);

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

--
-- Table structure for table `user_interests`
--

CREATE TABLE `user_interests` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `interest_id` int(11) NOT NULL,
  `createdAt` datetime NOT NULL,
  `updatedAt` datetime NOT NULL,
  `deletedAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `user_interests`
--

INSERT INTO `user_interests` (`id`, `user_id`, `interest_id`, `createdAt`, `updatedAt`, `deletedAt`) VALUES
(14, 6, 1, '2022-01-19 15:33:25', '2022-01-19 15:33:25', NULL),
(15, 6, 2, '2022-01-19 15:33:25', '2022-01-19 15:33:25', NULL),
(16, 6, 3, '2022-01-19 15:33:25', '2022-01-19 15:33:25', NULL),
(17, 7, 1, '2022-01-19 15:37:54', '2022-01-19 15:37:54', NULL),
(18, 7, 2, '2022-01-19 15:37:54', '2022-01-19 15:37:54', NULL),
(19, 7, 3, '2022-01-19 15:37:54', '2022-01-19 15:37:54', NULL),
(39, 13, 2, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL),
(40, 13, 3, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL),
(41, 13, 4, '2022-02-16 00:00:00', '2022-02-16 00:00:00', NULL);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `activities`
--
ALTER TABLE `activities`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uuid` (`uuid`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `created_by` (`created_by`);

--
-- Indexes for table `activity_interests`
--
ALTER TABLE `activity_interests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `activity_id` (`activity_id`),
  ADD KEY `interest_id` (`interest_id`);

--
-- Indexes for table `activity_invitations`
--
ALTER TABLE `activity_invitations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `activity_id` (`activity_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `sender_id` (`sender_id`);

--
-- Indexes for table `activity_messages`
--
ALTER TABLE `activity_messages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `activity_id` (`activity_id`),
  ADD KEY `sender_id` (`sender_id`);

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

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

--
-- Indexes for table `chatgroup_interests`
--
ALTER TABLE `chatgroup_interests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `chatgroup_id` (`chatgroup_id`),
  ADD KEY `interest_id` (`interest_id`);

--
-- Indexes for table `chatgroup_invitations`
--
ALTER TABLE `chatgroup_invitations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `group_id` (`group_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `sender_id` (`sender_id`);

--
-- Indexes for table `chatgroup_messages`
--
ALTER TABLE `chatgroup_messages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sent_by` (`sent_by`),
  ADD KEY `group_id` (`group_id`);

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

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

--
-- Indexes for table `friends_list`
--
ALTER TABLE `friends_list`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user1_id` (`user1_id`),
  ADD KEY `user2_id` (`user2_id`),
  ADD KEY `request_id` (`request_id`),
  ADD KEY `deleted_by` (`deleted_by`);

--
-- Indexes for table `friends_messages`
--
ALTER TABLE `friends_messages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `friends_id` (`friends_id`),
  ADD KEY `sent_by` (`sent_by`);

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

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

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

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

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

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

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

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

--
-- AUTO_INCREMENT for table `interests`
--
ALTER TABLE `interests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

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

--
-- AUTO_INCREMENT for table `user_interests`
--
ALTER TABLE `user_interests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=42;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `activities`
--
ALTER TABLE `activities`
  ADD CONSTRAINT `activities_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `activity_interests`
--
ALTER TABLE `activity_interests`
  ADD CONSTRAINT `activity_interests_ibfk_1` FOREIGN KEY (`activity_id`) REFERENCES `activities` (`id`),
  ADD CONSTRAINT `activity_interests_ibfk_2` FOREIGN KEY (`interest_id`) REFERENCES `interests` (`id`);

--
-- Constraints for table `activity_invitations`
--
ALTER TABLE `activity_invitations`
  ADD CONSTRAINT `activity_invitations_ibfk_1` FOREIGN KEY (`activity_id`) REFERENCES `activities` (`id`),
  ADD CONSTRAINT `activity_invitations_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `activity_invitations_ibfk_3` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`);

--
-- Constraints for table `activity_messages`
--
ALTER TABLE `activity_messages`
  ADD CONSTRAINT `activity_messages_ibfk_1` FOREIGN KEY (`activity_id`) REFERENCES `activities` (`id`),
  ADD CONSTRAINT `activity_messages_ibfk_2` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`);

--
-- Constraints for table `activity_users`
--
ALTER TABLE `activity_users`
  ADD CONSTRAINT `activity_users_ibfk_1` FOREIGN KEY (`activity_id`) REFERENCES `activities` (`id`),
  ADD CONSTRAINT `activity_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);

--
-- Constraints for table `chatgroups`
--
ALTER TABLE `chatgroups`
  ADD CONSTRAINT `chatgroups_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `chatgroup_interests`
--
ALTER TABLE `chatgroup_interests`
  ADD CONSTRAINT `chatgroup_interests_ibfk_1` FOREIGN KEY (`chatgroup_id`) REFERENCES `chatgroups` (`id`),
  ADD CONSTRAINT `chatgroup_interests_ibfk_2` FOREIGN KEY (`interest_id`) REFERENCES `interests` (`id`);

--
-- Constraints for table `chatgroup_invitations`
--
ALTER TABLE `chatgroup_invitations`
  ADD CONSTRAINT `chatgroup_invitations_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `chatgroups` (`id`),
  ADD CONSTRAINT `chatgroup_invitations_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `chatgroup_invitations_ibfk_3` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`);

--
-- Constraints for table `chatgroup_messages`
--
ALTER TABLE `chatgroup_messages`
  ADD CONSTRAINT `chatgroup_messages_ibfk_1` FOREIGN KEY (`sent_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `chatgroup_messages_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `chatgroups` (`id`);

--
-- Constraints for table `chatgroup_users`
--
ALTER TABLE `chatgroup_users`
  ADD CONSTRAINT `chatgroup_users_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `chatgroups` (`id`),
  ADD CONSTRAINT `chatgroup_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);

--
-- Constraints for table `friends_list`
--
ALTER TABLE `friends_list`
  ADD CONSTRAINT `friends_list_ibfk_1` FOREIGN KEY (`user1_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `friends_list_ibfk_2` FOREIGN KEY (`user2_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `friends_list_ibfk_3` FOREIGN KEY (`request_id`) REFERENCES `friend_requests` (`id`),
  ADD CONSTRAINT `friends_list_ibfk_4` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `friends_messages`
--
ALTER TABLE `friends_messages`
  ADD CONSTRAINT `friends_messages_ibfk_1` FOREIGN KEY (`friends_id`) REFERENCES `friends_list` (`id`),
  ADD CONSTRAINT `friends_messages_ibfk_2` FOREIGN KEY (`sent_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `friend_requests`
--
ALTER TABLE `friend_requests`
  ADD CONSTRAINT `friend_requests_ibfk_1` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `friend_requests_ibfk_2` FOREIGN KEY (`receiver_id`) REFERENCES `users` (`id`);

--
-- Constraints for table `user_interests`
--
ALTER TABLE `user_interests`
  ADD CONSTRAINT `user_interests_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `user_interests_ibfk_2` FOREIGN KEY (`interest_id`) REFERENCES `interests` (`id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
