pub const STORE_TABLE_NAME: &str = "yugendb_store";
pub const SCHEMA_VERSION: u32 = 1;
pub const MIGRATION_METADATA_TABLE_NAME: &str = "yugendb_migrations";
pub const VALUE_COLUMN_TYPE: &str = "LONGBLOB";
pub const CREATE_STORE_TABLE_SQL: &str = "CREATE TABLE IF NOT EXISTS yugendb_store (
namespace VARCHAR(512) NOT NULL,
collection VARCHAR(512) NOT NULL,
`key` VARCHAR(512) NOT NULL,
value LONGBLOB NOT NULL,
codec TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
expires_at TEXT,
PRIMARY KEY (namespace, collection, `key`)
);";
pub const CREATE_PREFIX_INDEX_SQL: &str = "CREATE INDEX idx_yugendb_store_prefix ON yugendb_store(namespace(191), collection(191), `key`(191));";
pub const CREATE_EXPIRES_AT_INDEX_SQL: &str =
"CREATE INDEX idx_yugendb_store_expires_at ON yugendb_store(expires_at(191));";
pub const ALL_SCHEMA_STATEMENTS: [&str; 1] = [CREATE_STORE_TABLE_SQL];
#[must_use]
pub const fn schema_statements() -> [&'static str; 1] {
ALL_SCHEMA_STATEMENTS
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MysqlDriverStorageSchema {
pub version: u32,
pub store_table_name: &'static str,
pub migration_metadata_table_name: &'static str,
pub value_column_type: &'static str,
}
impl MysqlDriverStorageSchema {
#[must_use]
pub const fn current() -> Self {
Self {
version: SCHEMA_VERSION,
store_table_name: STORE_TABLE_NAME,
migration_metadata_table_name: MIGRATION_METADATA_TABLE_NAME,
value_column_type: VALUE_COLUMN_TYPE,
}
}
}