Add a foreign key constraint to link invoices to specific jobs

Adds a foreign key constraint to the `invoices` table, referencing the `id` column in the `jobs` table, ensuring data integrity.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 418bf6f8-212b-4bb0-a7a5-8231a061da4e
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: d9dd1cc2-bc61-41c5-90bb-94504f4308a9
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
alexpaynex
2026-03-18 15:21:33 +00:00
parent 44f7e24b45
commit 9ec5e20a10

View File

@@ -1,13 +1,14 @@
import { pgTable, text, integer, boolean, timestamp } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { z } from "zod/v4";
import { jobs } from "./jobs";
export const INVOICE_TYPES = ["eval", "work"] as const;
export type InvoiceType = (typeof INVOICE_TYPES)[number];
export const invoices = pgTable("invoices", {
id: text("id").primaryKey(),
jobId: text("job_id").notNull(),
jobId: text("job_id").notNull().references(() => jobs.id),
paymentHash: text("payment_hash").notNull().unique(),
paymentRequest: text("payment_request").notNull(),
amountSats: integer("amount_sats").notNull(),