mirror of
https://github.com/kennethnym/aris.git
synced 2026-06-16 12:31:17 +01:00
feat: add reminder source (#126)
This commit is contained in:
@@ -60,3 +60,66 @@ export const userSources = pgTable(
|
||||
index("user_sources_user_id_enabled_idx").on(t.userId, t.enabled),
|
||||
],
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// FREYA — reminders source storage
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const reminders = pgTable(
|
||||
"reminders",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
title: text("title").notNull(),
|
||||
notes: text("notes"),
|
||||
dueAt: timestamp("due_at").notNull(),
|
||||
timeZone: text("time_zone").notNull().default("UTC"),
|
||||
recurrence: jsonb("recurrence"),
|
||||
priority: text("priority").notNull().default("normal"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at")
|
||||
.notNull()
|
||||
.defaultNow()
|
||||
.$onUpdate(() => new Date()),
|
||||
},
|
||||
(t) => [
|
||||
index("reminders_user_id_due_at_idx").on(t.userId, t.dueAt),
|
||||
index("reminders_user_id_updated_at_idx").on(t.userId, t.updatedAt),
|
||||
],
|
||||
)
|
||||
|
||||
export const reminderOccurrenceOverrides = pgTable(
|
||||
"reminder_occurrence_overrides",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
reminderId: uuid("reminder_id")
|
||||
.notNull()
|
||||
.references(() => reminders.id, { onDelete: "cascade" }),
|
||||
occurrenceId: text("occurrence_id").notNull(),
|
||||
originalDueAt: timestamp("original_due_at").notNull(),
|
||||
patch: jsonb("patch"),
|
||||
completedAt: timestamp("completed_at"),
|
||||
deletedAt: timestamp("deleted_at"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at")
|
||||
.notNull()
|
||||
.defaultNow()
|
||||
.$onUpdate(() => new Date()),
|
||||
},
|
||||
(t) => [
|
||||
unique("reminder_occurrence_overrides_reminder_id_occurrence_id_unique").on(
|
||||
t.reminderId,
|
||||
t.occurrenceId,
|
||||
),
|
||||
index("reminder_occurrence_overrides_user_id_reminder_id_idx").on(t.userId, t.reminderId),
|
||||
index("reminder_occurrence_overrides_user_id_original_due_at_idx").on(
|
||||
t.userId,
|
||||
t.originalDueAt,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user