ALTER TABLE `cld_menus` CHANGE `group` `group` ENUM('main','footer','sidebar','social','blog') CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;

ALTER TABLE `cld_menu_items` CHANGE `source` `source` ENUM('link','page','post','category','blog-category','route') CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;


ALTER TABLE `cld_blog_slider_items` CHANGE `orders` `depth` INT(11) NULL DEFAULT '0';

ALTER TABLE `cld_blog_slider_items` ADD `lft` INT UNSIGNED NULL DEFAULT NULL AFTER `options`, ADD `rgt` INT UNSIGNED NULL DEFAULT NULL AFTER `lft`;


UPDATE `cld_blog_posts` SET `picture` = replace(picture, 'blog/assets/media', 'media/blog') where 1;
UPDATE `cld_blog_posts` SET `banner` = replace(banner, 'blog/assets/media', 'media/blog') where 1;
UPDATE `cld_blog_posts` SET `content` = replace(content, 'blog/assets/media', 'media/blog') where 1;
UPDATE `cld_blog_posts` SET `content` = replace(content, 'blog/media/blog', 'media/blog') where 1;
UPDATE `cld_blog_posts` SET `content` = replace(content, 'assets/media', 'media/blog') where 1;


/*=============================================================*/

CREATE TABLE IF NOT EXISTS `cld_blog_comments` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `post_id` int(11) UNSIGNED DEFAULT NULL,
    `name` varchar(255) DEFAULT NULL,
    `email` varchar(255) DEFAULT NULL,
    `message` text DEFAULT NULL,
    `status` tinyint(1) NOT NULL DEFAULT 0,
    `created_at` datetime DEFAULT NULL,
    `updated_at` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `post_id` (`post_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


CREATE TABLE IF NOT EXISTS `cld_blog_slider` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `title` varchar(100) DEFAULT NULL,
    `options` text DEFAULT NULL,
    `background` varchar(255) DEFAULT NULL,
    `status` tinyint(1) NOT NULL DEFAULT 0,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `cld_blog_slider_items` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `slider_id` int(11) UNSIGNED NOT NULL,
    `title` varchar(255) DEFAULT NULL,
    `description` text DEFAULT NULL,
    `link` varchar(255) DEFAULT NULL,
    `link_title` varchar(100) DEFAULT NULL,
    `image` varchar(255) DEFAULT NULL,
    `options` text DEFAULT NULL,
    `orders` int(11) DEFAULT 0,
    `status` tinyint(1) NOT NULL DEFAULT 0,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `fk_slider_items_slider_id` (`slider_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `cld_blog_tags` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `title` varchar(100) NOT NULL,
    `slug` varchar(255) DEFAULT NULL,
    `description` text DEFAULT NULL,
    `status` tinyint(1) NOT NULL DEFAULT 1,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `cld_blog_tag_post` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `tag_id` int(11) UNSIGNED NOT NULL,
    `post_id` int(11) UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    KEY `role_id` (`tag_id`),
    KEY `user_id` (`post_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `cld_blog_posts` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `category_id` int(11) UNSIGNED DEFAULT NULL,
    `parent_id` int(11) UNSIGNED DEFAULT NULL,
    `type` enum('page','post') NOT NULL,
    `slug` varchar(100) DEFAULT NULL,
    `title` varchar(200) DEFAULT NULL,
    `description` text DEFAULT NULL,
    `picture` varchar(255) DEFAULT NULL,
    `hide_picture` tinyint(1) NOT NULL DEFAULT 0,
    `hide_title` tinyint(1) DEFAULT NULL,
    `picture_alt` varchar(250) DEFAULT NULL,
    `banner` varchar(255) DEFAULT NULL,
    `content` text DEFAULT NULL,
    `meta_title` varchar(255) DEFAULT NULL,
    `meta_description` text DEFAULT NULL,
    `meta_keywords` text DEFAULT NULL,
    `options` text DEFAULT NULL,
    `css_class` text DEFAULT NULL,
    `css_code` text DEFAULT NULL,
    `script_code` text DEFAULT NULL,
    `content_only` tinyint(1) UNSIGNED DEFAULT 0,
    `status` tinyint(1) UNSIGNED DEFAULT 1,
    `views` int(10) UNSIGNED NOT NULL DEFAULT 0,
    `nofollow` tinyint(1) NOT NULL DEFAULT 0,
    `noindex` tinyint(1) NOT NULL DEFAULT 0,
    `created_at` timestamp NULL DEFAULT NULL,
    `created_by` int(10) UNSIGNED DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL,
    `updated_by` int(10) UNSIGNED DEFAULT NULL,
    `deleted_at` datetime DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `slug` (`slug`),
    KEY `fk_pages_category_id` (`category_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;