feat(db): create new URL table and update the existing table to include a foreign key to the URLs table
This commit is contained in:
parent
443c7a7e0c
commit
ce1e93fc49
1 changed files with 12 additions and 2 deletions
14
src/db.rs
14
src/db.rs
|
@ -25,16 +25,26 @@ mod db_impl {
|
|||
// Create the database schema
|
||||
pub async fn create_schema(&self) -> Result<(), Error> {
|
||||
let conn = self.conn.lock().await;
|
||||
conn.execute_batch(
|
||||
"CREATE TABLE IF NOT EXISTS urls (
|
||||
id INTEGER PRIMARY KEY,
|
||||
url TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);",
|
||||
)?;
|
||||
logging::log!("URLs table created or verified");
|
||||
conn.execute_batch(
|
||||
"CREATE TABLE IF NOT EXISTS items (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
wikidata_id TEXT,
|
||||
custom_properties TEXT
|
||||
custom_properties TEXT,
|
||||
url_id INTEGER,
|
||||
FOREIGN KEY (url_id) REFERENCES urls (id)
|
||||
);",
|
||||
)?;
|
||||
logging::log!("Database schema created or verified");
|
||||
logging::log!("Items table updated with foreign key to URLs table");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue