refactor: replace focusedIndex with activeChildId
- Replace focusedIndex integer with activeChildId string in messages schema - Add migration to convert existing data and drop focused_index column - Add hooks for providers.updatedAt and messageParts.lastUpdatedAt - Add file size column to files table - Update message navigation to use child ID-based lookup - Simplify delete logic by removing focusedIndex math - Fix file delete endpoint filename ([id[ -> [id])
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { files } from "~~/drizzle/schema";
|
||||
import { db } from "~~/server/lib/db";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await protectRoute(event);
|
||||
|
||||
const userId = event.context.user!.id;
|
||||
|
||||
const id = getRouterParam(event, 'id')!;
|
||||
|
||||
const file = await db.delete(files).where(and(eq(files.id, id), eq(files.userId, userId))).returning();
|
||||
|
||||
if (!file) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: 'Not Found',
|
||||
message: 'File not found',
|
||||
});
|
||||
}
|
||||
|
||||
return { ok: true };
|
||||
});
|
||||
Reference in New Issue
Block a user