-- https://www.phpmyadmin.net/
--
-- Версия на сървъра: 10.4.11-MariaDB

START TRANSACTION;



--
-- Database: `webobiavi`
--

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

--
-- Структура на таблица `black_list_email`
--

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

--
-- Схема на данните от таблица `black_list_email`
--

INSERT INTO `black_list_email` (`id`, `email`) VALUES
(18, 'balsama@abv.bg');

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `black_list_ip`
--

INSERT INTO `black_list_ip` (`id`, `ip_address`) VALUES
(35, 0x9600000a),
(36, 0x8a0c0c01),
(37, 0x7f000001);

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `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);

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

--
-- Структура на таблица `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,
  `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;

--
-- Схема на данните от таблица `listings`
--

INSERT INTO `listings` (`listing_id`, `category_id`, `location_id`, `user_id`, `title`, `description`, `phone`, `price`, `currency`, `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', '2020-04-14 19:05:38', '2020-04-14 19:05:38', 1, 0, 0, 1),
(37, 2, 20, 27, 'BMW X5', 'Колата е с всички екстри.', '089888787848', '30000.00', 'bgn', '2020-04-24 16:48:06', '2020-04-24 16:54:39', 1, 0, 0, 0);

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

--
-- Структура на таблица `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;

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `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);

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `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);

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `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);

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

--
-- Структура на таблица `permissions`
--

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

--
-- Схема на данните от таблица `permissions`
--

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

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

--
-- Структура на таблица `roles`
--

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

--
-- Схема на данните от таблица `roles`
--

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

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `role_perm_link`
--

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

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

--
-- Структура на таблица `stop_words`
--

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

--
-- Схема на данните от таблица `stop_words`
--

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

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `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, 1587717842),
(23, 'Ivan', 'Balsamadjiev', 'balsama@abv.bg', '$2y$10$6BZuGuR6Dj9KKB2QQF/3MueryraSVIa7zE8egkuqzV21dlI6YvMoi', 'user', 1, 1568122948, 1587719092),
(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);

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `users_auth`
--

INSERT INTO `users_auth` (`id`, `user_id`, `validator`, `expires`) VALUES
(0x6ab93df9e128b12793e15e5aeac5653def3c8831, 27, '88f0ebcc0c0d01828586eb48e5022cbf450e7274243667fae99a8f47a7f89f30', 1587822322),
(0x9c777a85408f5a9c7e0869aa9aaf02b380d98300, 1, '4f52d2de7701bb9658e47bfe6696cd7444fa8506f46cb066f3d86beb68697a4a', 1587728988),
(0xba0c607229c190869d28f691b9a64c0b1080d3be, 26, 'c2b1ec1dda4e6e643c5135befda5bfacb3def5f8e0b759e2f2b35929c3c79842', 1571139280),
(0xfb54dce72704521a79dbd7ce1473e4bc5f8f9e4a, 1, 'a6948575002150ae5b83e6e42351faa65b604520c45407d395aecea29d1a51ea', 1587804242);

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `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, 1587675600);

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `users_blocked`
--

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

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

--
-- Структура на таблица `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;

--
-- Схема на данните от таблица `user_role_link`
--

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

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

--
-- Структура на таблица `visits`
--

CREATE TABLE `visits` (
  `listing_id` int(10) NOT NULL,
  `date` date NOT NULL,
  `clicks` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Схема на данните от таблица `visits`
--

INSERT INTO `visits` (`listing_id`, `date`, `clicks`) VALUES
(1, '2020-04-22', 6),
(2, '2020-04-22', 5),
(3, '2020-04-24', 1),
(4, '2020-04-19', 6),
(4, '2020-04-20', 2),
(4, '2020-04-22', 5),
(4, '2020-04-23', 1),
(5, '2020-04-22', 7),
(23, '2020-04-22', 3),
(24, '2020-04-20', 2),
(24, '2020-04-21', 11),
(24, '2020-04-22', 1),
(24, '2020-04-23', 2),
(25, '2020-04-19', 8),
(25, '2020-04-20', 3),
(25, '2020-04-21', 3),
(25, '2020-04-22', 3),
(25, '2020-04-23', 7),
(26, '2020-04-23', 4),
(26, '2020-04-24', 3),
(27, '2020-04-19', 11),
(27, '2020-04-22', 1),
(27, '2020-04-23', 3),
(27, '2020-04-24', 3),
(28, '2020-04-23', 3),
(37, '2020-04-24', 1);

--
-- Indexes for dumped tables
--

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

--
-- Indexes for table `visits`
--
ALTER TABLE `visits`
  ADD PRIMARY KEY (`listing_id`,`date`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

--
-- Ограничения за дъмпнати таблици
--

--
-- Ограничения за таблица `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;

--
-- Ограничения за таблица `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;

--
-- Ограничения за таблица `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;

--
-- Ограничения за таблица `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;

--
-- Ограничения за таблица `users_blocked`
--
ALTER TABLE `users_blocked`
  ADD CONSTRAINT `users_blocked_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);

--
-- Ограничения за таблица `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;

