pub struct Schema;Expand description
Database schema management.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn create_tables(conn: &Connection) -> Result<()>
pub fn create_tables(conn: &Connection) -> Result<()>
Create all tables in the database.
Sourcepub fn create_indexes(conn: &Connection) -> Result<()>
pub fn create_indexes(conn: &Connection) -> Result<()>
Create indexes for efficient queries.
Sourcepub fn drop_indexes(conn: &Connection) -> Result<()>
pub fn drop_indexes(conn: &Connection) -> Result<()>
Drop all non-primary indexes (for bulk import performance).
After import completes, call create_indexes to rebuild them.
Sourcepub fn initialize(conn: &Connection) -> Result<()>
pub fn initialize(conn: &Connection) -> Result<()>
Initialize a new database with schema and indexes.
Sourcepub fn get_version(conn: &Connection) -> Result<Option<i32>>
pub fn get_version(conn: &Connection) -> Result<Option<i32>>
Get the current schema version from the database. Returns None if the database is not initialized (table doesn’t exist or no rows).
Sourcepub fn set_metadata(conn: &Connection, key: &str, value: &str) -> Result<()>
pub fn set_metadata(conn: &Connection, key: &str, value: &str) -> Result<()>
Set a metadata value.
Sourcepub fn get_metadata(conn: &Connection, key: &str) -> Result<Option<String>>
pub fn get_metadata(conn: &Connection, key: &str) -> Result<Option<String>>
Get a metadata value.
Sourcepub fn migrate_if_needed(conn: &Connection) -> Result<()>
pub fn migrate_if_needed(conn: &Connection) -> Result<()>
Migrate the database schema if needed.
This handles upgrades from older schema versions to the current version.
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more