move meta entities to the page level, remove extra references, add change some db tables structure, change app version

This commit is contained in:
yggverse 2025-01-14 22:16:48 +02:00
parent 557ad69edf
commit 2ff6b9d963
22 changed files with 313 additions and 472 deletions

View file

@ -2,7 +2,8 @@ use sqlite::{Error, Transaction};
pub struct Table {
pub id: i64,
// pub app_browser_window_tab_item_id: i64, not in use
// pub app_browser_window_tab_item_id: i64, not in use,
pub title: String,
}
pub fn init(tx: &Transaction) -> Result<usize, Error> {
@ -11,6 +12,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`app_browser_window_tab_item_id` INTEGER NOT NULL,
`title` VARCHAR(1024),
FOREIGN KEY (`app_browser_window_tab_item_id`) REFERENCES `app_browser_window_tab_item`(`id`)
)",
@ -18,19 +20,25 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
)
}
pub fn insert(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<usize, Error> {
pub fn insert(
tx: &Transaction,
app_browser_window_tab_item_id: i64,
title: &str,
) -> Result<usize, Error> {
tx.execute(
"INSERT INTO `app_browser_window_tab_item_page` (
`app_browser_window_tab_item_id`
) VALUES (?)",
[app_browser_window_tab_item_id],
`app_browser_window_tab_item_id`,
`title`
) VALUES (?, ?)",
(app_browser_window_tab_item_id, title),
)
}
pub fn select(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<Vec<Table>, Error> {
pub fn select(tx: &Transaction, app_browser_window_tab_item_id: i64) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare(
"SELECT `id`,
`app_browser_window_tab_item_id`
`app_browser_window_tab_item_id`,
`title`
FROM `app_browser_window_tab_item_page`
WHERE `app_browser_window_tab_item_id` = ?",
)?;
@ -39,6 +47,7 @@ pub fn select(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<
Ok(Table {
id: row.get(0)?,
// app_browser_window_tab_item_id: row.get(1)?, not in use
title: row.get(2)?,
})
})?;
@ -52,7 +61,7 @@ pub fn select(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<
Ok(records)
}
pub fn delete(tx: &Transaction, id: &i64) -> Result<usize, Error> {
pub fn delete(tx: &Transaction, id: i64) -> Result<usize, Error> {
tx.execute(
"DELETE FROM `app_browser_window_tab_item_page` WHERE `id` = ?",
[id],