yugendb_postgres/
schema.rs1pub const STORE_TABLE_NAME: &str = "yugendb_store";
8pub const SCHEMA_VERSION: u32 = 1;
10pub const MIGRATION_METADATA_TABLE_NAME: &str = "yugendb_migrations";
12pub const VALUE_COLUMN_TYPE: &str = "BYTEA";
14
15pub const CREATE_STORE_TABLE_SQL: &str = "CREATE TABLE IF NOT EXISTS yugendb_store (
17 namespace TEXT NOT NULL,
18 collection TEXT NOT NULL,
19 key TEXT NOT NULL,
20 value BYTEA NOT NULL,
21 codec TEXT NOT NULL,
22 created_at TEXT NOT NULL,
23 updated_at TEXT NOT NULL,
24 expires_at TEXT,
25 PRIMARY KEY (namespace, collection, key)
26);";
27
28pub const CREATE_PREFIX_INDEX_SQL: &str = "CREATE INDEX IF NOT EXISTS idx_yugendb_store_prefix ON yugendb_store(namespace, collection, key);";
30pub const CREATE_EXPIRES_AT_INDEX_SQL: &str =
32 "CREATE INDEX IF NOT EXISTS idx_yugendb_store_expires_at ON yugendb_store(expires_at);";
33pub const ALL_SCHEMA_STATEMENTS: [&str; 3] = [
35 CREATE_STORE_TABLE_SQL,
36 CREATE_PREFIX_INDEX_SQL,
37 CREATE_EXPIRES_AT_INDEX_SQL,
38];
39
40#[must_use]
42pub const fn schema_statements() -> [&'static str; 3] {
43 ALL_SCHEMA_STATEMENTS
44}
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48pub struct PostgresDriverStorageSchema {
49 pub version: u32,
51 pub store_table_name: &'static str,
53 pub migration_metadata_table_name: &'static str,
55 pub value_column_type: &'static str,
57}
58
59impl PostgresDriverStorageSchema {
60 #[must_use]
62 pub const fn current() -> Self {
63 Self {
64 version: SCHEMA_VERSION,
65 store_table_name: STORE_TABLE_NAME,
66 migration_metadata_table_name: MIGRATION_METADATA_TABLE_NAME,
67 value_column_type: VALUE_COLUMN_TYPE,
68 }
69 }
70}