feat(db): add userFiles table and migration

Introduces the user_files table to track uploaded files per user,
including metadata fields for dimensions, versioning, and tool chains.
This commit is contained in:
Siddharth Kumar Sah
2026-03-26 01:10:50 +08:00
parent c8d2a3f439
commit dda37e90cc
4 changed files with 554 additions and 0 deletions
+16
View File
@@ -5,6 +5,7 @@ export const users = sqliteTable("users", {
username: text("username").notNull().unique(),
passwordHash: text("password_hash").notNull(),
role: text("role", { enum: ["admin", "user"] }).notNull().default("user"),
team: text("team").notNull().default("Default"),
mustChangePassword: integer("must_change_password", { mode: "boolean" }).notNull().default(true),
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => new Date()),
updatedAt: integer("updated_at", { mode: "timestamp" }).notNull().$defaultFn(() => new Date()),
@@ -54,3 +55,18 @@ export const pipelines = sqliteTable("pipelines", {
steps: text("steps").notNull(), // JSON array of { toolId, settings }
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => new Date()),
});
export const userFiles = sqliteTable("user_files", {
id: text("id").primaryKey(),
userId: text("user_id").references(() => users.id, { onDelete: "cascade" }),
originalName: text("original_name").notNull(),
storedName: text("stored_name").notNull(),
mimeType: text("mime_type").notNull(),
size: integer("size").notNull(),
width: integer("width"),
height: integer("height"),
version: integer("version").notNull().default(1),
parentId: text("parent_id"),
toolChain: text("tool_chain"),
createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => new Date()),
});