From e26236a5916b40a7d38143becc4cb09b398b2a39 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 8 Jan 2026 00:42:26 +0200 Subject: [PATCH] rename table --- crates/crawler/src/main.rs | 2 +- crates/mysql/database/0.1.0.sql | 22 +++++++++++----------- crates/mysql/src/lib.rs | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/crawler/src/main.rs b/crates/crawler/src/main.rs index c221040..eb57623 100644 --- a/crates/crawler/src/main.rs +++ b/crates/crawler/src/main.rs @@ -187,7 +187,7 @@ fn crawl(db: &Mysql, channel_config: &config::Channel) -> Result<()> { }, }; assert!( - db.contents_by_channel_item_id_source_id(channel_item_id, None, Some(1))? + db.contents_by_channel_item_id_provider_id(channel_item_id, None, Some(1))? .is_empty() ); let _content_id = db.insert_content(channel_item_id, None, title, description)?; diff --git a/crates/mysql/database/0.1.0.sql b/crates/mysql/database/0.1.0.sql index d35b99d..5eb70ff 100644 --- a/crates/mysql/database/0.1.0.sql +++ b/crates/mysql/database/0.1.0.sql @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- Wed 07 Jan 2026 04:18:03 PM EET +-- Thu 08 Jan 2026 12:40:45 AM EET -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -51,12 +51,12 @@ ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `rssto`.`source` +-- Table `rssto`.`provider` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `rssto`.`source` ( - `source_id` INT NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS `rssto`.`provider` ( + `provider_id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, - PRIMARY KEY (`source_id`), + PRIMARY KEY (`provider_id`), UNIQUE INDEX `name_UNIQUE` (`name` ASC) VISIBLE) ENGINE = InnoDB; @@ -67,21 +67,21 @@ ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `rssto`.`content` ( `content_id` BIGINT NOT NULL AUTO_INCREMENT, `channel_item_id` INT NOT NULL, - `source_id` INT NULL, + `provider_id` INT NULL, `title` VARCHAR(255) NOT NULL, `description` LONGTEXT NOT NULL, PRIMARY KEY (`content_id`), INDEX `fk_content_channel_item_idx` (`channel_item_id` ASC) VISIBLE, - INDEX `fk_content_source_idx` (`source_id` ASC) VISIBLE, - UNIQUE INDEX `UNIQUE` (`channel_item_id` ASC, `source_id` ASC) VISIBLE, + INDEX `fk_content_provider_idx` (`provider_id` ASC) VISIBLE, + UNIQUE INDEX `UNIQUE` (`channel_item_id` ASC, `provider_id` ASC) VISIBLE, CONSTRAINT `fk_content_channel_item` FOREIGN KEY (`channel_item_id`) REFERENCES `rssto`.`channel_item` (`channel_item_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fk_content_source` - FOREIGN KEY (`source_id`) - REFERENCES `rssto`.`source` (`source_id`) + CONSTRAINT `fk_content_provider` + FOREIGN KEY (`provider_id`) + REFERENCES `rssto`.`provider` (`provider_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; diff --git a/crates/mysql/src/lib.rs b/crates/mysql/src/lib.rs index 32f8018..21b6f9d 100644 --- a/crates/mysql/src/lib.rs +++ b/crates/mysql/src/lib.rs @@ -99,7 +99,7 @@ impl Mysql { self.pool.get_conn()?.exec_first( "SELECT `content_id`, `channel_item_id`, - `source_id`, + `provider_id`, `title`, `description` FROM `content` WHERE `content_id` = ?", (content_id,), @@ -118,43 +118,43 @@ impl Mysql { self.pool.get_conn()?.query(format!( "SELECT `content_id`, `channel_item_id`, - `source_id`, + `provider_id`, `title`, `description` FROM `content` ORDER BY `content_id` {sort} LIMIT {}", limit.unwrap_or(DEFAULT_LIMIT) )) } - pub fn contents_by_channel_item_id_source_id( + pub fn contents_by_channel_item_id_provider_id( &self, channel_item_id: u64, - source_id: Option, + provider_id: Option, limit: Option, ) -> Result, Error> { self.pool.get_conn()?.exec( format!( "SELECT `content_id`, `channel_item_id`, - `source_id`, + `provider_id`, `title`, - `description` FROM `content` WHERE `channel_item_id` = ? AND `source_id` = ? LIMIT {}", + `description` FROM `content` WHERE `channel_item_id` = ? AND `provider_id` = ? LIMIT {}", limit.unwrap_or(DEFAULT_LIMIT) ), - (channel_item_id, source_id), + (channel_item_id, provider_id), ) } pub fn insert_content( &self, channel_item_id: u64, - source_id: Option, + provider_id: Option, title: String, description: String, ) -> Result { let mut c = self.pool.get_conn()?; c.exec_drop( - "INSERT INTO `content` SET `channel_item_id` = ?, `source_id` = ?, `title` = ?, `description` = ?", - (channel_item_id, source_id, title, description ), + "INSERT INTO `content` SET `channel_item_id` = ?, `provider_id` = ?, `title` = ?, `description` = ?", + (channel_item_id, provider_id, title, description ), )?; Ok(c.last_insert_id()) } @@ -183,7 +183,7 @@ pub struct Content { pub channel_item_id: u64, /// None if the original `title` and `description` values /// parsed from the channel item on crawl - pub source_id: Option, + pub provider_id: Option, pub title: String, pub description: String, }