INNER CODE UNIT · Rust

initialize_postgres_schema

zly2006/zhihu-plus-plus · aigc-vote-server/src/lib.rs:912

async fn initialize_postgres_schema(pool: &PgPool) -> Result<(), ServiceError> {
    let statements = [
        r#"
        CREATE TABLE IF NOT EXISTS clients (
            id TEXT PRIMARY KEY NOT NULL,
            credit BIGINT NOT NULL DEFAULT 1,
            progress BIGINT NOT NULL DEFAULT 0,
            created_at BIGINT NOT NULL,
            last_seen_at BIGINT NOT NULL
        )
        "#,
        "ALTER TABLE clients ALTER COLUMN credit SET DEFAULT 1",
        r#"
        CREATE TABLE IF NOT EXISTS read_events (
            id BIGSERIAL PRIMARY KEY,
            client_id TEXT NOT NULL REFERENCES clients(id),
            content_type TEXT NOT NULL,
            content_id TEXT NOT NULL,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…