-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Oct 15, 2023 at 03:31 PM
-- Server version: 10.4.21-MariaDB
-- PHP Version: 7.4.25

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


CREATE TABLE `footer_items` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `pos` int(11) NOT NULL DEFAULT 0,
  `title` text NOT NULL DEFAULT '',
  `icon_code` tinytext NOT NULL DEFAULT '',
  `custom_class` tinytext NOT NULL DEFAULT '',
  `align_content` enum('unset','center','flex-start','flex-end','space-around','space-between','stretch') NOT NULL DEFAULT 'flex-start',
  `justify_content` enum('unset','center','flex-start','flex-end','space-between','space-around','space-evenly') NOT NULL DEFAULT 'flex-start',
  `align_items` enum('unset','center','flex-start','flex-end','stretch','baseline') NOT NULL DEFAULT 'center',
  `arrenge` enum('row','column') NOT NULL DEFAULT 'row',
  `item_arrenge` enum('row','column') NOT NULL DEFAULT 'row',
  `col_count` enum('col-count1','col-count2','col-count4','col-count6') NOT NULL DEFAULT 'col-count1',
  `title_color` tinytext NOT NULL DEFAULT '',
  `icon_color` tinytext NOT NULL DEFAULT '',
  `text_color` tinytext NOT NULL DEFAULT '',
  `img_width` int(11) NOT NULL DEFAULT 100,
  `icon_size` int(11) NOT NULL DEFAULT 20,
  `data` mediumtext NOT NULL DEFAULT '' COMMENT 'big json data with icons-images-text-intent-data-imgwidth...',
  `html_data` text NOT NULL DEFAULT '',
  `border_bottom_color` tinytext NOT NULL DEFAULT '',
  `border_top_color` tinytext NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `megamenu_items` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `parent_id` int(11) NOT NULL COMMENT 'root megamenu items must be -1',
  `float_mode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0/1',
  `pos` int(11) NOT NULL,
  `title` text NOT NULL DEFAULT '',
  `description` text NOT NULL DEFAULT '',
  `icon_code` text NOT NULL DEFAULT '',
  `image` text NOT NULL DEFAULT '',
  `color` tinytext NOT NULL DEFAULT '',
  `label` tinytext NOT NULL DEFAULT '' COMMENT 'for example new label',
  `label_color` tinytext NOT NULL DEFAULT '',
  `screen_limit` enum('no_limit','small_screen','large_screen','') NOT NULL DEFAULT 'no_limit',
  `intent_type` text NOT NULL DEFAULT '',
  `intent_data` text NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `redirects` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `redirect` tinytext NOT NULL DEFAULT '' COMMENT '301 or 302 ...',
  `old_link` text NOT NULL DEFAULT '',
  `new_link` text NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `sitemap` (
  `id` bigint(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `page_type` enum('homepage','static_pages','dynamic_pages','not_set') NOT NULL DEFAULT 'not_set' COMMENT 'posts for example are dynamic pages and account page is a static page',
  `loc` mediumtext NOT NULL DEFAULT '',
  `address` mediumtext NOT NULL DEFAULT '' COMMENT 'This is exactly same is loc only this one is not encoded!',
  `lastmod` text NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `subscribe_orders` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `purchase_id` int(11) NOT NULL DEFAULT 0,
  `subscribe_id` int(11) NOT NULL DEFAULT 0,
  `status` enum('active','expired') NOT NULL DEFAULT 'expired' COMMENT 'active|expired',
  `expire_date` tinytext NOT NULL DEFAULT '',
  `date_updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `date` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `subscribe_orders_log` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `subscribe_order_id` int(11) NOT NULL DEFAULT 0,
  `data` text NOT NULL DEFAULT '',
  `date` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `users_auth` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `token` text NOT NULL DEFAULT '',
  `expire` tinytext NOT NULL DEFAULT '' COMMENT 'we save date with (Y-m-d) format here and not the default Y-m-d H:i:s format because +7 day date extender not works in php when the default format'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `web_homepage_items` (
  `id` int(11) NOT NULL,
  `app_id` int(11) NOT NULL DEFAULT 0,
  `type` tinytext NOT NULL COMMENT 'text|img|img_dual|slider|and so much more',
  `pos` int(11) NOT NULL DEFAULT 0,
  `theme` int(11) NOT NULL DEFAULT 0,
  `data` mediumtext NOT NULL DEFAULT '',
  `data2` mediumtext NOT NULL DEFAULT '',
  `direction` tinytext NOT NULL DEFAULT '' COMMENT 'ltr|rtl if not set extend from app direction',
  `screen_limit` enum('no_limit','small_screen','large_screen','') NOT NULL DEFAULT 'no_limit',
  `margin_bottom` tinytext NOT NULL DEFAULT '',
  `icon_code` tinytext NOT NULL DEFAULT '',
  `text_color` tinytext NOT NULL DEFAULT '',
  `background_color` tinytext NOT NULL DEFAULT '',
  `inner_padding` int(11) NOT NULL DEFAULT 0,
  `root_background_color` tinytext NOT NULL DEFAULT '',
  `inner_root_padding` int(11) NOT NULL DEFAULT 0,
  `img_height` int(11) NOT NULL DEFAULT 100,
  `img_height_mobile` int(11) NOT NULL DEFAULT 70,
  `round_corners` int(11) NOT NULL DEFAULT 0,
  `space_between` int(11) NOT NULL DEFAULT 0,
  `grid_width` int(11) NOT NULL DEFAULT 90,
  `gravity` tinytext NOT NULL DEFAULT '' COMMENT 'start|end|center',
  `horizontal_scroll` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0|1',
  `align_content` enum('flex-start','center','flex-end','space-between','space-around','stretch') NOT NULL DEFAULT 'flex-start' COMMENT 'center|flex-start|flex-end|space-between|space-around|stretch',
  `justify_content` enum('flex-start','center','flex-end','space-between','space-around','space-evenly') NOT NULL DEFAULT 'flex-start' COMMENT 'center|flex-start|flex-end|space-between|space-around|space-evenly	',
  `align_items` enum('center','flex-start','flex-end','stretch') NOT NULL DEFAULT 'center' COMMENT 'center|flex-start|flex-end|stretch	',
  `line_post_order` tinytext NOT NULL DEFAULT '' COMMENT 'pos_desc , pos_asc , date_desc , date_asc , view_desc , like_desc',
  `line_post_limit` int(11) NOT NULL DEFAULT 20 COMMENT 'range 1 up to 30',
  `line_post_image_ratio` tinytext NOT NULL DEFAULT '' COMMENT '	something like 1:1 or 3:4',
  `line_post_first_item_as_image` text NOT NULL DEFAULT '',
  `line_post_first_item_as_image_intent_type` tinytext NOT NULL DEFAULT '',
  `line_post_first_item_as_image_intent_data` text NOT NULL DEFAULT '',
  `text_padding` int(11) NOT NULL DEFAULT 10,
  `text_weight` enum('200','300','400','500','600','700','800','900') NOT NULL DEFAULT '400' COMMENT '200|300|400|500|600|700|800|900',
  `root_custom_class_name` tinytext NOT NULL DEFAULT '' COMMENT 'custom css class name',
  `left_item_share` int(11) NOT NULL DEFAULT 40
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


ALTER TABLE `footer_items`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `megamenu_items`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `subscribe_orders`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `subscribe_orders_log`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `users_auth`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `web_homepage_items`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `redirects`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `sitemap`
  ADD PRIMARY KEY (`id`);




ALTER TABLE `footer_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


ALTER TABLE `megamenu_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


ALTER TABLE `subscribe_orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
  AUTO_INCREMENT = 11001;


ALTER TABLE `subscribe_orders_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


ALTER TABLE `users_auth`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


ALTER TABLE `web_homepage_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

  
ALTER TABLE `redirects`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


ALTER TABLE `sitemap`
  MODIFY `id` bigint(11) NOT NULL AUTO_INCREMENT;




-- Add New Columns to exisiting tables:

ALTER TABLE `apps`
  ADD `appuid` tinytext NOT NULL DEFAULT '' COMMENT 'generate uuid for site demos 16chars' AFTER `packagename`,
  MODIFY `variation_code` ENUM('demo','starter','pro','unlimited','demo_plus','pro_plus','unlimited_plus') NOT NULL DEFAULT 'demo' COMMENT 'This column defines how much option a specific subscription has access to.';


ALTER TABLE `bottombar_items`
  ADD `text_color` tinytext NOT NULL DEFAULT '' AFTER `text`;


ALTER TABLE `categories`
  ADD `primary_link` text NOT NULL DEFAULT '' AFTER `title`,
  ADD `seo_title` text NOT NULL DEFAULT '' AFTER `summary`,
  ADD `seo_description` text NOT NULL DEFAULT '' AFTER `summary`,
  ADD `header_banner` text NOT NULL DEFAULT '' AFTER `summary`,
  ADD `data` mediumtext NOT NULL DEFAULT '' AFTER `summary`,
  ADD `title_text_color` tinytext NOT NULL DEFAULT '' AFTER `box_corner_radius`,
  ADD `desc_text_color` tinytext NOT NULL DEFAULT '' AFTER `box_corner_radius`,
  ADD `view_like_date_text_color` tinytext NOT NULL DEFAULT '' AFTER `box_corner_radius`,
  ADD `box_background_color` tinytext NOT NULL DEFAULT '' AFTER `box_corner_radius`,
  ADD `arrow_color` tinytext NOT NULL DEFAULT '' AFTER `box_corner_radius`,
  ADD `title_max_lines` int(11) NOT NULL DEFAULT 0 AFTER `box_corner_radius`,
  ADD `description_max_lines` int(11) NOT NULL DEFAULT 0 AFTER `box_corner_radius`,
  ADD `date` timestamp NOT NULL DEFAULT current_timestamp() AFTER `actionbar_icon_intent_data`,
  ADD `date_updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() AFTER `actionbar_icon_intent_data`;


ALTER TABLE `coupons`
  ADD `category_limit` int(11) NOT NULL DEFAULT 0 COMMENT '0 means no limit' AFTER `section_limit`;


ALTER TABLE `forms`
  ADD `form_type` enum('free','paid') NOT NULL DEFAULT 'free' AFTER `title`,
  ADD `price` int(11) NOT NULL DEFAULT 0 AFTER `title`,
  ADD `price_off` int(11) NOT NULL DEFAULT 0 AFTER `title`,
  ADD `status` enum('in_stock','out_of_stock') NOT NULL DEFAULT 'in_stock' AFTER `title`,
  ADD `quantity` int(11) NOT NULL DEFAULT -200 AFTER `title`,
  ADD `quantity_title_text` text NOT NULL DEFAULT '' AFTER `title`,
  ADD `quantity_limit_for_every_user` int(11) NOT NULL DEFAULT 0 AFTER `title`,
  ADD `out_of_stock_text` tinytext NOT NULL DEFAULT '' AFTER `title`,
  ADD `guests_can_send_data` tinyint(1) NOT NULL DEFAULT 0 AFTER `user_can_resend_data`,
  ADD `date_updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() AFTER `date`;
  

ALTER TABLE `homepage_items`
  ADD `line_post_show_description` tinyint(4) NOT NULL DEFAULT 0 AFTER `line_post_recycler_type`;


ALTER TABLE `orders`
  ADD `payment_method` enum('online','transfer','atdes') NOT NULL DEFAULT 'online' COMMENT 'online|transfer|atdes' AFTER `purchase_id`,
  ADD `shipping_location_lat` tinytext NOT NULL DEFAULT '' AFTER `shipping_address`,
  ADD `shipping_location_lon` tinytext NOT NULL DEFAULT '' AFTER `shipping_address`;


ALTER TABLE `poll`
  ADD `date_updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() AFTER `date`;


ALTER TABLE `posts`
  ADD `primary_link` text NOT NULL DEFAULT '' AFTER `title`,
  ADD `seo_title` text NOT NULL DEFAULT '' AFTER `summary`,
  ADD `seo_description` text NOT NULL DEFAULT '' AFTER `summary`,
  ADD `show_limit` enum('none','app','web') NOT NULL DEFAULT 'none' COMMENT 'none|app|web' AFTER `is_under_construction`,
  ADD `label_text` tinytext NOT NULL DEFAULT '' AFTER `intent_opener_only`,
  ADD `label_txt_color` tinytext NOT NULL DEFAULT '' AFTER `intent_opener_only`,
  ADD `label_bg_color` tinytext NOT NULL DEFAULT '' AFTER `intent_opener_only`;


ALTER TABLE `purchases`
  ADD `payment_method` enum('online','transfer','atdes') NOT NULL DEFAULT 'online' COMMENT 'online|transfer|atdes' AFTER `purchase_type`;


ALTER TABLE `quiz`
  ADD `date_updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() AFTER `date`;


ALTER TABLE `users`
  ADD `family` text NOT NULL DEFAULT '' COMMENT 'for future uses' AFTER `name`,
  ADD `profile_picture` text NOT NULL DEFAULT '' COMMENT 'for feature uses' AFTER `name`,
  ADD `shipping_phone` tinytext NOT NULL DEFAULT '' COMMENT 'for feature uses' AFTER `location`,
  ADD `additional_shipping_addresses` mediumtext NOT NULL DEFAULT '' COMMENT '' AFTER `location`,
  ADD `authentication_image` text NOT NULL DEFAULT '' AFTER `melli_code`,
  ADD `custom_field1` text NOT NULL DEFAULT '' AFTER `birthday_fa`,
  ADD `custom_field2` text NOT NULL DEFAULT '' AFTER `birthday_fa`,
  ADD `custom_field3` text NOT NULL DEFAULT '' AFTER `birthday_fa`,
  ADD `invite_code` tinytext NOT NULL DEFAULT '' COMMENT 'save phone number or email by default. user can change it maybe' AFTER `wallet_balance`,
  ADD `inviter_user_id` int(11) NOT NULL DEFAULT 0 AFTER `wallet_balance`;


COMMIT;