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

START TRANSACTION;



--
-- Database: `greatide_diet`
--

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

--
-- Table structure for table `api_keys`
--

CREATE TABLE `api_keys` (
  `id` int(11) NOT NULL,
  `key_n` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `cats`
--

CREATE TABLE `cats` (
  `cat_id` int(11) NOT NULL,
  `parent_id` int(11) NOT NULL,
  `title` varchar(200) NOT NULL,
  `photo` varchar(200) NOT NULL,
  `depth` int(11) NOT NULL,
  `order_` int(11) NOT NULL,
  `number_fileds` int(11) NOT NULL,
  `map` text NOT NULL,
  `map_type` text DEFAULT NULL COMMENT '0 = text , 1=list , 2= rich text',
  `map_ids` text DEFAULT NULL,
  `map_api_keys` text DEFAULT NULL,
  `header_page` text NOT NULL,
  `meta_description` text NOT NULL,
  `meta_keywords` text NOT NULL,
  `broken_link` text NOT NULL,
  `show_` int(11) NOT NULL,
  `text0` varchar(255) NOT NULL,
  `text1` varchar(255) NOT NULL,
  `text2` varchar(255) NOT NULL,
  `text3` varchar(255) NOT NULL,
  `text4` varchar(255) NOT NULL,
  `text5` varchar(255) NOT NULL,
  `key_name` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `cron_push`
--

CREATE TABLE `cron_push` (
  `id` int(11) NOT NULL,
  `token` text NOT NULL,
  `data` text NOT NULL,
  `device_type` enum('','iphone','android') NOT NULL,
  `provider` enum('','firebase','apns') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `data`
--

CREATE TABLE `data` (
  `id` int(11) NOT NULL,
  `userid` int(11) NOT NULL,
  `cat_id` int(11) NOT NULL,
  `parent_id` int(11) NOT NULL,
  `title` text NOT NULL,
  `photo` varchar(150) NOT NULL,
  `alias` text NOT NULL,
  `order_` int(11) NOT NULL,
  `header_page` int(11) NOT NULL,
  `meta_description` int(11) NOT NULL,
  `meta_keywords` int(11) NOT NULL,
  `broken_link` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(),
  `status` enum('publish','draft') DEFAULT 'publish',
  `type_` enum('post') DEFAULT NULL,
  `text0` text NOT NULL,
  `text1` text NOT NULL,
  `text2` text NOT NULL,
  `text3` text NOT NULL,
  `text4` text NOT NULL,
  `text5` text NOT NULL,
  `text6` text NOT NULL,
  `text7` text NOT NULL,
  `text8` text NOT NULL,
  `text9` text NOT NULL,
  `text10` text NOT NULL,
  `text11` text NOT NULL,
  `text12` text NOT NULL,
  `text13` text NOT NULL,
  `text14` text NOT NULL,
  `text15` text NOT NULL,
  `text16` text NOT NULL,
  `text17` text NOT NULL,
  `text18` text NOT NULL,
  `text19` text NOT NULL,
  `text20` text NOT NULL,
  `text21` text NOT NULL,
  `text22` text NOT NULL,
  `text23` text NOT NULL,
  `text24` text NOT NULL,
  `text25` text NOT NULL,
  `text26` text NOT NULL,
  `text27` text NOT NULL,
  `text28` text NOT NULL,
  `text29` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `data_ex`
--

CREATE TABLE `data_ex` (
  `id` int(11) UNSIGNED NOT NULL,
  `postid` int(11) DEFAULT NULL,
  `userid_owner` int(11) DEFAULT NULL,
  `userid_action` int(11) DEFAULT NULL,
  `likes` int(11) DEFAULT 0,
  `comments` int(11) DEFAULT 0,
  `views` int(11) DEFAULT 0,
  `reports_post` int(11) DEFAULT 0,
  `report` enum('user','post','liked','found','report_post') DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `devices`
--

CREATE TABLE `devices` (
  `device_id` int(11) NOT NULL,
  `userid` int(11) DEFAULT NULL,
  `token` text NOT NULL,
  `fcmtoken` text DEFAULT NULL,
  `device_type` enum('ios','android') NOT NULL DEFAULT 'ios',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `ver` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `guide`
--

CREATE TABLE `guide` (
  `id` int(11) NOT NULL,
  `cat_id` int(11) NOT NULL,
  `number_fileds` int(11) NOT NULL,
  `map` text NOT NULL,
  `map_api_keys` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `location`
--

CREATE TABLE `location` (
  `rid` int(11) UNSIGNED NOT NULL,
  `id` int(11) NOT NULL,
  `lat` float(10,6) NOT NULL,
  `lng` float(10,6) NOT NULL,
  `address` text DEFAULT NULL,
  `tbl` enum('users','cats','data') DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `photos`
--

CREATE TABLE `photos` (
  `photo_id` int(11) NOT NULL,
  `item_id` int(11) NOT NULL,
  `photo` varchar(200) NOT NULL,
  `tbl` enum('cats','data','users','cmt') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Stand-in structure for view `reports_all`
-- (See below for the actual view)
--
CREATE TABLE `reports_all` (
`id` int(11) unsigned
,`postid` int(11)
,`userid_owner` int(11)
,`userid_action` int(11)
,`likes` int(11)
,`comments` int(11)
,`views` int(11)
,`reports_post` int(11)
,`report` enum('user','post','liked','found','report_post')
);

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

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `key_` varchar(40) NOT NULL,
  `value_` text NOT NULL,
  `data_type` varchar(20) NOT NULL,
  `group_` varchar(40) NOT NULL,
  `default_value` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

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

CREATE TABLE `users` (
  `userid` int(11) NOT NULL,
  `username` varchar(100) NOT NULL,
  `name` text DEFAULT NULL,
  `photo` text DEFAULT NULL,
  `email` varchar(50) DEFAULT '',
  `gender` enum('male','female','','') DEFAULT '',
  `phone` text DEFAULT NULL,
  `joining_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `password` varchar(255) NOT NULL,
  `status` enum('active','disactive') NOT NULL DEFAULT 'active',
  `user_group` enum('user','operator','admin') NOT NULL DEFAULT 'user',
  `birthdate` double DEFAULT NULL,
  `info` text DEFAULT NULL,
  `versionBuild` text DEFAULT NULL,
  `device_type` text DEFAULT NULL,
  `lang` text DEFAULT NULL,
  `weight` int(11) DEFAULT NULL,
  `tall` int(11) DEFAULT NULL,
  `ver` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `user_buy`
--

CREATE TABLE `user_buy` (
  `id` int(11) UNSIGNED NOT NULL,
  `userid` int(11) NOT NULL,
  `buy_type` enum('buy','restore','lastbuy') NOT NULL DEFAULT 'buy',
  `buy_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `last_status` enum('buy','restore','lastbuy') DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

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

--
-- Structure for view `reports_all`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`greatide`@`localhost` SQL SECURITY DEFINER VIEW `reports_all`  AS  select `data_ex`.`id` AS `id`,`data_ex`.`postid` AS `postid`,`data_ex`.`userid_owner` AS `userid_owner`,`data_ex`.`userid_action` AS `userid_action`,`data_ex`.`likes` AS `likes`,`data_ex`.`comments` AS `comments`,`data_ex`.`views` AS `views`,`data_ex`.`reports_post` AS `reports_post`,`data_ex`.`report` AS `report` from `data_ex` where `data_ex`.`report` = 'user' or `data_ex`.`report` = 'report_post' order by `data_ex`.`id` desc ;

--
-- Indexes for dumped tables
--

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

--
-- Indexes for table `cats`
--
ALTER TABLE `cats`
  ADD PRIMARY KEY (`cat_id`);

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

--
-- Indexes for table `data`
--
ALTER TABLE `data`
  ADD PRIMARY KEY (`id`),
  ADD KEY `data_cats` (`cat_id`),
  ADD KEY `data_users` (`userid`);

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

--
-- Indexes for table `devices`
--
ALTER TABLE `devices`
  ADD PRIMARY KEY (`device_id`);

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

--
-- Indexes for table `location`
--
ALTER TABLE `location`
  ADD PRIMARY KEY (`rid`);

--
-- Indexes for table `photos`
--
ALTER TABLE `photos`
  ADD PRIMARY KEY (`photo_id`);

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

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`userid`);

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `api_keys`
--
ALTER TABLE `api_keys`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cats`
--
ALTER TABLE `cats`
  MODIFY `cat_id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cron_push`
--
ALTER TABLE `cron_push`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `data`
--
ALTER TABLE `data`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `data_ex`
--
ALTER TABLE `data_ex`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `devices`
--
ALTER TABLE `devices`
  MODIFY `device_id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `guide`
--
ALTER TABLE `guide`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `location`
--
ALTER TABLE `location`
  MODIFY `rid` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `photos`
--
ALTER TABLE `photos`
  MODIFY `photo_id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `userid` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_buy`
--
ALTER TABLE `user_buy`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `data`
--
ALTER TABLE `data`
  ADD CONSTRAINT `data_cats` FOREIGN KEY (`cat_id`) REFERENCES `cats` (`cat_id`),
  ADD CONSTRAINT `data_users` FOREIGN KEY (`userid`) REFERENCES `users` (`userid`);
COMMIT;

