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

START TRANSACTION;



--
-- Database: `webobiavi`
--

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

--
-- Table structure for table `ad_visits`
--

CREATE TABLE `ad_visits` (
  `ad_id` int(10) UNSIGNED NOT NULL,
  `visit_date` date NOT NULL,
  `unique_visits` int(7) NOT NULL,
  `total_visits` int(7) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `ad_visits`
--

INSERT INTO `ad_visits` (`ad_id`, `visit_date`, `unique_visits`, `total_visits`) VALUES
(26, '2020-05-15', 2, 6),
(26, '2020-05-20', 1, 1),
(26, '2020-05-21', 1, 1),
(26, '2020-06-12', 1, 1),
(27, '2020-05-15', 1, 2),
(37, '2020-05-15', 1, 5),
(38, '2020-05-15', 1, 3),
(56, '2020-05-21', 1, 1),
(76, '2020-06-12', 1, 1),
(117, '2020-06-12', 1, 1),
(117, '2020-06-18', 1, 1),
(128, '2020-06-18', 1, 1),
(128, '2020-06-19', 1, 1);

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

--
-- Table structure for table `ad_visits_temp`
--

CREATE TABLE `ad_visits_temp` (
  `id` int(10) UNSIGNED NOT NULL,
  `ad_id` int(10) UNSIGNED NOT NULL,
  `ip_address` varbinary(16) NOT NULL,
  `visit_time` int(11) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `ad_visits_temp`
--

INSERT INTO `ad_visits_temp` (`id`, `ad_id`, `ip_address`, `visit_time`) VALUES
(1, 26, 0x7f000001, 1591976940),
(2, 37, 0x7f000001, 1589544840),
(3, 38, 0x7f000001, 1589544540),
(4, 27, 0x7f000001, 1589544360),
(5, 56, 0x7f000001, 1590069480),
(6, 117, 0x7f000001, 1592489820),
(7, 76, 0x7f000001, 1591977060),
(8, 128, 0x7f000001, 1592569500);

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

--
-- Table structure for table `black_list_email`
--

CREATE TABLE `black_list_email` (
  `id` int(10) UNSIGNED NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `black_list_ip`
--

CREATE TABLE `black_list_ip` (
  `id` int(10) UNSIGNED NOT NULL,
  `ip_address` varbinary(16) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `node_id` int(10) UNSIGNED NOT NULL,
  `parent_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lft` smallint(5) UNSIGNED NOT NULL,
  `rgt` smallint(5) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`node_id`, `parent_id`, `name`, `lft`, `rgt`) VALUES
(1, 0, 'Категории', 1, 228),
(2, 1, 'Автo', 2, 41),
(3, 1, 'Електроника', 42, 59),
(4, 1, 'Мода', 60, 95),
(5, 1, 'Имоти', 96, 123),
(7, 5, 'Къщи', 97, 98),
(13, 5, 'Дворно място', 99, 100),
(14, 5, 'Ниви', 101, 102),
(45, 4, 'Мъжки дрехи', 61, 62),
(74, 5, 'Гаражи', 103, 112),
(75, 74, 'Панелни', 104, 105),
(76, 74, 'Тухлени', 106, 107),
(77, 74, 'Мобилни', 108, 109),
(78, 74, 'Паркомясто', 110, 111),
(126, 5, 'Апартаменти', 113, 122),
(127, 126, '1 стайни', 114, 115),
(128, 126, '2 стайни', 116, 117),
(129, 126, 'многостайни', 118, 119),
(130, 126, 'мезонети', 120, 121),
(133, 2, 'Автомобили и джипове', 3, 4),
(134, 2, 'Автобуси и бусове', 5, 6),
(135, 2, 'Мотоциклети и мототехника', 7, 8),
(136, 2, 'Камиони', 9, 10),
(148, 3, 'ТВ', 43, 52),
(149, 3, 'Компютри', 53, 54),
(150, 3, 'Мобилни телефони', 55, 56),
(151, 3, 'Аудио системи', 57, 58),
(152, 148, 'LED', 44, 45),
(153, 148, 'LCD', 46, 47),
(154, 148, 'Plasma', 48, 49),
(155, 148, 'QLED', 50, 51),
(156, 1, 'Дом и Градина', 124, 125),
(157, 1, 'Животни', 126, 127),
(158, 1, 'Работа', 128, 153),
(159, 1, 'Туризъм', 154, 155),
(160, 1, 'Услуги', 156, 197),
(161, 1, 'Други', 198, 199),
(162, 4, 'Женски дрехи', 63, 64),
(163, 4, 'Мъжки обувки', 65, 66),
(164, 4, 'Женски обувки', 67, 68),
(165, 4, 'Парфюми', 69, 76),
(166, 4, 'Козметика', 77, 82),
(167, 165, 'Женски', 70, 71),
(168, 165, 'Мъжки', 72, 73),
(169, 165, 'Unisex', 74, 75),
(171, 166, 'Мъжка', 78, 79),
(172, 166, 'Женска', 80, 81),
(173, 4, 'Бижута', 83, 84),
(174, 4, 'Часовници', 85, 90),
(175, 174, 'Мъжки', 86, 87),
(176, 174, 'Женски', 88, 89),
(177, 4, 'Аксесоари', 91, 92),
(178, 4, 'Подаръци', 93, 94),
(179, 1, 'Бебета и деца', 200, 227),
(180, 179, 'Бебета', 201, 214),
(181, 179, 'Деца', 215, 226),
(182, 180, 'Дрехи', 202, 203),
(183, 180, 'Обувки', 204, 205),
(184, 180, 'Играчки', 206, 207),
(185, 180, 'Аксесоари', 208, 209),
(186, 180, 'Обзавеждане', 210, 211),
(187, 181, 'Дрехи', 216, 217),
(188, 181, 'Обувки', 218, 219),
(189, 181, 'Аксесоари', 220, 221),
(190, 181, 'Обзавеждане', 222, 223),
(191, 181, 'Играчки', 224, 225),
(192, 180, 'За разходка', 212, 213),
(193, 160, 'Курсове и обучения', 157, 158),
(194, 160, 'Почистване', 159, 160),
(195, 160, 'Строително-ремонтни', 161, 162),
(196, 160, 'Транспортни', 163, 164),
(197, 160, 'Финансови', 165, 166),
(198, 160, 'Правни', 167, 168),
(199, 160, 'Легализация и преводи', 169, 170),
(200, 160, 'Събития и кетъринг', 171, 172),
(201, 160, 'Болногледачки', 173, 174),
(202, 160, 'Детегледачки', 175, 176),
(203, 160, 'Фризьорски и козметични', 177, 178),
(204, 160, 'Охранителни', 179, 180),
(205, 160, 'Ясновидство', 181, 182),
(206, 160, 'Ремонт Компютри и офис техника', 183, 184),
(207, 160, 'Занаятчийски', 185, 186),
(208, 160, 'Ремонт бяла и черна техника', 187, 188),
(209, 160, 'Ремонт мобилни телефони', 189, 190),
(210, 160, 'Копирни услуги', 191, 192),
(211, 160, 'Траурни услуги', 193, 194),
(212, 160, 'Други', 195, 196),
(213, 158, 'Строителство', 129, 130),
(214, 158, 'Обслужващ персонал', 131, 132),
(215, 158, 'Икономика', 133, 134),
(216, 158, 'Финанси', 135, 136),
(217, 158, 'ИТ Сектор', 137, 138),
(218, 158, 'Право', 139, 140),
(219, 158, 'Производство', 141, 142),
(220, 158, 'Надомна работа', 143, 144),
(221, 158, 'Администрация', 145, 146),
(222, 158, 'Охранителна дейност', 147, 148),
(223, 158, 'Медицина', 149, 150),
(224, 158, 'Мениджмънт', 151, 152),
(225, 2, 'Каравани и кемпери', 11, 12),
(226, 2, 'Специализирана техника', 13, 14),
(227, 2, 'Ремаркета', 15, 16),
(228, 2, 'Воден транспорт', 17, 40),
(229, 228, 'Моторна яхта', 18, 19),
(230, 228, 'Джет', 20, 21),
(231, 228, 'Ветроходна лодка', 22, 23),
(232, 228, 'Лодка', 24, 25),
(233, 228, 'Надуваема лодка', 26, 27),
(234, 228, 'Двигатели', 28, 39),
(235, 234, 'Suzuki', 29, 30),
(236, 234, 'Yamaha', 31, 32),
(237, 234, 'Honda', 33, 34),
(238, 234, 'Mercury', 35, 36),
(239, 234, 'Други', 37, 38);

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

--
-- Table structure for table `listings`
--

CREATE TABLE `listings` (
  `listing_id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL,
  `location_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `title` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `phone` varchar(20) NOT NULL,
  `price` decimal(10,2) UNSIGNED NOT NULL,
  `currency` enum('bgn','eur','usd') NOT NULL,
  `ip_address` varbinary(16) NOT NULL,
  `date_created` datetime NOT NULL,
  `date_modified` datetime NOT NULL,
  `active` tinyint(3) NOT NULL,
  `sponsored` tinyint(3) NOT NULL,
  `blocked` tinyint(3) UNSIGNED NOT NULL,
  `bad_words` tinyint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `listings`
--

INSERT INTO `listings` (`listing_id`, `category_id`, `location_id`, `user_id`, `title`, `description`, `phone`, `price`, `currency`, `ip_address`, `date_created`, `date_modified`, `active`, `sponsored`, `blocked`, `bad_words`) VALUES
(26, 2, 16, 23, 'продавам касети', 'prodawam porno kassetki sex', '091298328173', '10.00', 'bgn', 0x7f000001, '2020-04-14 19:02:25', '2020-04-14 19:07:07', 1, 0, 1, 1),
(27, 148, 24, 23, 'sex филми', 'jikgaz', '0892213213', '12.00', 'bgn', 0x7f000001, '2020-04-14 19:05:38', '2020-05-20 18:29:38', 0, 0, 0, 1),
(72, 148, 37, 23, 'TВ \"Респром\"', 'хуиасд', '0912939', '19.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(73, 148, 34, 23, 'test picx213', 'test again22 132313212', '0912939', '23.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(74, 152, 34, 23, 'Tелевизор 3', 'test again22 LED hubaw', '0912939', '550.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-28 13:33:51', 1, 0, 0, 0),
(75, 148, 34, 23, 'телевизор 4', 'gagavhs', '0912939', '70.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(76, 148, 41, 23, 'телевизор Sony', 'uchr', '0912939', '110.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(77, 148, 41, 23, 'ТВ Панасоник', 'uchrасдсадсдадса', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(78, 148, 22, 23, 'Продавам Телевизори', 'всички марки', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(79, 148, 22, 24, 'LG televizor', '60 incha', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(80, 148, 20, 24, 'Novi televizori', 'vtora ryka', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(81, 148, 16, 23, 'TV prodawam ', 'novi', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(82, 148, 16, 23, 'TV Grundik', 'Dobromir - star e televizora', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(83, 148, 36, 80, 'TV Now', 'gagacha - star e televizora', '0912939', '22.00', 'bgn', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(112, 13, 16, 23, 'nonbadword тест', '2 non badword тест', '213444', '123.00', 'bgn', 0x7f000001, '2020-06-02 17:22:30', '2020-06-02 17:27:36', 1, 0, 0, 0),
(113, 213, 16, 23, 'Обява за работа', 'Търся работа upd', '0891298389', '1.00', 'bgn', 0x7f000001, '2020-06-02 17:33:59', '2020-06-02 17:43:56', 1, 0, 0, 0),
(114, 213, 19, 25, 'Обява за работа 2', 'Търся работа upd2', '09123091290', '1.00', 'bgn', 0x7f000001, '2020-06-02 17:33:59', '2020-06-02 17:43:56', 1, 0, 0, 0),
(115, 133, 17, 23, 'Продавам BMW', 'bmw-то е счупено', '091290309312', '1000.00', 'bgn', 0x7f000001, '2020-06-02 17:47:34', '2020-06-02 17:47:34', 1, 0, 0, 0),
(116, 14, 19, 23, 'продавам земя', '1 декар', '123231213312', '1000.00', 'eur', 0x7f000001, '2020-06-02 17:48:04', '2020-06-02 17:48:04', 1, 0, 0, 0),
(117, 2, 42, 80, 'правя услуги', 'внос износ и други услуги', '091298328173', '10.00', 'usd', 0x7f000001, '2020-04-14 19:02:25', '2020-04-14 19:07:07', 1, 0, 1, 1),
(118, 45, 21, 24, 'продавам кокошки и петки', 'ассадсадса адса дссадсаддасдсадассад', '012939', '44.00', 'bgn', 0x7f000001, '2020-05-15 14:05:00', '2020-05-15 14:05:00', 1, 0, 0, 0),
(119, 2, 34, 25, 'продавам касети и касетофон', 'prodawam audio kaseti stari', '091298328173', '10.00', 'usd', 0x7f000001, '2020-04-14 19:02:25', '2020-04-14 19:07:07', 1, 0, 1, 1),
(120, 148, 24, 23, 'продажба на прасенца', 'продавам малки прасенца', '0892213213', '100.00', 'eur', 0x7f000001, '2020-04-14 19:05:38', '2020-05-20 18:29:38', 0, 0, 0, 1),
(121, 148, 16, 76, 'киноскоп телевизор', '213213321uchr', '0912939', '20.00', 'usd', 0x7f000001, '2020-05-18 17:25:15', '2020-05-21 16:46:11', 1, 0, 0, 0),
(122, 213, 19, 76, 'Обява за работа', 'Търся работа като машинист на багер', '0891298389', '1000.00', 'eur', 0x7f000001, '2020-06-02 17:33:59', '2020-06-02 17:43:56', 1, 0, 0, 0),
(123, 14, 40, 25, 'продавам земя и животни евтино', '1 декар и 20 магарета + 30 кокошки', '123231213312', '2000.00', 'usd', 0x7f000001, '2020-06-02 17:48:04', '2020-06-02 17:48:04', 1, 0, 0, 0),
(124, 133, 23, 24, 'Продавам Ауди 80', 'става за къща за куче ', '091290309312', '200.00', 'bgn', 0x7f000001, '2020-06-02 17:47:34', '2020-06-02 17:47:34', 1, 0, 0, 0),
(126, 2, 16, 24, 'правя ремонтни услуги', 'ВиК и други ', '091298328173', '50.00', 'bgn', 0x7f000001, '2020-04-14 19:02:25', '2020-04-14 19:07:07', 1, 0, 1, 1),
(127, 133, 16, 81, 'gagacha grebi', 'gagacha grebi', '0981283828', '30.00', 'bgn', 0x7f000001, '2020-06-03 18:04:56', '2020-06-03 18:04:56', 1, 0, 0, 0),
(128, 133, 16, 81, 'продава бутилки за бира - 500мл', 'saddsasad', '08912', '11.00', 'bgn', 0x7f000001, '2020-06-03 18:26:58', '2020-06-03 18:26:58', 1, 0, 0, 0),
(129, 13, 19, 81, 'snimki', 'dsadsa', '0891232132', '22.00', 'bgn', 0x7f000001, '2020-06-03 18:49:58', '2020-06-03 18:49:58', 1, 0, 0, 0),
(130, 156, 17, 81, 'My best listing', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', '0912939321', '22.00', 'bgn', 0x7f000001, '2020-06-03 18:52:05', '2020-06-03 19:02:28', 1, 0, 0, 0);

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

--
-- Table structure for table `listings_archive_2020`
--

CREATE TABLE `listings_archive_2020` (
  `listing_id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL,
  `location_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `title` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `phone` varchar(20) NOT NULL,
  `price` decimal(10,2) UNSIGNED NOT NULL,
  `currency` varchar(10) NOT NULL,
  `ip_address` varbinary(16) NOT NULL,
  `date_created` datetime NOT NULL,
  `date_modified` datetime NOT NULL,
  `active` tinyint(3) NOT NULL,
  `sponsored` tinyint(3) NOT NULL,
  `blocked` tinyint(3) UNSIGNED NOT NULL,
  `bad_words` tinyint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `listings_archive_2020`
--

INSERT INTO `listings_archive_2020` (`listing_id`, `category_id`, `location_id`, `user_id`, `title`, `description`, `phone`, `price`, `currency`, `ip_address`, `date_created`, `date_modified`, `active`, `sponsored`, `blocked`, `bad_words`) VALUES
(1, 133, 21, 23, 'Jikarr', 'sad', '213213213', '22.00', 'bgn', 0x7f000001, '2020-06-02 15:49:37', '2020-06-02 15:49:51', 1, 0, 0, 0),
(2, 7, 16, 23, 'jikagaz', 'uderi', '12', '332.00', 'bgn', 0x7f000001, '2020-06-02 15:47:01', '2020-06-02 15:47:01', 1, 0, 0, 0),
(3, 13, 16, 23, 'udri', 'sad', '123', '213.00', 'bgn', 0x7f000001, '2020-06-02 15:45:09', '2020-06-02 15:45:09', 1, 0, 0, 0),
(4, 45, 18, 23, 'Horogribi', 'tst we', '09891238287', '33.00', 'bgn', 0x7f000001, '2020-06-02 15:43:27', '2020-06-02 15:43:27', 1, 0, 0, 0);

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

--
-- Table structure for table `listings_images`
--

CREATE TABLE `listings_images` (
  `id` int(10) UNSIGNED NOT NULL,
  `listing_id` int(10) UNSIGNED NOT NULL,
  `img_src` varchar(128) NOT NULL,
  `disp_order` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `listings_images`
--

INSERT INTO `listings_images` (`id`, `listing_id`, `img_src`, `disp_order`) VALUES
(102, 130, 'assets/images/listings/130-js-before-after.png', 1),
(103, 130, 'assets/images/listings/130-before.png', 2);

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

--
-- Table structure for table `listings_options`
--

CREATE TABLE `listings_options` (
  `id` int(10) UNSIGNED NOT NULL,
  `listing_id` int(10) UNSIGNED NOT NULL,
  `option_id` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `listings_options`
--

INSERT INTO `listings_options` (`id`, `listing_id`, `option_id`) VALUES
(1, 26, 0),
(2, 27, 7),
(3, 27, 12),
(9, 28, 3),
(14, 37, 6),
(15, 37, 12),
(16, 47, 0),
(17, 48, 0),
(18, 49, 0),
(19, 74, 0),
(36, 105, 0),
(37, 109, 0),
(43, 112, 0),
(44, 130, 0);

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

--
-- Table structure for table `locations`
--

CREATE TABLE `locations` (
  `node_id` int(10) UNSIGNED NOT NULL,
  `parent_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lft` smallint(5) UNSIGNED NOT NULL,
  `rgt` smallint(5) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `locations`
--

INSERT INTO `locations` (`node_id`, `parent_id`, `name`, `lft`, `rgt`) VALUES
(1, 0, 'Населено място', 1, 36),
(16, 1, 'София', 2, 15),
(17, 1, 'Пловдив', 16, 17),
(18, 1, 'Варна', 18, 19),
(19, 1, 'Бургас', 20, 21),
(20, 1, 'Ямбол', 22, 31),
(21, 1, 'Сливен', 32, 33),
(22, 1, 'Русе', 34, 35),
(23, 16, 'Пазарджик', 3, 8),
(24, 23, 'село Гошево', 4, 5),
(34, 20, 'село Трънково', 23, 24),
(35, 20, 'село Ботево', 25, 26),
(36, 20, 'село Роза', 27, 30),
(37, 36, 'тест 1', 28, 29),
(38, 23, 'asd', 6, 7),
(40, 16, 'Правец', 9, 10),
(41, 16, 'Етрополе', 11, 12),
(42, 16, 'Нонсенс', 13, 14);

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

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

CREATE TABLE `messages` (
  `message_id` int(10) UNSIGNED NOT NULL,
  `conversation_id` int(10) UNSIGNED NOT NULL,
  `from_user_id` int(10) UNSIGNED NOT NULL,
  `to_user_id` int(10) UNSIGNED NOT NULL,
  `message` text NOT NULL,
  `date_created` datetime NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'unread'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `messages`
--

INSERT INTO `messages` (`message_id`, `conversation_id`, `from_user_id`, `to_user_id`, `message`, `date_created`, `status`) VALUES
(26, 1, 23, 81, 'zdrasti kiro!', '2020-06-19 18:20:00', 'read'),
(27, 1, 81, 23, 'здрасти Иване, с какво може да ти помогна ?', '2020-06-19 18:22:26', 'read'),
(28, 1, 81, 23, 'Кажи и ще видим какво можем да направим', '2020-06-19 18:23:15', 'read'),
(30, 1, 81, 23, 'urch', '2020-06-19 18:29:45', 'read'),
(31, 1, 23, 81, 'Udri bace, dovechera shte julem kaldja', '2020-06-19 18:30:51', 'read'),
(32, 1, 23, 81, 'Gagach grebi', '2020-06-19 18:31:00', 'read'),
(33, 1, 23, 81, 'ontrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \"de Finibus Bonorum et Malorum\" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, \"Lorem ipsum dolor sit amet..\", comes from a line in section 1.10.32.', '2020-06-19 18:31:21', 'read'),
(34, 1, 81, 23, 'Sending...', '2020-06-19 18:35:38', 'read'),
(35, 1, 81, 23, 'bat kiro greben ima li ?', '2020-06-19 18:36:48', 'read'),
(36, 1, 23, 81, 'Kwo stava wikash li neshto', '2020-06-19 18:40:31', 'read'),
(37, 1, 23, 81, 'Ne chuvash mai petela?', '2020-06-19 18:56:47', 'read');

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

--
-- Table structure for table `messages_conv_list_link`
--

CREATE TABLE `messages_conv_list_link` (
  `conversation_id` int(10) UNSIGNED NOT NULL,
  `listing_id` int(10) UNSIGNED NOT NULL,
  `from_user_id` int(10) UNSIGNED NOT NULL,
  `to_user_id` int(10) UNSIGNED NOT NULL,
  `status` tinyint(1) NOT NULL COMMENT '1 = active, 0 = disabled',
  `created_at` datetime NOT NULL COMMENT 'is necesary???'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `messages_conv_list_link`
--

INSERT INTO `messages_conv_list_link` (`conversation_id`, `listing_id`, `from_user_id`, `to_user_id`, `status`, `created_at`) VALUES
(1, 128, 23, 81, 1, '2020-06-17 15:33:32');

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

--
-- Table structure for table `options`
--

CREATE TABLE `options` (
  `node_id` int(10) UNSIGNED NOT NULL,
  `parent_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lft` smallint(5) UNSIGNED NOT NULL,
  `rgt` smallint(5) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `options`
--

INSERT INTO `options` (`node_id`, `parent_id`, `name`, `lft`, `rgt`, `category_id`) VALUES
(1, 0, 'Опции', 1, 18, 1),
(2, 1, 'Цвят', 2, 5, 5),
(3, 2, 'Зелен', 3, 4, 5),
(4, 2, 'Червен', 4, 5, 5),
(5, 1, 'Марка', 6, 10, 2),
(6, 5, 'BMW', 6, 7, 2),
(7, 5, 'AUDI', 7, 8, 2),
(8, 5, 'Opel', 8, 9, 2),
(9, 5, 'VW', 9, 10, 2),
(10, 1, 'Година', 10, 15, 2),
(11, 10, '2010', 11, 12, 2),
(12, 10, '2011', 12, 13, 2),
(13, 10, '2012', 13, 14, 2),
(14, 10, '2013', 14, 15, 2);

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

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `perm_id` int(10) UNSIGNED NOT NULL,
  `perm_description` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `permissions`
--

INSERT INTO `permissions` (`perm_id`, `perm_description`) VALUES
(10, 'can manage perms'),
(11, 'can manage users'),
(12, 'can create admin');

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

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `role_id` int(10) UNSIGNED NOT NULL,
  `role_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`role_id`, `role_name`) VALUES
(10, 'SuperAdmin');

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

--
-- Table structure for table `role_perm_link`
--

CREATE TABLE `role_perm_link` (
  `role_id` int(10) UNSIGNED NOT NULL,
  `perm_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `role_perm_link`
--

INSERT INTO `role_perm_link` (`role_id`, `perm_id`) VALUES
(10, 10),
(10, 11),
(10, 12);

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

--
-- Table structure for table `searches`
--

CREATE TABLE `searches` (
  `search_query` varchar(255) NOT NULL,
  `results_count` int(10) UNSIGNED NOT NULL,
  `searches_count` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `searches`
--

INSERT INTO `searches` (`search_query`, `results_count`, `searches_count`) VALUES
('989', 0, 1),
('dasdsa', 0, 3),
('sex', 2, 6),
('test', 0, 1),
('касет', 1, 5),
('касети', 1, 2),
('касетки', 0, 2),
('кокошки', 1, 2),
('продавам', 2, 15),
('продавам касети', 1, 9),
('тест', 0, 2),
('тест 123', 0, 3);

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

--
-- Table structure for table `stop_words`
--

CREATE TABLE `stop_words` (
  `id` int(10) NOT NULL,
  `word` varchar(64) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `stop_words`
--

INSERT INTO `stop_words` (`id`, `word`) VALUES
(1, 'sex'),
(86, 'porno');

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

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

CREATE TABLE `users` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `first_name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  `username` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  `pwd` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` tinyint(3) UNSIGNED NOT NULL,
  `created` int(10) UNSIGNED NOT NULL,
  `last_login` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `users` (`user_id`, `first_name`, `last_name`, `username`, `pwd`, `role`, `status`, `created`, `last_login`) VALUES
(1, 'Admin', 'Admin', 'admin', '$2y$10$NqLtD.Sz9bOYCdpDhswtW.gZRmgck7jer1KFfCQLNhfdUIiaVBq3.', 'admin', 1, 1542664093, 1591621247),
(23, 'Иван', 'Балсамаджиев', 'balsama@abv.bg', '$2y$10$6BZuGuR6Dj9KKB2QQF/3MueryraSVIa7zE8egkuqzV21dlI6YvMoi', 'user', 1, 1568122948, 1592582640),
(24, 'Jelko', 'jelkov', 'jelk@abv.bg', '$2y$10$eqnzVj04SQyNsvBVO1m8DO9F5DltKIL5n.jdfij9cjM3jlOvV8y9.', 'user', 1, 1571047045, 1571047045),
(25, 'Stancho', 'Georgiev', 'stg11@abv.bg', '$2y$10$Ccwaz9D93XVRBqBrwYlFn.eef3hcdFQzkRjMzsOmhAHS3tCDpN6U6', 'user', 1, 1571047200, 1571047200),
(26, 'Karo', 'Karov', 'karov@abv.bg', '$2y$10$SibU6nFBGgSgHbGDorSnROnX/J3A32MeTINC13z3z/mdQQ2xIO8Vm', 'user', 1, 1571052880, 1571052880),
(27, 'Vasi', 'Kolev', 'vasilenwebso@gmail.com', '$2y$10$RjeLuZl23XeJS2D1Y/4/KuC8EqJ40MyzkH09o63q4lsr7L7wCCnGq', 'user', 1, 1584546726, 1587735922),
(76, 'teeasd', 'teas', 'awqvfwkrqpz_1584962447@tfbnw.net', '$2y$10$lF1UlFMne5HivsaF9v3Kn.ZIKgriSPnJvyrkAWFuFzpOFFogvBED6', 'user', 1, 1585066758, 1585066819),
(80, 'Ava', 'Occhinoescu', 'wqvfwkrqpz_1584962447@tfbnw.net', '$2y$10$ZGMJTtQA/SzkhQWf.3Muqu6soqU0UYzG9Gbi.P0WhIW5uFyusOH5K', 'user', 1, 1585125221, 1585131183),
(81, 'Kиро', 'Киров', 'kirov@abv.bg', '$2y$10$tFpDwT4ZeuS5B85hs7cRseBwnybNmbJyCryaG2BSb6PpFXhyM.roi', 'user', 1, 1589470033, 1592582224);

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

--
-- Table structure for table `users_auth`
--

CREATE TABLE `users_auth` (
  `id` binary(20) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `validator` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `expires` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `users_auth`
--

INSERT INTO `users_auth` (`id`, `user_id`, `validator`, `expires`) VALUES
(0x2a99a99264bb9304b116aef44e585ff202a2790b, 1, '2809085f44327f56095864cfb4efbcd7cfa6ad891edfa0741bac8461966bb75a', 1591707647),
(0x6ab93df9e128b12793e15e5aeac5653def3c8831, 27, '88f0ebcc0c0d01828586eb48e5022cbf450e7274243667fae99a8f47a7f89f30', 1587822322),
(0xba0c607229c190869d28f691b9a64c0b1080d3be, 26, 'c2b1ec1dda4e6e643c5135befda5bfacb3def5f8e0b759e2f2b35929c3c79842', 1571139280);

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

--
-- Table structure for table `users_auth_ip`
--

CREATE TABLE `users_auth_ip` (
  `id` int(11) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `ip_address` varbinary(16) NOT NULL,
  `date` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `users_auth_ip`
--

INSERT INTO `users_auth_ip` (`id`, `user_id`, `ip_address`, `date`) VALUES
(2, 23, 0x9600000a, 1587416400),
(3, 23, 0x8a0c0c01, 1587416400),
(4, 24, 0x9600000b, 1587416400),
(5, 24, 0x8a0b0c01, 1587416400),
(6, 23, 0x7f000001, 1592514000),
(7, 81, 0x7f000001, 1592514000);

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

--
-- Table structure for table `users_blocked`
--

CREATE TABLE `users_blocked` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `blocked` tinyint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `users_blocked`
--

INSERT INTO `users_blocked` (`id`, `user_id`, `blocked`) VALUES
(1, 23, 1);

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

--
-- Table structure for table `users_data`
--

CREATE TABLE `users_data` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `phone` varchar(20) NOT NULL,
  `region` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `users_data`
--

INSERT INTO `users_data` (`id`, `user_id`, `phone`, `region`) VALUES
(1, 23, '08972374732', 'Търголяс'),
(15, 81, '123', 'кърджали');

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

--
-- Table structure for table `user_role_link`
--

CREATE TABLE `user_role_link` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `role_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `user_role_link`
--

INSERT INTO `user_role_link` (`user_id`, `role_id`) VALUES
(1, 10);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `ad_visits`
--
ALTER TABLE `ad_visits`
  ADD PRIMARY KEY (`ad_id`,`visit_date`);

--
-- Indexes for table `ad_visits_temp`
--
ALTER TABLE `ad_visits_temp`
  ADD PRIMARY KEY (`id`),
  ADD KEY `ad_id` (`ad_id`);

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

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

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`node_id`),
  ADD UNIQUE KEY `parent_id` (`parent_id`,`name`),
  ADD KEY `lft` (`lft`),
  ADD KEY `rgt` (`rgt`) USING BTREE;

--
-- Indexes for table `listings`
--
ALTER TABLE `listings`
  ADD PRIMARY KEY (`listing_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `location_id` (`location_id`);
ALTER TABLE `listings` ADD FULLTEXT KEY `title` (`title`,`description`);

--
-- Indexes for table `listings_archive_2020`
--
ALTER TABLE `listings_archive_2020`
  ADD PRIMARY KEY (`listing_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `location_id` (`location_id`);

--
-- Indexes for table `listings_images`
--
ALTER TABLE `listings_images`
  ADD PRIMARY KEY (`id`),
  ADD KEY `listing_id` (`listing_id`);

--
-- Indexes for table `listings_options`
--
ALTER TABLE `listings_options`
  ADD PRIMARY KEY (`id`),
  ADD KEY `listing_id` (`listing_id`),
  ADD KEY `option_id` (`option_id`);

--
-- Indexes for table `locations`
--
ALTER TABLE `locations`
  ADD PRIMARY KEY (`node_id`),
  ADD UNIQUE KEY `parent_id` (`parent_id`,`name`),
  ADD KEY `lft` (`lft`) USING BTREE,
  ADD KEY `rgt` (`rgt`) USING BTREE;

--
-- Indexes for table `messages`
--
ALTER TABLE `messages`
  ADD PRIMARY KEY (`message_id`),
  ADD KEY `conversation_id` (`conversation_id`),
  ADD KEY `from_user_id` (`from_user_id`),
  ADD KEY `to_user_id` (`to_user_id`);

--
-- Indexes for table `messages_conv_list_link`
--
ALTER TABLE `messages_conv_list_link`
  ADD PRIMARY KEY (`conversation_id`),
  ADD KEY `listing_id` (`listing_id`),
  ADD KEY `from_user_id` (`from_user_id`),
  ADD KEY `to_user_id` (`to_user_id`);

--
-- Indexes for table `options`
--
ALTER TABLE `options`
  ADD PRIMARY KEY (`node_id`),
  ADD UNIQUE KEY `parent_id` (`parent_id`,`name`),
  ADD KEY `lft` (`lft`),
  ADD KEY `rgt` (`rgt`),
  ADD KEY `category_id` (`category_id`) USING BTREE;

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`perm_id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`role_id`);

--
-- Indexes for table `role_perm_link`
--
ALTER TABLE `role_perm_link`
  ADD KEY `perm_id` (`perm_id`),
  ADD KEY `role_id` (`role_id`);

--
-- Indexes for table `searches`
--
ALTER TABLE `searches`
  ADD UNIQUE KEY `search_query` (`search_query`);

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

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

--
-- Indexes for table `users_auth`
--
ALTER TABLE `users_auth`
  ADD PRIMARY KEY (`id`),
  ADD KEY `uid` (`user_id`) USING BTREE;

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

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

--
-- Indexes for table `users_data`
--
ALTER TABLE `users_data`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`),
  ADD UNIQUE KEY `user_id_2` (`user_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `user_role_link`
--
ALTER TABLE `user_role_link`
  ADD KEY `user_id` (`user_id`),
  ADD KEY `role` (`role_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
  MODIFY `node_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=240;

--
-- AUTO_INCREMENT for table `listings`
--
ALTER TABLE `listings`
  MODIFY `listing_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=131;

--
-- AUTO_INCREMENT for table `listings_archive_2020`
--
ALTER TABLE `listings_archive_2020`
  MODIFY `listing_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

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

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

--
-- AUTO_INCREMENT for table `locations`
--
ALTER TABLE `locations`
  MODIFY `node_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43;

--
-- AUTO_INCREMENT for table `messages`
--
ALTER TABLE `messages`
  MODIFY `message_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38;

--
-- AUTO_INCREMENT for table `messages_conv_list_link`
--
ALTER TABLE `messages_conv_list_link`
  MODIFY `conversation_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `options`
--
ALTER TABLE `options`
  MODIFY `node_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `perm_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `role_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `stop_words`
--
ALTER TABLE `stop_words`
  MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=83;

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `listings`
--
ALTER TABLE `listings`
  ADD CONSTRAINT `listings_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `listings_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `categories` (`node_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `listings_ibfk_3` FOREIGN KEY (`location_id`) REFERENCES `locations` (`node_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `listings_images`
--
ALTER TABLE `listings_images`
  ADD CONSTRAINT `listings_images_ibfk_1` FOREIGN KEY (`listing_id`) REFERENCES `listings` (`listing_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `messages`
--
ALTER TABLE `messages`
  ADD CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`conversation_id`) REFERENCES `messages_conv_list_link` (`conversation_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `messages_ibfk_2` FOREIGN KEY (`from_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `messages_ibfk_3` FOREIGN KEY (`to_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `messages_conv_list_link`
--
ALTER TABLE `messages_conv_list_link`
  ADD CONSTRAINT `messages_conv_list_link_ibfk_1` FOREIGN KEY (`listing_id`) REFERENCES `listings` (`listing_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `messages_conv_list_link_ibfk_2` FOREIGN KEY (`from_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `messages_conv_list_link_ibfk_3` FOREIGN KEY (`to_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `role_perm_link`
--
ALTER TABLE `role_perm_link`
  ADD CONSTRAINT `role_perm_link_cnstr_1` FOREIGN KEY (`perm_id`) REFERENCES `permissions` (`perm_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `role_perm_link_cnstr_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `users_auth_ip`
--
ALTER TABLE `users_auth_ip`
  ADD CONSTRAINT `users_auth_ip_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `users_blocked`
--
ALTER TABLE `users_blocked`
  ADD CONSTRAINT `users_blocked_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);

--
-- Constraints for table `users_data`
--
ALTER TABLE `users_data`
  ADD CONSTRAINT `users_data_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `user_role_link`
--
ALTER TABLE `user_role_link`
  ADD CONSTRAINT `user_role_link_cnstr_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `user_role_link_cnstr_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

