-- 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),
(27, '2020-05-15', 1, 2),
(37, '2020-05-15', 1, 5),
(38, '2020-05-15', 1, 3);

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

--
-- 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, 1589543460),
(2, 37, 0x7f000001, 1589544840),
(3, 38, 0x7f000001, 1589544540),
(4, 27, 0x7f000001, 1589544360);

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

--
-- 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, 60),
(2, 1, 'Автo', 2, 11),
(3, 1, 'Електроника', 12, 21),
(4, 1, 'Мода', 22, 31),
(5, 1, 'Имоти', 32, 59),
(7, 5, 'Къщи', 33, 34),
(13, 5, 'Дворно място', 35, 36),
(14, 5, 'Ниви', 37, 38),
(45, 4, 'Мъжка мода', 23, 24),
(69, 4, 'Женска мода', 25, 26),
(74, 5, 'Гаражи', 39, 48),
(75, 74, 'Панелни', 40, 41),
(76, 74, 'Тухлени', 42, 43),
(77, 74, 'Мобилни', 44, 45),
(78, 74, 'Паркомясто', 46, 47),
(126, 5, 'Апартаменти', 49, 58),
(127, 126, '1 стайни', 50, 51),
(128, 126, '2 стайни', 52, 53),
(129, 126, 'многостайни', 54, 55),
(130, 126, 'мезонети', 56, 57),
(131, 4, 'Детска мода', 27, 28),
(132, 4, 'бебешки', 29, 30),
(133, 2, 'Коли', 3, 4),
(134, 2, 'Бусове', 5, 6),
(135, 2, 'Мотори', 7, 8),
(136, 2, 'Камиони', 9, 10),
(148, 3, 'ТВ', 13, 14),
(149, 3, 'Компютри', 15, 16),
(150, 3, 'Мобилни телефони', 17, 18),
(151, 3, 'Аудио системи', 19, 20);

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

--
-- 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` 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`
--

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', '', '2020-04-14 19:02:25', '2020-04-14 19:07:07', 1, 0, 1, 1),
(27, 5, 16, 23, 'sex филми', 'падосо', '0892213213', '12.00', 'bgn', 0x7f000001, '2020-04-14 19:05:38', '2020-04-14 19:05:38', 1, 0, 0, 1),
(56, 45, 19, 81, 'продавам кокошки', 'ассадса', '012939', '22.00', 'bgn', 0x7f000001, '2020-05-15 14:05:00', '2020-05-15 14:05:00', 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;

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

--
-- 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;

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

--
-- 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);

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

--
-- 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 `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 `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, 1589537527),
(23, 'Ivan', 'Balsamadjiev', 'balsama@abv.bg', '$2y$10$6BZuGuR6Dj9KKB2QQF/3MueryraSVIa7zE8egkuqzV21dlI6YvMoi', 'user', 1, 1568122948, 1589810744),
(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, 'kiro', 'kirov', 'kirov@abv.bg', '$2y$10$tFpDwT4ZeuS5B85hs7cRseBwnybNmbJyCryaG2BSb6PpFXhyM.roi', 'user', 1, 1589470033, 1589540419);

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

--
-- 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
(0x026ecb70a9e7d7666361a2229376031b46658f12, 23, '78c5d00a061d01e2ccf1d8566835dacdc3871b1cce5120060c88090735d258a8', 1589897144),
(0x1644e635bc6c481e811c6bc905d1174ae8b5fb78, 81, '2333a5bb43c8031e3aa28ec1a5c931c4c7b9a6fc87b6f8f4300f51d53aa17115', 1589626819),
(0x26a06c2ce98cf174ba0e8ed0597d581a2511cabd, 1, 'b8b399d6627999936fbc1baab313b258e3efa88eaebb515942da6d88fccf6147', 1589550536),
(0x59fb9e430849f120666d43e0536dc2965c391980, 1, 'abb567fd8c5113ffefc7ca4ff0d97a1bf3d9afc8491fa893e0d29fd3c79e30e7', 1589623927),
(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, 1589749200),
(7, 81, 0x7f000001, 1589490000);

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

--
-- 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 `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 `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 `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 `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=5;

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

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

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

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

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

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

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

--
-- 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 `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;

--
-- 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 `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 `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;

