CREATE TABLE IF NOT EXISTS `blog_posts` (
    `id`             INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `slug`           VARCHAR(160) NOT NULL,
    `author_id`      INT UNSIGNED NOT NULL,
    `title_lv`       VARCHAR(200) NOT NULL,
    `title_ru`       VARCHAR(200) NOT NULL,
    `title_en`       VARCHAR(200) NOT NULL,
    `excerpt_lv`     TEXT NULL,
    `excerpt_ru`     TEXT NULL,
    `excerpt_en`     TEXT NULL,
    `content_lv`     LONGTEXT NULL,
    `content_ru`     LONGTEXT NULL,
    `content_en`     LONGTEXT NULL,
    `cover_image`    VARCHAR(255) NULL,
    `meta_title_lv`  VARCHAR(160) NULL,
    `meta_title_ru`  VARCHAR(160) NULL,
    `meta_title_en`  VARCHAR(160) NULL,
    `meta_desc_lv`   VARCHAR(320) NULL,
    `meta_desc_ru`   VARCHAR(320) NULL,
    `meta_desc_en`   VARCHAR(320) NULL,
    `is_published`   TINYINT(1) NOT NULL DEFAULT 0,
    `published_at`   DATETIME NULL,
    `views_count`    INT UNSIGNED NOT NULL DEFAULT 0,
    `created_at`     DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`     DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `blog_posts_slug_unique` (`slug`),
    KEY `blog_posts_is_published_index` (`is_published`, `published_at`),
    CONSTRAINT `fk_bp_author` FOREIGN KEY (`author_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
