CREATE TABLE `jw_pages` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `page_name` VARCHAR(100) COLLATE utf8mb4_general_ci NOT NULL,
  `page_url` VARCHAR(100) COLLATE utf8mb4_general_ci NOT NULL,
  `user_permission_name` VARCHAR(100) NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

ALTER TABLE `users`
  ADD `jw_page_id` BIGINT UNSIGNED NULL;

ALTER TABLE `users`
  ADD CONSTRAINT `fk_users_jw_page_id`
  FOREIGN KEY (`jw_page_id`) REFERENCES `jw_pages`(`id`)
  ON DELETE SET NULL
  ON UPDATE CASCADE;

-- jw_pages data
INSERT INTO u0305746_jw.jw_pages (page_name,page_url,user_permission_name) VALUES
	 ('Кабинет','/charts.php','menu_office'),
	 ('Поиск(Продажа)','/sale.php','menu_search'),
	 ('Поиск(Аренда)','/main.php','menu_search'),
	 ('Поиск по карте','/find-objects.php','menu_search'),
	 ('Объекты','/my-objects.php','menu_objects'),
	 ('Реклама','/agency-objects.php','menu_ads'),
	 ('Жилые комплексы','/complexes','menu_complexes'),
	 ('Клиенты','/clients.php','menu_clients'),
	 ('Заявки','/requisitions.php','menu_submissions'),
	 ('Календарь','/calendar.php',NULL);
INSERT INTO u0305746_jw.jw_pages (page_name,page_url,user_permission_name) VALUES
	 ('Сотрудники','/users.php',NULL),
	 ('Партнеры','/partners.php','menu_partners'),
	 ('Документы','/docs.php','menu_docs'),
	 ('Настройки','/settings.php','menu_settings'),
	 ('Обучение','/help.php',NULL);
