thumbnail 테이블의 created_at 컬럼의 이름을 updated_at으로 변경

This commit is contained in:
static
2025-07-05 05:54:55 +09:00
parent 36d082e0f8
commit c236242136
6 changed files with 13 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ import db from "./kysely";
interface Thumbnail { interface Thumbnail {
id: number; id: number;
path: string; path: string;
createdAt: Date; updatedAt: Date;
encContentIv: string; encContentIv: string;
} }
@@ -49,13 +49,13 @@ export const updateFileThumbnail = async (
.values({ .values({
file_id: fileId, file_id: fileId,
path, path,
created_at: now, updated_at: now,
encrypted_content_iv: encContentIv, encrypted_content_iv: encContentIv,
}) })
.onConflict((oc) => .onConflict((oc) =>
oc.column("file_id").doUpdateSet({ oc.column("file_id").doUpdateSet({
path, path,
created_at: now, updated_at: now,
encrypted_content_iv: encContentIv, encrypted_content_iv: encContentIv,
}), }),
) )
@@ -80,7 +80,7 @@ export const getFileThumbnail = async (userId: number, fileId: number) => {
fileId: thumbnail.file_id, fileId: thumbnail.file_id,
path: thumbnail.path, path: thumbnail.path,
encContentIv: thumbnail.encrypted_content_iv, encContentIv: thumbnail.encrypted_content_iv,
createdAt: thumbnail.created_at, updatedAt: thumbnail.updated_at,
} satisfies FileThumbnail) } satisfies FileThumbnail)
: null; : null;
}; };

View File

@@ -16,7 +16,7 @@ export const up = async (db: Kysely<any>) => {
col.references("category.id").onDelete("cascade").unique(), col.references("category.id").onDelete("cascade").unique(),
) )
.addColumn("path", "text", (col) => col.unique().notNull()) .addColumn("path", "text", (col) => col.unique().notNull())
.addColumn("created_at", "timestamp(3)", (col) => col.notNull()) .addColumn("updated_at", "timestamp(3)", (col) => col.notNull())
.addColumn("encrypted_content_iv", "text", (col) => col.notNull()) .addColumn("encrypted_content_iv", "text", (col) => col.notNull())
.addCheckConstraint( .addCheckConstraint(
"thumbnail_ck01", "thumbnail_ck01",

View File

@@ -6,7 +6,7 @@ interface ThumbnailTable {
file_id: number | null; file_id: number | null;
category_id: number | null; category_id: number | null;
path: string; path: string;
created_at: Date; updated_at: Date;
encrypted_content_iv: string; // Base64 encrypted_content_iv: string; // Base64
} }

View File

@@ -31,6 +31,7 @@ export const fileRenameRequest = z.object({
export type FileRenameRequest = z.infer<typeof fileRenameRequest>; export type FileRenameRequest = z.infer<typeof fileRenameRequest>;
export const fileThumbnailInfoResponse = z.object({ export const fileThumbnailInfoResponse = z.object({
updatedAt: z.string().datetime(),
encContentIv: z.string().base64().nonempty(), encContentIv: z.string().base64().nonempty(),
}); });
export type FileThumbnailInfoResponse = z.infer<typeof fileThumbnailInfoResponse>; export type FileThumbnailInfoResponse = z.infer<typeof fileThumbnailInfoResponse>;

View File

@@ -92,7 +92,7 @@ export const getFileThumbnailInformation = async (userId: number, fileId: number
error(404, "File or its thumbnail not found"); error(404, "File or its thumbnail not found");
} }
return { encContentIv: thumbnail.encContentIv }; return { updatedAt: thumbnail.updatedAt, encContentIv: thumbnail.encContentIv };
}; };
export const getFileThumbnailStream = async (userId: number, fileId: number) => { export const getFileThumbnailStream = async (userId: number, fileId: number) => {

View File

@@ -16,8 +16,11 @@ export const GET: RequestHandler = async ({ locals, params }) => {
if (!zodRes.success) error(400, "Invalid path parameters"); if (!zodRes.success) error(400, "Invalid path parameters");
const { id } = zodRes.data; const { id } = zodRes.data;
const { encContentIv } = await getFileThumbnailInformation(userId, id); const { updatedAt, encContentIv } = await getFileThumbnailInformation(userId, id);
return json( return json(
fileThumbnailInfoResponse.parse({ encContentIv } satisfies FileThumbnailInfoResponse), fileThumbnailInfoResponse.parse({
updatedAt: updatedAt.toISOString(),
encContentIv,
} satisfies FileThumbnailInfoResponse),
); );
}; };