Kysely 및 PostgreSQL 도입 (WiP)

This commit is contained in:
static
2025-01-20 10:56:58 +09:00
parent 0002b4e5f2
commit 63eacbb1b3
10 changed files with 399 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import {
foreignKey,
unique,
} from "drizzle-orm/sqlite-core";
import type { ColumnType, Generated } from "kysely";
import { user } from "./user";
export const client = sqliteTable(
@@ -59,3 +60,32 @@ export const userClientChallenge = sqliteTable(
}),
}),
);
interface ClientTable {
id: Generated<number>;
encryption_public_key: string; // Base64
signature_public_key: string; // Base64
}
interface UserClientTable {
user_id: number;
client_id: number;
state: "challenging" | "pending" | "active";
}
interface UserClientChallengeTable {
id: Generated<number>;
user_id: number;
client_id: number;
answer: string; // Base64
allowed_ip: string;
expires_at: ColumnType<Date, Date, never>;
}
declare module "./index" {
interface Database {
client: ClientTable;
user_client: UserClientTable;
user_client_challenge: UserClientChallengeTable;
}
}