Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(company): add watchlist columns to Company, the model type and the backup schema

Khuram Niaz320ff3cb02bc
diff --git a/__tests__/backupRoundTrip.spec.ts b/__tests__/backupRoundTrip.spec.ts
index 19c6d6f..b9677f9 100644
--- a/__tests__/backupRoundTrip.spec.ts
+++ b/__tests__/backupRoundTrip.spec.ts
@@ -50,7 +50,19 @@ afterAll(async () => {
async function seedFullAccount() {
const company = await prisma.company.create({
- data: { label: "Acme", value: "acme", createdBy: userId },
+ data: {
+ label: "Acme",
+ value: "acme",
+ createdBy: userId,
+ watched: true,
+ watchedAt: new Date("2026-09-01T10:00:00.000Z"),
+ atsProvider: "greenhouse",
+ atsToken: "acme",
+ atsHost: null,
+ websiteUrl: "https://acme.example.com",
+ careersUrl: "https://acme.example.com/careers",
+ industry: "Widgets",
+ },
});
const title = await prisma.jobTitle.create({
data: { label: "Engineer", value: "engineer", createdBy: userId },
@@ -272,6 +284,22 @@ describe("backup round trip", () => {
expect(fs.readFileSync(file.filePath).toString()).toContain("seed");
}, 120_000);
+ it("restores every watchlist column on Company, watchedAt as a Date", async () => {
+ const [restored] = await prisma.company.findMany({
+ where: { createdBy: userId, value: "acme" },
+ });
+
+ expect(restored.watched).toBe(true);
+ expect(restored.watchedAt).toBeInstanceOf(Date);
+ expect(restored.watchedAt?.toISOString()).toBe("2026-09-01T10:00:00.000Z");
+ expect(restored.atsProvider).toBe("greenhouse");
+ expect(restored.atsToken).toBe("acme");
+ expect(restored.atsHost).toBeNull();
+ expect(restored.websiteUrl).toBe("https://acme.example.com");
+ expect(restored.careersUrl).toBe("https://acme.example.com/careers");
+ expect(restored.industry).toBe("Widgets");
+ });
+
it("does not demand confirmWipe on a freshly signed-up account", async () => {
const freshUserId = await seedAccount(prisma, "[email protected]");
const { buffer } = await buildBackupZip(userId, "[email protected]");
diff --git a/prisma/migrations/20260907153300_company_watchlist/migration.sql b/prisma/migrations/20260907153300_company_watchlist/migration.sql
new file mode 100644
index 0000000..4320823
--- /dev/null
+++ b/prisma/migrations/20260907153300_company_watchlist/migration.sql
@@ -0,0 +1,28 @@
+-- RedefineTables
+PRAGMA defer_foreign_keys=ON;
+PRAGMA foreign_keys=OFF;
+CREATE TABLE "new_Company" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "label" TEXT NOT NULL,
+ "value" TEXT NOT NULL,
+ "logoUrl" TEXT,
+ "createdBy" TEXT NOT NULL,
+ "watched" BOOLEAN NOT NULL DEFAULT false,
+ "watchedAt" DATETIME,
+ "atsProvider" TEXT,
+ "atsToken" TEXT,
+ "atsHost" TEXT,
+ "websiteUrl" TEXT,
+ "careersUrl" TEXT,
+ "industry" TEXT,
+ CONSTRAINT "Company_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+INSERT INTO "new_Company" ("createdBy", "id", "label", "logoUrl", "value") SELECT "createdBy", "id", "label", "logoUrl", "value" FROM "Company";
+DROP TABLE "Company";
+ALTER TABLE "new_Company" RENAME TO "Company";
+CREATE INDEX "Company_createdBy_watched_idx" ON "Company"("createdBy", "watched");
+CREATE UNIQUE INDEX "Company_value_createdBy_key" ON "Company"("value", "createdBy");
+CREATE UNIQUE INDEX "Company_createdBy_atsProvider_atsToken_key" ON "Company"("createdBy", "atsProvider", "atsToken");
+PRAGMA foreign_keys=ON;
+PRAGMA defer_foreign_keys=OFF;
+
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 9183f3e..360717b 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -261,7 +261,23 @@ model Company {
user User @relation(fields: [createdBy], references: [id])
workExperiences WorkExperience[]
+ // Watch intent — independent of whether a board is linked
+ watched Boolean @default(false)
+ watchedAt DateTime?
+
+ // Board coordinates; atsHost is Lever-only
+ atsProvider String?
+ atsToken String?
+ atsHost String?
+
+ // Company attributes, unrelated to boards
+ websiteUrl String?
+ careersUrl String?
+ industry String?
+
@@unique([value, createdBy])
+ @@unique([createdBy, atsProvider, atsToken])
+ @@index([createdBy, watched])
}
model JobSource {
diff --git a/src/lib/backup/schema.ts b/src/lib/backup/schema.ts
index f9d29ef..635c22b 100644
--- a/src/lib/backup/schema.ts
+++ b/src/lib/backup/schema.ts
@@ -21,7 +21,22 @@ const optDt = z.coerce.date().nullable();
const int = z.number().int();
const optInt = z.number().int().nullable();
-const Company = z.object({ id, label: str, value: str, logoUrl: optStr });
+// The watchlist columns are optional, not just nullable: a backup taken before
+// they existed has no such key, and undefined leaves Prisma on the default.
+const Company = z.object({
+ id,
+ label: str,
+ value: str,
+ logoUrl: optStr,
+ watched: z.boolean().optional(),
+ watchedAt: optDt.optional(),
+ atsProvider: optStr.optional(),
+ atsToken: optStr.optional(),
+ atsHost: optStr.optional(),
+ websiteUrl: optStr.optional(),
+ careersUrl: optStr.optional(),
+ industry: optStr.optional(),
+});
const JobTitle = z.object({ id, label: str, value: str });
const Location = z.object({
id,
diff --git a/src/models/job.model.ts b/src/models/job.model.ts
index da89d58..d021c61 100644
--- a/src/models/job.model.ts
+++ b/src/models/job.model.ts
@@ -1,3 +1,4 @@
+import type { JobBoard, LeverHost } from "@/models/automation.model";
import { CoverLetter, Resume } from "./profile.model";
export interface JobForm {
@@ -79,6 +80,14 @@ export interface Company {
value: string;
createdBy: string;
logoUrl?: string;
+ watched?: boolean;
+ watchedAt?: Date | null;
+ atsProvider?: JobBoard | null;
+ atsToken?: string | null;
+ atsHost?: LeverHost | null;
+ websiteUrl?: string | null;
+ careersUrl?: string | null;
+ industry?: string | null;
_count?: {
jobsApplied: number;
jobsRejected?: number;