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




--
-- Database: `webobiavi_last`
--

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

--
-- 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,
  `date_created` datetime NOT NULL,
  `date_modified` datetime NOT NULL,
  `active` tinyint(3) NOT NULL,
  `sponsored` 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`, `date_created`, `date_modified`, `active`, `sponsored`) VALUES
(1, 5, 16, 23, 'продавам зеле', 'Продавам прясно зеле, био updater 3', '', '6.00', 'bgn', '2019-10-15 15:54:30', '2019-12-05 19:24:45', 1, 1),
(2, 5, 17, 23, 'Продавам апартамент', 'продавам тристаен апартамент на центъра в град Пловдив', '', '999.99', 'euro', '2019-10-15 15:57:50', '2019-10-15 15:57:50', 0, 0),
(3, 4, 16, 23, 'Женска чанта', 'Продавам женска чанта', '', '50000.00', 'usd', '2019-10-15 15:59:26', '2019-11-20 19:04:49', 0, 0),
(4, 2, 17, 23, 'test1', 'asd', '', '33.70', 'euro', '2019-10-15 16:10:01', '2019-10-15 16:10:01', 0, 0),
(5, 5, 17, 23, 'продажба земя', 'Продавам 12 декара земеделска земя край Пловдив', '0894626273', '1000.00', 'bgn', '2019-10-15 16:39:13', '2019-12-06 11:58:06', 1, 1),
(23, 4, 16, 23, 'Купувам вино', 'Търся да закупя 25 литра вино за празниците (updated) ...', '0892349934', '1.00', 'bgn', '2019-11-20 12:15:53', '2019-12-05 19:25:37', 1, 1),
(24, 2, 23, 23, 'Продавам зимни гуми', 'описание за симните гуми', '098923489389', '120.00', 'bgn', '2019-12-05 18:38:07', '2019-12-05 18:39:13', 1, 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
(88, 24, 'assets/images/listings/24-evilrabbitfreak.jpg', 1),
(89, 1, 'assets/images/listings/1-saveplanetbeer.jpg', 1),
(90, 5, 'assets/images/listings/5-paths.jpg', 1),
(91, 23, 'assets/images/listings/23-blacksheep.jpeg', 1),
(92, 5, 'assets/images/listings/5-barni-rubala.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,
  `opt_1` varchar(100) NOT NULL,
  `opt_2` varchar(100) NOT NULL,
  `opt_3` varchar(100) NOT NULL,
  `opt_4` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- 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 `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, 1575545830),
(23, 'Ivan', 'Balsamadjiev', 'balsama@abv.bg', '$2y$10$PJagzUkFk9125gB5y8vKBe1jKJsaUwSoDBgF.NeKP0s9pm.SDtUPe', 'user', 1, 1568122948, 1575633209),
(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);

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

--
-- 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
(0x5ebc5e89f4574f1d48a1cee05893e9b6b2b1934f, 1, 'fccbc8cc8ed7834dae3a4cc89691f8309184910853f75ea1aa750f45b578f06f', 1575632230),
(0xba0c607229c190869d28f691b9a64c0b1080d3be, 26, 'c2b1ec1dda4e6e643c5135befda5bfacb3def5f8e0b759e2f2b35929c3c79842', 1571139280),
(0xe31d45ae129b9529b0d56b5928143257532ea7d0, 23, '48f8d54df2b6bc4859a584f2247e10e8d340bbcee30653bddef0b11ec7032a6b', 1575653065);

--
-- Indexes for dumped tables
--

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- 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=25;
--
-- 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 for table `locations`
--
ALTER TABLE `locations`
  MODIFY `node_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27;
--
-- 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 `listings_options`
--
ALTER TABLE `listings_options`
  ADD CONSTRAINT `listings_options_ibfk_1` FOREIGN KEY (`listing_id`) REFERENCES `listings` (`listing_id`) ON DELETE CASCADE ON UPDATE CASCADE;

