This commit is contained in:
2026-06-06 17:02:45 -04:00
parent 47609e5e42
commit db4c656730
22 changed files with 6195 additions and 326 deletions

View File

@@ -113,6 +113,51 @@ export const plantViews = sqliteTable(
}),
);
// ─── Flagged Content Table ─────────────────────────────────────────────────
/**
* Stores user-flagged content for manual review.
* content_type: what kind of content is flagged
* content_id: the ID of the plant or disease
* field_name: specific field being flagged (e.g., "image", "symptoms", "causes", "treatment", "prevention")
* flag_count: number of times this item has been flagged
*/
export const flaggedContent = sqliteTable(
"flagged_content",
{
id: text("id").primaryKey(),
contentType: text("content_type", {
enum: [
"plant_image",
"disease_image",
"disease_symptoms",
"disease_causes",
"disease_treatment",
"disease_prevention",
],
}).notNull(),
contentId: text("content_id").notNull(),
fieldName: text("field_name").notNull(),
notes: text("notes").default(""),
flagCount: integer("flag_count").notNull().default(1),
createdAt: text("created_at")
.notNull()
.default(sql`(datetime('now'))`),
updatedAt: text("updated_at")
.notNull()
.default(sql`(datetime('now'))`),
},
(table) => ({
contentTypeIdx: index("idx_flagged_content_type").on(table.contentType),
contentIdIdx: index("idx_flagged_content_id").on(table.contentId),
}),
);
// ─── Type helpers ────────────────────────────────────────────────────────────
export type FlaggedContentRow = typeof flaggedContent.$inferSelect;
export type FlaggedContentInsert = typeof flaggedContent.$inferInsert;
// ─── Relation Inference ──────────────────────────────────────────────────────
export const plantsRelations = {};