mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-07-09 11:26:00 +00:00
feat(anotações): permite anexos em notas
This commit is contained in:
@@ -847,11 +847,12 @@ export const budgetsRelations = relations(budgets, ({ one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const notesRelations = relations(notes, ({ one }) => ({
|
||||
export const notesRelations = relations(notes, ({ one, many }) => ({
|
||||
user: one(user, {
|
||||
fields: [notes.userId],
|
||||
references: [user.id],
|
||||
}),
|
||||
noteAttachments: many(noteAttachments),
|
||||
}));
|
||||
|
||||
export const savedInsightsRelations = relations(savedInsights, ({ one }) => ({
|
||||
@@ -972,6 +973,24 @@ export const transactionAttachments = pgTable(
|
||||
}),
|
||||
);
|
||||
|
||||
export const noteAttachments = pgTable(
|
||||
"anotacao_anexos",
|
||||
{
|
||||
noteId: uuid("anotacao_id")
|
||||
.notNull()
|
||||
.references(() => notes.id, { onDelete: "cascade" }),
|
||||
attachmentId: uuid("anexo_id")
|
||||
.notNull()
|
||||
.references(() => attachments.id, { onDelete: "cascade" }),
|
||||
},
|
||||
(table) => ({
|
||||
pk: primaryKey({ columns: [table.noteId, table.attachmentId] }),
|
||||
attachmentIdIdx: index("anotacao_anexos_anexo_id_idx").on(
|
||||
table.attachmentId,
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
export const importCategoryMappings = pgTable(
|
||||
"import_category_mappings",
|
||||
{
|
||||
@@ -1044,6 +1063,7 @@ export const attachmentsRelations = relations(attachments, ({ one, many }) => ({
|
||||
references: [user.id],
|
||||
}),
|
||||
transactionAttachments: many(transactionAttachments),
|
||||
noteAttachments: many(noteAttachments),
|
||||
}));
|
||||
|
||||
export const transactionAttachmentsRelations = relations(
|
||||
@@ -1060,8 +1080,23 @@ export const transactionAttachmentsRelations = relations(
|
||||
}),
|
||||
);
|
||||
|
||||
export const noteAttachmentsRelations = relations(
|
||||
noteAttachments,
|
||||
({ one }) => ({
|
||||
note: one(notes, {
|
||||
fields: [noteAttachments.noteId],
|
||||
references: [notes.id],
|
||||
}),
|
||||
attachment: one(attachments, {
|
||||
fields: [noteAttachments.attachmentId],
|
||||
references: [attachments.id],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export type Attachment = typeof attachments.$inferSelect;
|
||||
export type TransactionAttachment = typeof transactionAttachments.$inferSelect;
|
||||
export type NoteAttachment = typeof noteAttachments.$inferSelect;
|
||||
|
||||
export const establishmentLogosRelations = relations(
|
||||
establishmentLogos,
|
||||
|
||||
Reference in New Issue
Block a user