-- MySQL Script generated by MySQL Workbench
-- нд, 11-січ-2026 20:33:40 +0200
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema rssto
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema rssto
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `rssto` ;
USE `rssto` ;

-- -----------------------------------------------------
-- Table `rssto`.`channel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel` (
  `channel_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `url` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`channel_id`),
  UNIQUE INDEX `url_UNIQUE` (`url` ASC) VISIBLE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_item`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item` (
  `channel_item_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `channel_id` INT UNSIGNED NOT NULL,
  `pub_date` BIGINT NOT NULL,
  `guid` VARCHAR(255) NOT NULL,
  `link` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`channel_item_id`, `channel_id`),
  INDEX `fk_channel_item_channel_idx` (`channel_id` ASC) VISIBLE,
  UNIQUE INDEX `UNIQUE` (`guid` ASC, `channel_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_item_channel`
    FOREIGN KEY (`channel_id`)
    REFERENCES `rssto`.`channel` (`channel_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`provider`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`provider` (
  `provider_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`provider_id`),
  UNIQUE INDEX `name_UNIQUE` (`name` ASC) VISIBLE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_item_content`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item_content` (
  `channel_item_content_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `channel_item_id` INT UNSIGNED NOT NULL,
  PRIMARY KEY (`channel_item_content_id`, `channel_item_id`),
  INDEX `fk_channel_item_content_channel_item_idx` (`channel_item_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_item_content_channel_item`
    FOREIGN KEY (`channel_item_id`)
    REFERENCES `rssto`.`channel_item` (`channel_item_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`image`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`image` (
  `image_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `provider_id` INT UNSIGNED NULL,
  `sha256` CHAR(64) NOT NULL,
  `src` VARCHAR(2048) NULL,
  `url` VARCHAR(2048) NULL,
  `data` MEDIUMBLOB NOT NULL,
  PRIMARY KEY (`image_id`),
  UNIQUE INDEX `hash_UNIQUE` (`sha256` ASC) VISIBLE,
  INDEX `fk_image_provider_idx` (`provider_id` ASC) VISIBLE,
  CONSTRAINT `fk_image_provider`
    FOREIGN KEY (`provider_id`)
    REFERENCES `rssto`.`provider` (`provider_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_item_content_image`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item_content_image` (
  `channel_item_content_image_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `content_channel_item_content_id` BIGINT UNSIGNED NOT NULL,
  `image_id` BIGINT UNSIGNED NOT NULL,
  PRIMARY KEY (`channel_item_content_image_id`),
  INDEX `fk_channel_item_content_image_channel_item_content_idx` (`content_channel_item_content_id` ASC) VISIBLE,
  INDEX `fk_channel_item_content_image_image_idx` (`image_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_item_content_image_channel_item_content`
    FOREIGN KEY (`content_channel_item_content_id`)
    REFERENCES `rssto`.`channel_item_content` (`channel_item_content_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_channel_item_content_image_image`
    FOREIGN KEY (`image_id`)
    REFERENCES `rssto`.`image` (`image_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_description`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_description` (
  `channel_description_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `channel_id` INT UNSIGNED NOT NULL,
  `provider_id` INT UNSIGNED NULL,
  `title` TEXT NULL,
  `description` LONGTEXT NULL,
  PRIMARY KEY (`channel_description_id`),
  INDEX `fk_channel_description_provider_idx` (`provider_id` ASC) VISIBLE,
  INDEX `fk_channel_description_channel_idx` (`channel_id` ASC) VISIBLE,
  UNIQUE INDEX `UNIQUE` (`channel_id` ASC, `provider_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_description_provider`
    FOREIGN KEY (`provider_id`)
    REFERENCES `rssto`.`provider` (`provider_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_channel_description_channel`
    FOREIGN KEY (`channel_id`)
    REFERENCES `rssto`.`channel` (`channel_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_item_description`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item_description` (
  `channel_item_description_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `channel_item_id` INT UNSIGNED NOT NULL,
  `provider_id` INT UNSIGNED NULL,
  `title` TEXT NULL,
  `description` LONGTEXT NULL,
  INDEX `fk_channel_item_description_channel_item_idx` (`channel_item_id` ASC) VISIBLE,
  INDEX `fk_channel_item_description_provider_idx` (`provider_id` ASC) VISIBLE,
  PRIMARY KEY (`channel_item_description_id`),
  UNIQUE INDEX `UNIQUE` (`channel_item_id` ASC, `provider_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_item_description_channel_item`
    FOREIGN KEY (`channel_item_id`)
    REFERENCES `rssto`.`channel_item` (`channel_item_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_channel_item_description_provider`
    FOREIGN KEY (`provider_id`)
    REFERENCES `rssto`.`provider` (`provider_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_item_content_description`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item_content_description` (
  `channel_item_content_description_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `channel_item_content_id` BIGINT UNSIGNED NOT NULL,
  `provider_id` INT UNSIGNED NULL,
  `title` TEXT NULL,
  `description` LONGTEXT NULL,
  PRIMARY KEY (`channel_item_content_description_id`),
  INDEX `fk_channel_item_content_description_channel_item_content_idx` (`channel_item_content_id` ASC) VISIBLE,
  INDEX `fk_channel_item_content_description_provider_idx` (`provider_id` ASC) VISIBLE,
  UNIQUE INDEX `UNIQUE` (`channel_item_content_id` ASC, `provider_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_item_content_description_channel_item_content`
    FOREIGN KEY (`channel_item_content_id`)
    REFERENCES `rssto`.`channel_item_content` (`channel_item_content_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_channel_item_content_description_provider`
    FOREIGN KEY (`provider_id`)
    REFERENCES `rssto`.`provider` (`provider_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
