feat(18-01): add documentTemplates table and relation to schema.ts
- Add document_templates pgTable with 7 columns: id, name, formTemplateId, signatureFields, archivedAt, createdAt, updatedAt - formTemplateId FK references formTemplates.id with no onDelete cascade - signatureFields typed as SignatureFieldData[] via jsonb, nullable (template starts empty) - archivedAt nullable timestamp for soft-delete (NULL = active) - Add documentTemplatesRelations joining to formTemplates
This commit is contained in:
@@ -98,6 +98,20 @@ export const formTemplates = pgTable("form_templates", {
|
||||
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const documentTemplates = pgTable("document_templates", {
|
||||
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
name: text("name").notNull(),
|
||||
formTemplateId: text("form_template_id").notNull().references(() => formTemplates.id),
|
||||
signatureFields: jsonb("signature_fields").$type<SignatureFieldData[]>(),
|
||||
archivedAt: timestamp("archived_at"),
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const documentTemplatesRelations = relations(documentTemplates, ({ one }) => ({
|
||||
formTemplate: one(formTemplates, { fields: [documentTemplates.formTemplateId], references: [formTemplates.id] }),
|
||||
}));
|
||||
|
||||
/** Shape of each entry in documents.signers JSONB array. */
|
||||
export interface DocumentSigner {
|
||||
email: string;
|
||||
|
||||
Reference in New Issue
Block a user