mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
Kysely 및 PostgreSQL 도입 (WiP)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { sqliteTable, text, integer, foreignKey } from "drizzle-orm/sqlite-core";
|
||||
import type { ColumnType, Generated, JSONColumnType } from "kysely";
|
||||
import { hsk } from "./hsk";
|
||||
import { mek } from "./mek";
|
||||
import { user } from "./user";
|
||||
@@ -86,3 +87,61 @@ export const fileLog = sqliteTable("file_log", {
|
||||
action: text("action", { enum: ["create", "rename"] }).notNull(),
|
||||
newName: ciphertext("new_name"),
|
||||
});
|
||||
|
||||
type Ciphertext = JSONColumnType<{
|
||||
ciphertext: string; // Base64
|
||||
iv: string; // Base64
|
||||
}>;
|
||||
|
||||
interface DirectoryTable {
|
||||
id: Generated<number>;
|
||||
parent_id: number | null;
|
||||
user_id: number;
|
||||
master_encryption_key_version: number;
|
||||
encrypted_data_encryption_key: string; // Base64
|
||||
data_encryption_key_version: Date;
|
||||
encrypted_name: Ciphertext;
|
||||
}
|
||||
|
||||
interface DirectoryLogTable {
|
||||
id: Generated<number>;
|
||||
directory_id: number;
|
||||
timestamp: ColumnType<Date, Date, never>;
|
||||
action: "create" | "rename";
|
||||
new_name: Ciphertext | null;
|
||||
}
|
||||
|
||||
interface FileTable {
|
||||
id: Generated<number>;
|
||||
parent_id: number | null;
|
||||
user_id: number;
|
||||
path: string;
|
||||
master_encryption_key_version: number;
|
||||
encrypted_data_encryption_key: string; // Base64
|
||||
data_encryption_key_version: Date;
|
||||
hmac_secret_key_version: number | null;
|
||||
content_hmac: string | null; // Base64
|
||||
content_type: string;
|
||||
encrypted_content_iv: string; // Base64
|
||||
encrypted_content_hash: string; // Base64
|
||||
encrypted_name: Ciphertext;
|
||||
encrypted_created_at: Ciphertext | null;
|
||||
encrypted_last_modified_at: Ciphertext;
|
||||
}
|
||||
|
||||
interface FileLogTable {
|
||||
id: Generated<number>;
|
||||
file_id: number;
|
||||
timestamp: ColumnType<Date, Date, never>;
|
||||
action: "create" | "rename";
|
||||
new_name: Ciphertext | null;
|
||||
}
|
||||
|
||||
declare module "./index" {
|
||||
interface Database {
|
||||
directory: DirectoryTable;
|
||||
directory_log: DirectoryLogTable;
|
||||
file: FileTable;
|
||||
file_log: FileLogTable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user