feat(issues): add issue documents and inline editing
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
30
packages/db/src/schema/issue_documents.ts
Normal file
30
packages/db/src/schema/issue_documents.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { pgTable, uuid, text, timestamp, index, uniqueIndex } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { issues } from "./issues.js";
|
||||
import { documents } from "./documents.js";
|
||||
|
||||
export const issueDocuments = pgTable(
|
||||
"issue_documents",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id),
|
||||
issueId: uuid("issue_id").notNull().references(() => issues.id, { onDelete: "cascade" }),
|
||||
documentId: uuid("document_id").notNull().references(() => documents.id, { onDelete: "cascade" }),
|
||||
key: text("key").notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
companyIssueKeyUq: uniqueIndex("issue_documents_company_issue_key_uq").on(
|
||||
table.companyId,
|
||||
table.issueId,
|
||||
table.key,
|
||||
),
|
||||
documentUq: uniqueIndex("issue_documents_document_uq").on(table.documentId),
|
||||
companyIssueUpdatedIdx: index("issue_documents_company_issue_updated_idx").on(
|
||||
table.companyId,
|
||||
table.issueId,
|
||||
table.updatedAt,
|
||||
),
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user