feat(category): save collapse state for signed in users (#2134)
This commit is contained in:
@@ -312,6 +312,24 @@ export const sections = sqliteTable("section", {
|
||||
}),
|
||||
});
|
||||
|
||||
export const sectionCollapseStates = sqliteTable(
|
||||
"section_collapse_state",
|
||||
{
|
||||
userId: text()
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
sectionId: text()
|
||||
.notNull()
|
||||
.references(() => sections.id, { onDelete: "cascade" }),
|
||||
collapsed: int({ mode: "boolean" }).default(false).notNull(),
|
||||
},
|
||||
(table) => ({
|
||||
compoundKey: primaryKey({
|
||||
columns: [table.userId, table.sectionId],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const items = sqliteTable("item", {
|
||||
id: text().notNull().primaryKey(),
|
||||
sectionId: text()
|
||||
@@ -550,6 +568,18 @@ export const sectionRelations = relations(sections, ({ many, one }) => ({
|
||||
fields: [sections.boardId],
|
||||
references: [boards.id],
|
||||
}),
|
||||
collapseStates: many(sectionCollapseStates),
|
||||
}));
|
||||
|
||||
export const sectionCollapseStateRelations = relations(sectionCollapseStates, ({ one }) => ({
|
||||
user: one(users, {
|
||||
fields: [sectionCollapseStates.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
section: one(sections, {
|
||||
fields: [sectionCollapseStates.sectionId],
|
||||
references: [sections.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const itemRelations = relations(items, ({ one, many }) => ({
|
||||
|
||||
Reference in New Issue
Block a user