diff --git a/app/components/AppTopBar.vue b/app/components/AppTopBar.vue index 0c0ae7d3..3449f8a5 100644 --- a/app/components/AppTopBar.vue +++ b/app/components/AppTopBar.vue @@ -6,7 +6,7 @@ import { ChevronDown, Menu, X, Users, ChevronLeft, LayoutDashboard, Calendar, ArrowUpCircle, Sparkles, Radio, History, - MessageCircle, Languages, Lock, Inbox, Upload, + MessageCircle, Languages, Lock, Inbox, Upload, Zap, } from 'lucide-vue-next' import type { PlanFeature } from '~~/shared/billing' @@ -111,6 +111,7 @@ const jobTabs = computed(() => { { label: 'Import', to: `${base}/import`, icon: Upload, exact: true }, { label: 'Inbox', to: `${base}/inbox`, icon: Inbox, exact: true }, { label: 'Application Form', to: `${base}/application-form`, icon: FileText, exact: true }, + { label: 'Automation', to: `${base}/rules`, icon: Zap, exact: true }, { label: 'Source Tracking', to: `${base}/source-tracking`, icon: Radio, exact: true }, { label: 'AI Analysis', to: `${base}/ai-analysis`, icon: Sparkles, exact: true }, { label: 'Settings', to: `${base}/settings`, icon: Settings, exact: true }, diff --git a/app/components/ApplicationBuilder.vue b/app/components/ApplicationBuilder.vue index 982fce9f..ffe5a711 100644 --- a/app/components/ApplicationBuilder.vue +++ b/app/components/ApplicationBuilder.vue @@ -1,7 +1,7 @@ + + diff --git a/app/composables/useApplicationRules.ts b/app/composables/useApplicationRules.ts new file mode 100644 index 00000000..d0ac399e --- /dev/null +++ b/app/composables/useApplicationRules.ts @@ -0,0 +1,55 @@ +import type { MaybeRefOrGetter } from 'vue' +import type { ApplicationRuleInput } from '~~/shared/application-rules' + +export interface ApplicationRule extends ApplicationRuleInput { + id: string + jobId: string + displayOrder: number +} + +/** + * Composable for managing a job's application automation rules. + * The builder edits a local draft and saves the whole set atomically (PUT). + */ +export function useApplicationRules(jobId: MaybeRefOrGetter) { + const { handlePreviewReadOnlyError } = usePreviewReadOnly() + const id = computed(() => toValue(jobId)) + + const { data, status, error, refresh } = useFetch( + () => `/api/jobs/${id.value}/rules`, + { + key: computed(() => `job-rules-${id.value}`), + headers: useRequestHeaders(['cookie']), + default: () => ({ rules: [] as ApplicationRule[] }), + }, + ) + + const rules = computed(() => data.value?.rules ?? []) + + /** Replace the entire rule set for the job. */ + async function saveRules(payload: ApplicationRuleInput[]) { + try { + const res = await $fetch(`/api/jobs/${id.value}/rules`, { + method: 'PUT', + body: { rules: payload }, + }) + await refresh() + return res + } catch (err) { + handlePreviewReadOnlyError(err) + throw err + } + } + + /** Retroactively apply the saved rules to existing `new` applicants. */ + async function runRules() { + try { + return await $fetch(`/api/jobs/${id.value}/rules/run`, { method: 'POST' }) + } catch (err) { + handlePreviewReadOnlyError(err) + throw err + } + } + + return { rules, status, error, refresh, saveRules, runRules } +} diff --git a/app/composables/useTimeline.ts b/app/composables/useTimeline.ts index 42353e50..bebe5549 100644 --- a/app/composables/useTimeline.ts +++ b/app/composables/useTimeline.ts @@ -10,7 +10,7 @@ export interface TimelineItem { resourceId: string metadata: Record | null createdAt: string - actorId: string + actorId: string | null actorName: string | null actorEmail: string | null actorImage: string | null diff --git a/app/pages/dashboard/jobs/[id]/index.vue b/app/pages/dashboard/jobs/[id]/index.vue index 060a8079..ced638ca 100644 --- a/app/pages/dashboard/jobs/[id]/index.vue +++ b/app/pages/dashboard/jobs/[id]/index.vue @@ -7,7 +7,7 @@ import { CheckCircle2, XCircle, AlertTriangle, ArrowUpDown, ListFilter, Maximize2, Minimize2, Brain, History, SlidersHorizontal, ChevronLeft, ChevronRight, UnfoldHorizontal, FoldHorizontal, - StickyNote, MoreHorizontal, Inbox, + StickyNote, MoreHorizontal, Inbox, Zap, } from 'lucide-vue-next' import type { Component } from 'vue' import type { Interview, InterviewMutationResult } from '~/composables/useInterviews' @@ -411,6 +411,7 @@ type SwipeApplicationDetail = { score: number | null notes: string | null coverLetterText: string | null + autoRule: { ruleId: string; ruleName: string; action: string; matchedQuestionIds: string[] } | null createdAt: string | Date updatedAt: string | Date candidate: { @@ -451,6 +452,14 @@ const { // the very first load is this null. const resolvedCurrentApplication = computed(() => currentApplication.value ?? null) +// The automation rule (if any) that auto-set this application's status on +// submit, plus a lookup of which responses triggered it — drives the "Auto" +// status badge and the per-response trigger badges. +const autoRule = computed(() => resolvedCurrentApplication.value?.autoRule ?? null) +function isRuleTriggerQuestion(questionId: string | undefined): boolean { + return !!questionId && !!autoRule.value?.matchedQuestionIds?.includes(questionId) +} + // True while what we're showing no longer belongs to the selected candidate, // i.e. a fetch for the newly selected candidate is still in flight. const isDetailStale = computed(() => @@ -1815,6 +1824,14 @@ function closeDocPreview() { > {{ currentSummary.status }} + + + Auto + -
+
+

+ + AI Analysis +

-

- {{ response.question?.label ?? 'Unknown question' }} -

+
+

+ {{ response.question?.label ?? 'Unknown question' }} +

+ + + Triggered “{{ autoRule?.ruleName }}” + +

{{ formatResponseValue(response.value) }}

@@ -2523,14 +2555,12 @@ function closeDocPreview() {
-
+
+

+ + Properties +

-
-
- -
-

Properties

-
+import type { ApplicationRuleInput, QuestionType } from '~~/shared/application-rules' + +definePageMeta({ + layout: 'dashboard', + middleware: ['auth', 'require-org'], +}) + +const route = useRoute() +const jobId = route.params.id as string +const toast = useToast() +const { handlePreviewReadOnlyError } = usePreviewReadOnly() + +const { job } = useJob(jobId) +const { questions } = useJobQuestions(jobId) +const { rules, status, error, saveRules, runRules } = useApplicationRules(jobId) + +useSeoMeta({ + title: computed(() => + job.value ? `Automation Rules — ${job.value.title} — Reqcore` : 'Automation Rules — Reqcore', + ), +}) + +const builderQuestions = computed(() => + (questions.value ?? []).map((q: any) => ({ + id: q.id, + label: q.label, + type: q.type as QuestionType, + options: q.options ?? null, + })), +) + +const saving = ref(false) +const running = ref(false) + +async function onSave(payload: ApplicationRuleInput[]) { + saving.value = true + try { + await saveRules(payload) + toast.success('Rules saved', 'New applicants will be categorized automatically.') + } catch (err: any) { + if (handlePreviewReadOnlyError(err)) return + toast.error('Failed to save rules', { message: err.data?.statusMessage, statusCode: err.data?.statusCode }) + } finally { + saving.value = false + } +} + +async function onRun() { + running.value = true + try { + const res = await runRules() + if (res.matched === 0) { + toast.info('No matches', `Checked ${res.evaluated} applicant${res.evaluated === 1 ? '' : 's'} — none matched your rules.`) + } else { + const parts = Object.entries(res.byAction).map(([action, n]) => `${n} → ${action}`) + toast.success(`${res.matched} applicant${res.matched === 1 ? '' : 's'} updated`, parts.join(', ')) + refreshNuxtData(`pipeline-apps-${jobId}`) + } + } catch (err: any) { + if (handlePreviewReadOnlyError(err)) return + toast.error('Failed to run rules', { message: err.data?.statusMessage, statusCode: err.data?.statusCode }) + } finally { + running.value = false + } +} + + + diff --git a/server/api/activity-log/candidate-timeline.get.ts b/server/api/activity-log/candidate-timeline.get.ts index 870fa728..a479379a 100644 --- a/server/api/activity-log/candidate-timeline.get.ts +++ b/server/api/activity-log/candidate-timeline.get.ts @@ -58,7 +58,8 @@ export default defineEventHandler(async (event) => { actorImage: user.image, }) .from(activityLog) - .innerJoin(user, eq(user.id, activityLog.actorId)) + // Left join: system-actor entries (null actorId) still appear in the timeline. + .leftJoin(user, eq(user.id, activityLog.actorId)) .where(and( eq(activityLog.organizationId, orgId), or(...resourceConditions), diff --git a/server/api/activity-log/timeline.get.ts b/server/api/activity-log/timeline.get.ts index 6b149ffd..572e4ea5 100644 --- a/server/api/activity-log/timeline.get.ts +++ b/server/api/activity-log/timeline.get.ts @@ -62,7 +62,8 @@ export default defineEventHandler(async (event) => { actorImage: user.image, }) .from(activityLog) - .innerJoin(user, eq(user.id, activityLog.actorId)) + // Left join: system-actor entries (null actorId) still appear in the timeline. + .leftJoin(user, eq(user.id, activityLog.actorId)) .where(where) .orderBy(desc(activityLog.createdAt)) .limit(query.limit + 1) // fetch one extra to know if there's more diff --git a/server/api/jobs/[id]/rules/index.get.ts b/server/api/jobs/[id]/rules/index.get.ts new file mode 100644 index 00000000..5cb62205 --- /dev/null +++ b/server/api/jobs/[id]/rules/index.get.ts @@ -0,0 +1,32 @@ +import { eq, and, asc } from 'drizzle-orm' +import { applicationRule, job } from '../../../../database/schema' +import { ruleJobIdParamSchema } from '../../../../utils/schemas/applicationRule' + +/** + * GET /api/jobs/:id/rules + * List all automation rules for a job, ordered by displayOrder. + */ +export default defineEventHandler(async (event) => { + const session = await requirePermission(event, { job: ['read'] }) + const orgId = session.session.activeOrganizationId + const { id: jobId } = await getValidatedRouterParams(event, ruleJobIdParamSchema.parse) + + const jobRecord = await db.query.job.findFirst({ + where: and(eq(job.id, jobId), eq(job.organizationId, orgId)), + columns: { id: true }, + }) + if (!jobRecord) { + throw createError({ statusCode: 404, statusMessage: 'Job not found' }) + } + + const rules = await db + .select() + .from(applicationRule) + .where(and( + eq(applicationRule.jobId, jobId), + eq(applicationRule.organizationId, orgId), + )) + .orderBy(asc(applicationRule.displayOrder)) + + return { rules } +}) diff --git a/server/api/jobs/[id]/rules/index.put.ts b/server/api/jobs/[id]/rules/index.put.ts new file mode 100644 index 00000000..7adbc9e6 --- /dev/null +++ b/server/api/jobs/[id]/rules/index.put.ts @@ -0,0 +1,71 @@ +import { eq, and, asc } from 'drizzle-orm' +import { applicationRule, job } from '../../../../database/schema' +import { bulkRulesSchema, ruleJobIdParamSchema } from '../../../../utils/schemas/applicationRule' + +/** + * PUT /api/jobs/:id/rules + * Replace the full automation-rule set for a job (atomic save from the builder). + * displayOrder is derived from array position. + */ +export default defineEventHandler(async (event) => { + const session = await requirePermission(event, { job: ['update'] }) + const orgId = session.session.activeOrganizationId + const { id: jobId } = await getValidatedRouterParams(event, ruleJobIdParamSchema.parse) + const body = await readValidatedBody(event, bulkRulesSchema.parse) + + const jobRecord = await db.query.job.findFirst({ + where: and(eq(job.id, jobId), eq(job.organizationId, orgId)), + columns: { id: true }, + }) + if (!jobRecord) { + throw createError({ statusCode: 404, statusMessage: 'Job not found' }) + } + + const saved = await db.transaction(async (tx) => { + await tx.delete(applicationRule) + .where(and( + eq(applicationRule.jobId, jobId), + eq(applicationRule.organizationId, orgId), + )) + + if (body.rules.length === 0) return [] + + return tx.insert(applicationRule) + .values(body.rules.map((r, index) => ({ + organizationId: orgId, + jobId, + name: r.name, + matchType: r.matchType, + action: r.action, + enabled: r.enabled, + conditions: r.conditions, + displayOrder: index, + }))) + .returning() + }) + + recordActivity({ + organizationId: orgId, + actorId: session.user.id, + action: 'updated', + resourceType: 'applicationRules', + resourceId: jobId, + metadata: { count: saved.length }, + }) + + logApiRequest(event, session, 'application_rules.saved', { + job_id: jobId, + rule_count: saved.length, + }) + + const rules = await db + .select() + .from(applicationRule) + .where(and( + eq(applicationRule.jobId, jobId), + eq(applicationRule.organizationId, orgId), + )) + .orderBy(asc(applicationRule.displayOrder)) + + return { rules } +}) diff --git a/server/api/jobs/[id]/rules/run.post.ts b/server/api/jobs/[id]/rules/run.post.ts new file mode 100644 index 00000000..716e2ebf --- /dev/null +++ b/server/api/jobs/[id]/rules/run.post.ts @@ -0,0 +1,34 @@ +import { eq, and } from 'drizzle-orm' +import { job } from '../../../../database/schema' +import { ruleJobIdParamSchema } from '../../../../utils/schemas/applicationRule' +import { applyRulesToNewJobApplications } from '../../../../utils/rules/applyRules' + +/** + * POST /api/jobs/:id/rules/run + * Retroactively evaluate the current rule set against every application still in + * `new` for this job. Useful right after editing rules to catch applicants who + * came in before the rule existed. Only `new` applications are touched. + */ +export default defineEventHandler(async (event) => { + const session = await requirePermission(event, { application: ['update'] }) + const orgId = session.session.activeOrganizationId + const { id: jobId } = await getValidatedRouterParams(event, ruleJobIdParamSchema.parse) + + const jobRecord = await db.query.job.findFirst({ + where: and(eq(job.id, jobId), eq(job.organizationId, orgId)), + columns: { id: true }, + }) + if (!jobRecord) { + throw createError({ statusCode: 404, statusMessage: 'Job not found' }) + } + + const result = await applyRulesToNewJobApplications(jobId, orgId) + + logApiRequest(event, session, 'application_rules.run', { + job_id: jobId, + evaluated: result.evaluated, + matched: result.matched, + }) + + return result +}) diff --git a/server/api/public/jobs/[slug]/apply.post.ts b/server/api/public/jobs/[slug]/apply.post.ts index 6787c5ff..34231d3f 100644 --- a/server/api/public/jobs/[slug]/apply.post.ts +++ b/server/api/public/jobs/[slug]/apply.post.ts @@ -14,6 +14,7 @@ import { } from '../../../../utils/schemas/document' import { restoreCandidateForPublicApplication } from '../../../../utils/candidate-retention' import { enqueueNotification } from '../../../../utils/notifications/enqueue' +import { applyRulesToApplication } from '../../../../utils/rules/applyRules' /** Rate limit: max 5 applications per IP per 15 minutes */ const applyRateLimit = createRateLimiter({ @@ -659,10 +660,27 @@ export default defineEventHandler(async (event) => { } // ───────────────────────────────────────────── - // 12. Fire-and-forget auto AI scoring if enabled + // 12. Apply automation rules (auto-categorize / disqualify) // ───────────────────────────────────────────── + // + // Runs inline (fast, in-memory comparison) so the recruiter sees the + // categorized status immediately. Must run AFTER all responses — including + // file uploads stored in steps 10–11 — so file-based conditions see them. + // Never throws: applyRulesToApplication swallows its own errors. - if (existingJob.autoScoreOnApply && newApplication) { + let ruleMatch: Awaited> = null + if (newApplication) { + ruleMatch = await applyRulesToApplication(newApplication.id, orgId) + } + + // ───────────────────────────────────────────── + // 13. Fire-and-forget auto AI scoring if enabled + // ───────────────────────────────────────────── + // + // Skip scoring when a rule already disqualified the applicant — no point + // spending AI budget on a rejected candidate. + + if (existingJob.autoScoreOnApply && newApplication && ruleMatch?.action !== 'rejected') { autoScoreApplication(newApplication.id, orgId).catch((err) => { logError('application.auto_score_failed', { application_id: newApplication.id, @@ -690,6 +708,7 @@ export default defineEventHandler(async (event) => { file_count: uploadedFiles.size, auto_score_enabled: !!existingJob.autoScoreOnApply, is_returning_candidate: !!existingCandidate, + auto_rule_action: ruleMatch?.action ?? null, }) setResponseStatus(event, 201) diff --git a/server/database/migrations/0051_marvelous_molly_hayes.sql b/server/database/migrations/0051_marvelous_molly_hayes.sql new file mode 100644 index 00000000..f8a937d3 --- /dev/null +++ b/server/database/migrations/0051_marvelous_molly_hayes.sql @@ -0,0 +1,20 @@ +CREATE TYPE "public"."rule_action" AS ENUM('rejected', 'screening', 'interview');--> statement-breakpoint +CREATE TYPE "public"."rule_match_type" AS ENUM('all', 'any');--> statement-breakpoint +CREATE TABLE "application_rule" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "job_id" text NOT NULL, + "name" text NOT NULL, + "match_type" "rule_match_type" DEFAULT 'all' NOT NULL, + "action" "rule_action" DEFAULT 'rejected' NOT NULL, + "enabled" boolean DEFAULT true NOT NULL, + "conditions" jsonb DEFAULT '[]'::jsonb NOT NULL, + "display_order" integer DEFAULT 0 NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "application_rule" ADD CONSTRAINT "application_rule_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "application_rule" ADD CONSTRAINT "application_rule_job_id_job_id_fk" FOREIGN KEY ("job_id") REFERENCES "public"."job"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "application_rule_organization_id_idx" ON "application_rule" USING btree ("organization_id");--> statement-breakpoint +CREATE INDEX "application_rule_job_id_idx" ON "application_rule" USING btree ("job_id"); \ No newline at end of file diff --git a/server/database/migrations/0052_application_auto_rule.sql b/server/database/migrations/0052_application_auto_rule.sql new file mode 100644 index 00000000..fb3f3018 --- /dev/null +++ b/server/database/migrations/0052_application_auto_rule.sql @@ -0,0 +1 @@ +ALTER TABLE "application" ADD COLUMN "auto_rule" jsonb; \ No newline at end of file diff --git a/server/database/migrations/0053_glorious_jigsaw.sql b/server/database/migrations/0053_glorious_jigsaw.sql new file mode 100644 index 00000000..492506fb --- /dev/null +++ b/server/database/migrations/0053_glorious_jigsaw.sql @@ -0,0 +1 @@ +ALTER TABLE "activity_log" ALTER COLUMN "actor_id" DROP NOT NULL; \ No newline at end of file diff --git a/server/database/migrations/meta/0051_snapshot.json b/server/database/migrations/meta/0051_snapshot.json new file mode 100644 index 00000000..88833eb1 --- /dev/null +++ b/server/database/migrations/meta/0051_snapshot.json @@ -0,0 +1,8012 @@ +{ + "id": "716ea038-28a3-49c9-ae2a-a3923788b441", + "prevId": "36f987fc-91b3-4096-b47a-cc242da5b1f9", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation": { + "name": "invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inviter_id": { + "name": "inviter_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_organization_id_idx": { + "name": "invitation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_inviter_id_user_id_fk": { + "name": "invitation_inviter_id_user_id_fk", + "tableFrom": "invitation", + "tableTo": "user", + "columnsFrom": [ + "inviter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_organization_id_organization_id_fk": { + "name": "invitation_organization_id_organization_id_fk", + "tableFrom": "invitation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.member": { + "name": "member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "member_user_id_idx": { + "name": "member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_organization_id_idx": { + "name": "member_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_user_org_unique_idx": { + "name": "member_user_org_unique_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "member_user_id_user_id_fk": { + "name": "member_user_id_user_id_fk", + "tableFrom": "member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "member_organization_id_organization_id_fk": { + "name": "member_organization_id_organization_id_fk", + "tableFrom": "member", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limit": { + "name": "rate_limit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_request": { + "name": "last_request", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "rate_limit_key_idx": { + "name": "rate_limit_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscription": { + "name": "subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'incomplete'" + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_start": { + "name": "trial_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_end": { + "name": "trial_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cancel_at": { + "name": "cancel_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "billing_interval": { + "name": "billing_interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_schedule_id": { + "name": "stripe_schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "subscription_reference_id_idx": { + "name": "subscription_reference_id_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "subscription_stripe_customer_id_idx": { + "name": "subscription_stripe_customer_id_idx", + "columns": [ + { + "expression": "stripe_customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.activity_log": { + "name": "activity_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "activity_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "activity_log_organization_id_idx": { + "name": "activity_log_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_actor_id_idx": { + "name": "activity_log_actor_id_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_resource_idx": { + "name": "activity_log_resource_idx", + "columns": [ + { + "expression": "resource_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resource_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_created_at_idx": { + "name": "activity_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_log_organization_id_organization_id_fk": { + "name": "activity_log_organization_id_organization_id_fk", + "tableFrom": "activity_log", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "activity_log_actor_id_user_id_fk": { + "name": "activity_log_actor_id_user_id_fk", + "tableFrom": "activity_log", + "tableTo": "user", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_config": { + "name": "ai_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Default'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gpt-4o-mini'" + }, + "api_key_encrypted": { + "name": "api_key_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4096 + }, + "input_price_per_1m": { + "name": "input_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "output_price_per_1m": { + "name": "output_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_default_chatbot": { + "name": "is_default_chatbot", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_default_analysis": { + "name": "is_default_analysis", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_config_organization_id_idx": { + "name": "ai_config_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_config_default_chatbot_idx": { + "name": "ai_config_default_chatbot_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_config\".\"is_default_chatbot\" = true", + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_config_default_analysis_idx": { + "name": "ai_config_default_analysis_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_config\".\"is_default_analysis\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_config_organization_id_organization_id_fk": { + "name": "ai_config_organization_id_organization_id_fk", + "tableFrom": "ai_config", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.analysis_run": { + "name": "analysis_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "analysis_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'completed'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "criteria_snapshot": { + "name": "criteria_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "composite_score": { + "name": "composite_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "prompt_tokens": { + "name": "prompt_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "completion_tokens": { + "name": "completion_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cost_usd_micros": { + "name": "cost_usd_micros", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "billing_mode": { + "name": "billing_mode", + "type": "analysis_billing_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'byok'" + }, + "raw_response": { + "name": "raw_response", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scored_by_id": { + "name": "scored_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "analysis_run_organization_id_idx": { + "name": "analysis_run_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analysis_run_application_id_idx": { + "name": "analysis_run_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analysis_run_created_at_idx": { + "name": "analysis_run_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "analysis_run_organization_id_organization_id_fk": { + "name": "analysis_run_organization_id_organization_id_fk", + "tableFrom": "analysis_run", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_run_application_id_application_id_fk": { + "name": "analysis_run_application_id_application_id_fk", + "tableFrom": "analysis_run", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_run_scored_by_id_user_id_fk": { + "name": "analysis_run_scored_by_id_user_id_fk", + "tableFrom": "analysis_run", + "tableTo": "user", + "columnsFrom": [ + "scored_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application": { + "name": "application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "application_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cover_letter_text": { + "name": "cover_letter_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_organization_id_idx": { + "name": "application_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_candidate_id_idx": { + "name": "application_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_job_id_idx": { + "name": "application_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_org_candidate_job_idx": { + "name": "application_org_candidate_job_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_organization_id_organization_id_fk": { + "name": "application_organization_id_organization_id_fk", + "tableFrom": "application", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_candidate_id_candidate_id_fk": { + "name": "application_candidate_id_candidate_id_fk", + "tableFrom": "application", + "tableTo": "candidate", + "columnsFrom": [ + "candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_job_id_job_id_fk": { + "name": "application_job_id_job_id_fk", + "tableFrom": "application", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application_rule": { + "name": "application_rule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_type": { + "name": "match_type", + "type": "rule_match_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'all'" + }, + "action": { + "name": "action", + "type": "rule_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'rejected'" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_rule_organization_id_idx": { + "name": "application_rule_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_rule_job_id_idx": { + "name": "application_rule_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_rule_organization_id_organization_id_fk": { + "name": "application_rule_organization_id_organization_id_fk", + "tableFrom": "application_rule", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_rule_job_id_job_id_fk": { + "name": "application_rule_job_id_job_id_fk", + "tableFrom": "application_rule", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application_source": { + "name": "application_source", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "source_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'direct'" + }, + "tracking_link_id": { + "name": "tracking_link_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_source": { + "name": "utm_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_medium": { + "name": "utm_medium", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_campaign": { + "name": "utm_campaign", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_term": { + "name": "utm_term", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_content": { + "name": "utm_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "referrer_domain": { + "name": "referrer_domain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_source_organization_id_idx": { + "name": "application_source_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_application_id_idx": { + "name": "application_source_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_channel_idx": { + "name": "application_source_channel_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_tracking_link_id_idx": { + "name": "application_source_tracking_link_id_idx", + "columns": [ + { + "expression": "tracking_link_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_application_idx": { + "name": "application_source_application_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_source_organization_id_organization_id_fk": { + "name": "application_source_organization_id_organization_id_fk", + "tableFrom": "application_source", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_source_application_id_application_id_fk": { + "name": "application_source_application_id_application_id_fk", + "tableFrom": "application_source", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_source_tracking_link_id_tracking_link_id_fk": { + "name": "application_source_tracking_link_id_tracking_link_id_fk", + "tableFrom": "application_source", + "tableTo": "tracking_link", + "columnsFrom": [ + "tracking_link_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.calendar_integration": { + "name": "calendar_integration", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "calendar_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'google'" + }, + "access_token_encrypted": { + "name": "access_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token_encrypted": { + "name": "refresh_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "calendar_id": { + "name": "calendar_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'primary'" + }, + "account_email": { + "name": "account_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_channel_id": { + "name": "webhook_channel_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_resource_id": { + "name": "webhook_resource_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_expiration": { + "name": "webhook_expiration", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sync_token": { + "name": "sync_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "calendar_integration_user_provider_idx": { + "name": "calendar_integration_user_provider_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "calendar_integration_webhook_channel_idx": { + "name": "calendar_integration_webhook_channel_idx", + "columns": [ + { + "expression": "webhook_channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "calendar_integration_user_id_user_id_fk": { + "name": "calendar_integration_user_id_user_id_fk", + "tableFrom": "calendar_integration", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate": { + "name": "candidate", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "gender", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quick_notes": { + "name": "quick_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retention_exempt_until": { + "name": "retention_exempt_until", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "retention_exempt_reason": { + "name": "retention_exempt_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retention_reviewed_at": { + "name": "retention_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "quarantined_at": { + "name": "quarantined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scheduled_purge_at": { + "name": "scheduled_purge_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_organization_id_idx": { + "name": "candidate_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_gender_idx": { + "name": "candidate_gender_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "gender", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_org_email_idx": { + "name": "candidate_org_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_quarantine_idx": { + "name": "candidate_quarantine_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_purge_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_organization_id_organization_id_fk": { + "name": "candidate_organization_id_organization_id_fk", + "tableFrom": "candidate", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_conversation": { + "name": "candidate_conversation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_token": { + "name": "reply_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unread_count": { + "name": "unread_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_conversation_organization_id_idx": { + "name": "candidate_conversation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_application_id_idx": { + "name": "candidate_conversation_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_reply_token_idx": { + "name": "candidate_conversation_reply_token_idx", + "columns": [ + { + "expression": "reply_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_last_message_at_idx": { + "name": "candidate_conversation_last_message_at_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_conversation_organization_id_organization_id_fk": { + "name": "candidate_conversation_organization_id_organization_id_fk", + "tableFrom": "candidate_conversation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_conversation_application_id_application_id_fk": { + "name": "candidate_conversation_application_id_application_id_fk", + "tableFrom": "candidate_conversation", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message": { + "name": "candidate_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "candidate_message_direction", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "candidate_message_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'message'" + }, + "interview_id": { + "name": "interview_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calendar_attachment_status": { + "name": "calendar_attachment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_applicable'" + }, + "calendar_attachment_error": { + "name": "calendar_attachment_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calendar_sequence": { + "name": "calendar_sequence", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internet_message_id": { + "name": "internet_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "in_reply_to": { + "name": "in_reply_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "references": { + "name": "references", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sent_by_id": { + "name": "sent_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_status_at": { + "name": "provider_status_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_organization_id_idx": { + "name": "candidate_message_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_conversation_id_idx": { + "name": "candidate_message_conversation_id_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_interview_id_idx": { + "name": "candidate_message_interview_id_idx", + "columns": [ + { + "expression": "interview_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_provider_id_idx": { + "name": "candidate_message_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_internet_id_idx": { + "name": "candidate_message_internet_id_idx", + "columns": [ + { + "expression": "internet_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_message_organization_id_organization_id_fk": { + "name": "candidate_message_organization_id_organization_id_fk", + "tableFrom": "candidate_message", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_conversation_id_candidate_conversation_id_fk": { + "name": "candidate_message_conversation_id_candidate_conversation_id_fk", + "tableFrom": "candidate_message", + "tableTo": "candidate_conversation", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_interview_id_interview_id_fk": { + "name": "candidate_message_interview_id_interview_id_fk", + "tableFrom": "candidate_message", + "tableTo": "interview", + "columnsFrom": [ + "interview_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidate_message_sent_by_id_user_id_fk": { + "name": "candidate_message_sent_by_id_user_id_fk", + "tableFrom": "candidate_message", + "tableTo": "user", + "columnsFrom": [ + "sent_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message_attachment": { + "name": "candidate_message_attachment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "provider_attachment_id": { + "name": "provider_attachment_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_attachment_organization_id_idx": { + "name": "candidate_message_attachment_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_attachment_message_id_idx": { + "name": "candidate_message_attachment_message_id_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_message_attachment_organization_id_organization_id_fk": { + "name": "candidate_message_attachment_organization_id_organization_id_fk", + "tableFrom": "candidate_message_attachment", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_attachment_message_id_candidate_message_id_fk": { + "name": "candidate_message_attachment_message_id_candidate_message_id_fk", + "tableFrom": "candidate_message_attachment", + "tableTo": "candidate_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "candidate_message_attachment_storage_key_unique": { + "name": "candidate_message_attachment_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + }, + "candidate_message_attachment_provider_attachment_id_unique": { + "name": "candidate_message_attachment_provider_attachment_id_unique", + "nullsNotDistinct": false, + "columns": [ + "provider_attachment_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message_webhook_event": { + "name": "candidate_message_webhook_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_webhook_provider_id_idx": { + "name": "candidate_message_webhook_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_webhook_unprocessed_idx": { + "name": "candidate_message_webhook_unprocessed_idx", + "columns": [ + { + "expression": "processed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.career_page": { + "name": "career_page", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "accent_color": { + "name": "accent_color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headline": { + "name": "headline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_storage_key": { + "name": "logo_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_storage_key": { + "name": "banner_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_position": { + "name": "banner_position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "career_page_organization_id_idx": { + "name": "career_page_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "career_page_slug_idx": { + "name": "career_page_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "career_page_organization_id_organization_id_fk": { + "name": "career_page_organization_id_organization_id_fk", + "tableFrom": "career_page", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_agent": { + "name": "chatbot_agent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system_prompt": { + "name": "system_prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(3, 2)", + "primaryKey": false, + "notNull": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_agent_org_user_idx": { + "name": "chatbot_agent_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_agent_default_per_user_idx": { + "name": "chatbot_agent_default_per_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"chatbot_agent\".\"is_default\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_agent_organization_id_organization_id_fk": { + "name": "chatbot_agent_organization_id_organization_id_fk", + "tableFrom": "chatbot_agent", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_agent_user_id_user_id_fk": { + "name": "chatbot_agent_user_id_user_id_fk", + "tableFrom": "chatbot_agent", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_conversation": { + "name": "chatbot_conversation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ai_config_id": { + "name": "ai_config_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'New chat'" + }, + "scope": { + "name": "scope", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "thinking": { + "name": "thinking", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "last_message_preview": { + "name": "last_message_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_conversation_org_user_idx": { + "name": "chatbot_conversation_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_conversation_folder_idx": { + "name": "chatbot_conversation_folder_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_conversation_last_message_at_idx": { + "name": "chatbot_conversation_last_message_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_conversation_organization_id_organization_id_fk": { + "name": "chatbot_conversation_organization_id_organization_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_conversation_user_id_user_id_fk": { + "name": "chatbot_conversation_user_id_user_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_conversation_folder_id_chatbot_folder_id_fk": { + "name": "chatbot_conversation_folder_id_chatbot_folder_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "chatbot_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chatbot_conversation_agent_id_chatbot_agent_id_fk": { + "name": "chatbot_conversation_agent_id_chatbot_agent_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "chatbot_agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chatbot_conversation_ai_config_id_ai_config_id_fk": { + "name": "chatbot_conversation_ai_config_id_ai_config_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "ai_config", + "columnsFrom": [ + "ai_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_folder": { + "name": "chatbot_folder", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_folder_org_user_idx": { + "name": "chatbot_folder_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_folder_organization_id_organization_id_fk": { + "name": "chatbot_folder_organization_id_organization_id_fk", + "tableFrom": "chatbot_folder", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_folder_user_id_user_id_fk": { + "name": "chatbot_folder_user_id_user_id_fk", + "tableFrom": "chatbot_folder", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_message": { + "name": "chatbot_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "chatbot_message_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_calls": { + "name": "tool_calls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sources": { + "name": "sources", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_message_conversation_idx": { + "name": "chatbot_message_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_message_conversation_id_chatbot_conversation_id_fk": { + "name": "chatbot_message_conversation_id_chatbot_conversation_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "chatbot_conversation", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_message_organization_id_organization_id_fk": { + "name": "chatbot_message_organization_id_organization_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_message_user_id_user_id_fk": { + "name": "chatbot_message_user_id_user_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comment": { + "name": "comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "comment_target", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comment_organization_id_idx": { + "name": "comment_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "comment_target_idx": { + "name": "comment_target_idx", + "columns": [ + { + "expression": "target_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "comment_author_id_idx": { + "name": "comment_author_id_idx", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "comment_organization_id_organization_id_fk": { + "name": "comment_organization_id_organization_id_fk", + "tableFrom": "comment", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comment_author_id_user_id_fk": { + "name": "comment_author_id_user_id_fk", + "tableFrom": "comment", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.criterion_score": { + "name": "criterion_score", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "criterion_key": { + "name": "criterion_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "max_score": { + "name": "max_score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "applicant_score": { + "name": "applicant_score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "confidence": { + "name": "confidence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "evidence": { + "name": "evidence", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "strengths": { + "name": "strengths", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "gaps": { + "name": "gaps", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "criterion_score_organization_id_idx": { + "name": "criterion_score_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "criterion_score_application_id_idx": { + "name": "criterion_score_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "criterion_score_app_criterion_idx": { + "name": "criterion_score_app_criterion_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "criterion_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "criterion_score_organization_id_organization_id_fk": { + "name": "criterion_score_organization_id_organization_id_fk", + "tableFrom": "criterion_score", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "criterion_score_application_id_application_id_fk": { + "name": "criterion_score_application_id_application_id_fk", + "tableFrom": "criterion_score", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.document": { + "name": "document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "document_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'resume'" + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "original_filename": { + "name": "original_filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parsed_content": { + "name": "parsed_content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "document_organization_id_idx": { + "name": "document_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "document_candidate_id_idx": { + "name": "document_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "document_organization_id_organization_id_fk": { + "name": "document_organization_id_organization_id_fk", + "tableFrom": "document", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "document_candidate_id_candidate_id_fk": { + "name": "document_candidate_id_candidate_id_fk", + "tableFrom": "document", + "tableTo": "candidate", + "columnsFrom": [ + "candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "document_storage_key_unique": { + "name": "document_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_suppression": { + "name": "email_suppression", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "email_suppression_reason", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_suppression_email_idx": { + "name": "email_suppression_email_idx", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_template": { + "name": "email_template", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_template_organization_id_idx": { + "name": "email_template_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "email_template_created_by_id_idx": { + "name": "email_template_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_template_organization_id_organization_id_fk": { + "name": "email_template_organization_id_organization_id_fk", + "tableFrom": "email_template", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_template_created_by_id_user_id_fk": { + "name": "email_template_created_by_id_user_id_fk", + "tableFrom": "email_template", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_job": { + "name": "import_job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "import_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'processing'" + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "columns": { + "name": "columns", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "target_job_id": { + "name": "target_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_rows": { + "name": "total_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "committed_rows": { + "name": "committed_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "import_job_organization_id_idx": { + "name": "import_job_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_job_status_idx": { + "name": "import_job_status_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_job_organization_id_organization_id_fk": { + "name": "import_job_organization_id_organization_id_fk", + "tableFrom": "import_job", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_job_created_by_user_id_fk": { + "name": "import_job_created_by_user_id_fk", + "tableFrom": "import_job", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_job_target_job_id_job_id_fk": { + "name": "import_job_target_job_id_job_id_fk", + "tableFrom": "import_job", + "tableTo": "job", + "columnsFrom": [ + "target_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_row": { + "name": "import_row", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_index": { + "name": "row_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "raw_data": { + "name": "raw_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "normalized_data": { + "name": "normalized_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "import_row_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'ready'" + }, + "dedupe_hash": { + "name": "dedupe_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "matched_candidate_id": { + "name": "matched_candidate_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_candidate_id": { + "name": "created_candidate_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "import_row_job_id_idx": { + "name": "import_row_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_row_job_status_idx": { + "name": "import_row_job_status_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_row_dedupe_idx": { + "name": "import_row_dedupe_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_row_organization_id_organization_id_fk": { + "name": "import_row_organization_id_organization_id_fk", + "tableFrom": "import_row", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_job_id_import_job_id_fk": { + "name": "import_row_job_id_import_job_id_fk", + "tableFrom": "import_row", + "tableTo": "import_job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_matched_candidate_id_candidate_id_fk": { + "name": "import_row_matched_candidate_id_candidate_id_fk", + "tableFrom": "import_row", + "tableTo": "candidate", + "columnsFrom": [ + "matched_candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "import_row_created_candidate_id_candidate_id_fk": { + "name": "import_row_created_candidate_id_candidate_id_fk", + "tableFrom": "import_row", + "tableTo": "candidate", + "columnsFrom": [ + "created_candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.interview": { + "name": "interview", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "interview_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'video'" + }, + "status": { + "name": "status", + "type": "interview_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "personal_note": { + "name": "personal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interviewers": { + "name": "interviewers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invitation_sent_at": { + "name": "invitation_sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "candidate_response": { + "name": "candidate_response", + "type": "candidate_response", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "candidate_responded_at": { + "name": "candidate_responded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "google_calendar_event_id": { + "name": "google_calendar_event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_calendar_event_link": { + "name": "google_calendar_event_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'UTC'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "interview_organization_id_idx": { + "name": "interview_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_application_id_idx": { + "name": "interview_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_scheduled_at_idx": { + "name": "interview_scheduled_at_idx", + "columns": [ + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_status_idx": { + "name": "interview_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_created_by_id_idx": { + "name": "interview_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "interview_organization_id_organization_id_fk": { + "name": "interview_organization_id_organization_id_fk", + "tableFrom": "interview", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "interview_application_id_application_id_fk": { + "name": "interview_application_id_application_id_fk", + "tableFrom": "interview", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "interview_created_by_id_user_id_fk": { + "name": "interview_created_by_id_user_id_fk", + "tableFrom": "interview", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invite_link": { + "name": "invite_link", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "max_uses": { + "name": "max_uses", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invite_link_organization_id_idx": { + "name": "invite_link_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invite_link_token_idx": { + "name": "invite_link_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invite_link_organization_id_organization_id_fk": { + "name": "invite_link_organization_id_organization_id_fk", + "tableFrom": "invite_link", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invite_link_created_by_id_user_id_fk": { + "name": "invite_link_created_by_id_user_id_fk", + "tableFrom": "invite_link", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invite_link_token_unique": { + "name": "invite_link_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job": { + "name": "job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "job_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'full_time'" + }, + "status": { + "name": "status", + "type": "job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "salary_min": { + "name": "salary_min", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "salary_max": { + "name": "salary_max", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "salary_currency": { + "name": "salary_currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salary_unit": { + "name": "salary_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salary_negotiable": { + "name": "salary_negotiable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "remote_status": { + "name": "remote_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valid_through": { + "name": "valid_through", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "experience_level": { + "name": "experience_level", + "type": "experience_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "phone_requirement": { + "name": "phone_requirement", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'optional'" + }, + "require_resume": { + "name": "require_resume", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "require_cover_letter": { + "name": "require_cover_letter", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_score_on_apply": { + "name": "auto_score_on_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "analysis_context": { + "name": "analysis_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"coverLetter\":true,\"screeningAnswers\":true,\"recruiterNotes\":false}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_organization_id_idx": { + "name": "job_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_organization_id_organization_id_fk": { + "name": "job_organization_id_organization_id_fk", + "tableFrom": "job", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "job_slug_unique": { + "name": "job_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job_question": { + "name": "job_question", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "question_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'short_text'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "options": { + "name": "options", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_question_organization_id_idx": { + "name": "job_question_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_question_job_id_idx": { + "name": "job_question_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_question_organization_id_organization_id_fk": { + "name": "job_question_organization_id_organization_id_fk", + "tableFrom": "job_question", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_question_job_id_job_id_fk": { + "name": "job_question_job_id_job_id_fk", + "tableFrom": "job_question", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.join_request": { + "name": "join_request", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "join_request_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "reviewed_by_id": { + "name": "reviewed_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "join_request_organization_id_idx": { + "name": "join_request_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "join_request_user_id_idx": { + "name": "join_request_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "join_request_status_idx": { + "name": "join_request_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "join_request_user_id_user_id_fk": { + "name": "join_request_user_id_user_id_fk", + "tableFrom": "join_request", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "join_request_organization_id_organization_id_fk": { + "name": "join_request_organization_id_organization_id_fk", + "tableFrom": "join_request", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "join_request_reviewed_by_id_user_id_fk": { + "name": "join_request_reviewed_by_id_user_id_fk", + "tableFrom": "join_request", + "tableTo": "user", + "columnsFrom": [ + "reviewed_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_outbox": { + "name": "notification_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_email": { + "name": "recipient_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "cadence": { + "name": "cadence", + "type": "notification_cadence", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "notification_outbox_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "digest_bucket": { + "name": "digest_bucket", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_outbox_dedupe_key_idx": { + "name": "notification_outbox_dedupe_key_idx", + "columns": [ + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_pull_idx": { + "name": "notification_outbox_pull_idx", + "columns": [ + { + "expression": "cadence", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"notification_outbox\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_provider_id_idx": { + "name": "notification_outbox_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"notification_outbox\".\"provider_message_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_organization_id_idx": { + "name": "notification_outbox_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_digest_idx": { + "name": "notification_outbox_digest_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "digest_bucket", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_outbox_organization_id_organization_id_fk": { + "name": "notification_outbox_organization_id_organization_id_fk", + "tableFrom": "notification_outbox", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_outbox_recipient_user_id_user_id_fk": { + "name": "notification_outbox_recipient_user_id_user_id_fk", + "tableFrom": "notification_outbox", + "tableTo": "user", + "columnsFrom": [ + "recipient_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_preference": { + "name": "notification_preference", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "channel_mode": { + "name": "channel_mode", + "type": "notification_channel_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_preference_user_org_type_idx": { + "name": "notification_preference_user_org_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_preference_organization_id_idx": { + "name": "notification_preference_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_preference_user_id_user_id_fk": { + "name": "notification_preference_user_id_user_id_fk", + "tableFrom": "notification_preference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preference_organization_id_organization_id_fk": { + "name": "notification_preference_organization_id_organization_id_fk", + "tableFrom": "notification_preference", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.onboarding_survey_response": { + "name": "onboarding_survey_response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signup_plan": { + "name": "signup_plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signup_billing": { + "name": "signup_billing", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company_size": { + "name": "company_size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_role": { + "name": "user_role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discovery_source": { + "name": "discovery_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_hiring_process": { + "name": "current_hiring_process", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_roles_12m": { + "name": "expected_roles_12m", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_count": { + "name": "answered_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped_count": { + "name": "skipped_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_survey_response_user_id_idx": { + "name": "onboarding_survey_response_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_survey_response_organization_id_idx": { + "name": "onboarding_survey_response_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_survey_response_user_id_user_id_fk": { + "name": "onboarding_survey_response_user_id_user_id_fk", + "tableFrom": "onboarding_survey_response", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_survey_response_organization_id_organization_id_fk": { + "name": "onboarding_survey_response_organization_id_organization_id_fk", + "tableFrom": "onboarding_survey_response", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_settings": { + "name": "org_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name_display_format": { + "name": "name_display_format", + "type": "name_display_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'first_last'" + }, + "date_format": { + "name": "date_format", + "type": "date_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'mdy'" + }, + "retention_enabled": { + "name": "retention_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "retention_months": { + "name": "retention_months", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "quarantine_days": { + "name": "quarantine_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "retention_activated_at": { + "name": "retention_activated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "privacy_policy_url": { + "name": "privacy_policy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privacy_policy_text": { + "name": "privacy_policy_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privacy_contact_email": { + "name": "privacy_contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_settings_organization_id_idx": { + "name": "org_settings_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "org_settings_organization_id_organization_id_fk": { + "name": "org_settings_organization_id_organization_id_fk", + "tableFrom": "org_settings", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_ai_config": { + "name": "platform_ai_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Platform (OpenRouter)'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openrouter'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai/gpt-5.4-mini'" + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4096 + }, + "input_price_per_1m": { + "name": "input_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "output_price_per_1m": { + "name": "output_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_default_analysis": { + "name": "is_default_analysis", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_enabled": { + "name": "is_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "platform_ai_config_organization_id_idx": { + "name": "platform_ai_config_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "platform_ai_config_organization_id_organization_id_fk": { + "name": "platform_ai_config_organization_id_organization_id_fk", + "tableFrom": "platform_ai_config", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.property_definition": { + "name": "property_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "property_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "property_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "property_definition_org_idx": { + "name": "property_definition_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_definition_org_entity_idx": { + "name": "property_definition_org_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_definition_job_idx": { + "name": "property_definition_job_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "property_definition_organization_id_organization_id_fk": { + "name": "property_definition_organization_id_organization_id_fk", + "tableFrom": "property_definition", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "property_definition_job_id_job_id_fk": { + "name": "property_definition_job_id_job_id_fk", + "tableFrom": "property_definition", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.property_value": { + "name": "property_value", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "property_definition_id": { + "name": "property_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "property_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "property_value_org_idx": { + "name": "property_value_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_entity_idx": { + "name": "property_value_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_definition_idx": { + "name": "property_value_definition_idx", + "columns": [ + { + "expression": "property_definition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_def_entity_idx": { + "name": "property_value_def_entity_idx", + "columns": [ + { + "expression": "property_definition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "property_value_organization_id_organization_id_fk": { + "name": "property_value_organization_id_organization_id_fk", + "tableFrom": "property_value", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "property_value_property_definition_id_property_definition_id_fk": { + "name": "property_value_property_definition_id_property_definition_id_fk", + "tableFrom": "property_value", + "tableTo": "property_definition", + "columnsFrom": [ + "property_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.question_response": { + "name": "question_response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "question_id": { + "name": "question_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "question_response_organization_id_idx": { + "name": "question_response_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "question_response_application_id_idx": { + "name": "question_response_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "question_response_question_id_idx": { + "name": "question_response_question_id_idx", + "columns": [ + { + "expression": "question_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "question_response_organization_id_organization_id_fk": { + "name": "question_response_organization_id_organization_id_fk", + "tableFrom": "question_response", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "question_response_application_id_application_id_fk": { + "name": "question_response_application_id_application_id_fk", + "tableFrom": "question_response", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "question_response_question_id_job_question_id_fk": { + "name": "question_response_question_id_job_question_id_fk", + "tableFrom": "question_response", + "tableTo": "job_question", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.retention_audit": { + "name": "retention_audit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "retention_audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'success'" + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "retention_audit_organization_id_idx": { + "name": "retention_audit_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "retention_audit_candidate_id_idx": { + "name": "retention_audit_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "retention_audit_created_at_idx": { + "name": "retention_audit_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "retention_audit_organization_id_organization_id_fk": { + "name": "retention_audit_organization_id_organization_id_fk", + "tableFrom": "retention_audit", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scoring_criterion": { + "name": "scoring_criterion", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "criterion_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'custom'" + }, + "max_score": { + "name": "max_score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "weight": { + "name": "weight", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "scoring_criterion_organization_id_idx": { + "name": "scoring_criterion_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scoring_criterion_job_id_idx": { + "name": "scoring_criterion_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scoring_criterion_job_key_idx": { + "name": "scoring_criterion_job_key_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "scoring_criterion_organization_id_organization_id_fk": { + "name": "scoring_criterion_organization_id_organization_id_fk", + "tableFrom": "scoring_criterion", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "scoring_criterion_job_id_job_id_fk": { + "name": "scoring_criterion_job_id_job_id_fk", + "tableFrom": "scoring_criterion", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tracking_link": { + "name": "tracking_link", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "source_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'custom'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "utm_source": { + "name": "utm_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_medium": { + "name": "utm_medium", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_campaign": { + "name": "utm_campaign", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_term": { + "name": "utm_term", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_content": { + "name": "utm_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "click_count": { + "name": "click_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "application_count": { + "name": "application_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tracking_link_organization_id_idx": { + "name": "tracking_link_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_job_id_idx": { + "name": "tracking_link_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_code_idx": { + "name": "tracking_link_code_idx", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_channel_idx": { + "name": "tracking_link_channel_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tracking_link_organization_id_organization_id_fk": { + "name": "tracking_link_organization_id_organization_id_fk", + "tableFrom": "tracking_link", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tracking_link_job_id_job_id_fk": { + "name": "tracking_link_job_id_job_id_fk", + "tableFrom": "tracking_link", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tracking_link_created_by_id_user_id_fk": { + "name": "tracking_link_created_by_id_user_id_fk", + "tableFrom": "tracking_link", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tracking_link_code_unique": { + "name": "tracking_link_code_unique", + "nullsNotDistinct": false, + "columns": [ + "code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sso_provider": { + "name": "sso_provider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "issuer": { + "name": "issuer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "oidc_config": { + "name": "oidc_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "saml_config": { + "name": "saml_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sso_provider_domain_idx": { + "name": "sso_provider_domain_idx", + "columns": [ + { + "expression": "domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_provider_id_idx": { + "name": "sso_provider_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_organization_id_idx": { + "name": "sso_provider_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sso_provider_user_id_user_id_fk": { + "name": "sso_provider_user_id_user_id_fk", + "tableFrom": "sso_provider", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sso_provider_organization_id_organization_id_fk": { + "name": "sso_provider_organization_id_organization_id_fk", + "tableFrom": "sso_provider", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.activity_action": { + "name": "activity_action", + "schema": "public", + "values": [ + "created", + "updated", + "deleted", + "status_changed", + "comment_added", + "member_invited", + "member_removed", + "member_role_changed", + "scored" + ] + }, + "public.analysis_billing_mode": { + "name": "analysis_billing_mode", + "schema": "public", + "values": [ + "platform", + "byok" + ] + }, + "public.analysis_run_status": { + "name": "analysis_run_status", + "schema": "public", + "values": [ + "completed", + "failed", + "partial" + ] + }, + "public.application_status": { + "name": "application_status", + "schema": "public", + "values": [ + "new", + "screening", + "interview", + "offer", + "hired", + "rejected" + ] + }, + "public.calendar_provider": { + "name": "calendar_provider", + "schema": "public", + "values": [ + "google" + ] + }, + "public.candidate_message_direction": { + "name": "candidate_message_direction", + "schema": "public", + "values": [ + "inbound", + "outbound" + ] + }, + "public.candidate_message_status": { + "name": "candidate_message_status", + "schema": "public", + "values": [ + "queued", + "sent", + "delivered", + "delayed", + "bounced", + "failed", + "complained" + ] + }, + "public.candidate_response": { + "name": "candidate_response", + "schema": "public", + "values": [ + "pending", + "accepted", + "declined", + "tentative" + ] + }, + "public.chatbot_message_role": { + "name": "chatbot_message_role", + "schema": "public", + "values": [ + "user", + "assistant" + ] + }, + "public.comment_target": { + "name": "comment_target", + "schema": "public", + "values": [ + "candidate", + "application", + "job" + ] + }, + "public.criterion_category": { + "name": "criterion_category", + "schema": "public", + "values": [ + "technical", + "experience", + "soft_skills", + "education", + "culture", + "custom" + ] + }, + "public.date_format": { + "name": "date_format", + "schema": "public", + "values": [ + "mdy", + "dmy", + "ymd" + ] + }, + "public.document_type": { + "name": "document_type", + "schema": "public", + "values": [ + "resume", + "cover_letter", + "other" + ] + }, + "public.email_suppression_reason": { + "name": "email_suppression_reason", + "schema": "public", + "values": [ + "bounce", + "complaint" + ] + }, + "public.experience_level": { + "name": "experience_level", + "schema": "public", + "values": [ + "junior", + "mid", + "senior", + "lead" + ] + }, + "public.gender": { + "name": "gender", + "schema": "public", + "values": [ + "male", + "female", + "other", + "prefer_not_to_say" + ] + }, + "public.import_job_status": { + "name": "import_job_status", + "schema": "public", + "values": [ + "processing", + "previewing", + "committing", + "completed", + "failed" + ] + }, + "public.import_row_status": { + "name": "import_row_status", + "schema": "public", + "values": [ + "ready", + "duplicate", + "duplicate_in_file", + "error", + "committed", + "skipped" + ] + }, + "public.import_source": { + "name": "import_source", + "schema": "public", + "values": [ + "csv", + "xlsx", + "resume_zip" + ] + }, + "public.interview_status": { + "name": "interview_status", + "schema": "public", + "values": [ + "scheduled", + "completed", + "cancelled", + "no_show" + ] + }, + "public.interview_type": { + "name": "interview_type", + "schema": "public", + "values": [ + "phone", + "video", + "in_person", + "panel", + "technical", + "take_home" + ] + }, + "public.job_status": { + "name": "job_status", + "schema": "public", + "values": [ + "draft", + "open", + "closed", + "archived" + ] + }, + "public.job_type": { + "name": "job_type", + "schema": "public", + "values": [ + "full_time", + "part_time", + "contract", + "internship" + ] + }, + "public.join_request_status": { + "name": "join_request_status", + "schema": "public", + "values": [ + "pending", + "approved", + "rejected" + ] + }, + "public.name_display_format": { + "name": "name_display_format", + "schema": "public", + "values": [ + "first_last", + "last_first" + ] + }, + "public.notification_cadence": { + "name": "notification_cadence", + "schema": "public", + "values": [ + "instant", + "digest" + ] + }, + "public.notification_channel_mode": { + "name": "notification_channel_mode", + "schema": "public", + "values": [ + "instant", + "digest", + "off" + ] + }, + "public.notification_outbox_status": { + "name": "notification_outbox_status", + "schema": "public", + "values": [ + "pending", + "sent", + "skipped", + "dead" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "candidate_replied", + "application_created", + "interview_response" + ] + }, + "public.property_entity_type": { + "name": "property_entity_type", + "schema": "public", + "values": [ + "candidate", + "application" + ] + }, + "public.property_type": { + "name": "property_type", + "schema": "public", + "values": [ + "text", + "long_text", + "number", + "select", + "multi_select", + "date", + "checkbox", + "url", + "email", + "person", + "file" + ] + }, + "public.question_type": { + "name": "question_type", + "schema": "public", + "values": [ + "short_text", + "long_text", + "single_select", + "multi_select", + "number", + "date", + "url", + "checkbox", + "file_upload" + ] + }, + "public.retention_audit_action": { + "name": "retention_audit_action", + "schema": "public", + "values": [ + "quarantined", + "restored", + "erased", + "exempted", + "unexempted", + "exported" + ] + }, + "public.rule_action": { + "name": "rule_action", + "schema": "public", + "values": [ + "rejected", + "screening", + "interview" + ] + }, + "public.rule_match_type": { + "name": "rule_match_type", + "schema": "public", + "values": [ + "all", + "any" + ] + }, + "public.source_channel": { + "name": "source_channel", + "schema": "public", + "values": [ + "linkedin", + "indeed", + "glassdoor", + "ziprecruiter", + "monster", + "handshake", + "angellist", + "wellfound", + "dice", + "stackoverflow", + "weworkremotely", + "remoteok", + "builtin", + "hired", + "lever", + "greenhouse_board", + "google_jobs", + "facebook", + "twitter", + "instagram", + "tiktok", + "reddit", + "referral", + "career_site", + "email", + "event", + "agency", + "direct", + "other", + "custom" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/server/database/migrations/meta/0052_snapshot.json b/server/database/migrations/meta/0052_snapshot.json new file mode 100644 index 00000000..461efa65 --- /dev/null +++ b/server/database/migrations/meta/0052_snapshot.json @@ -0,0 +1,8018 @@ +{ + "id": "4d7cb462-bca2-40d1-9dba-7a9c27ded8ce", + "prevId": "716ea038-28a3-49c9-ae2a-a3923788b441", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation": { + "name": "invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inviter_id": { + "name": "inviter_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_organization_id_idx": { + "name": "invitation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_inviter_id_user_id_fk": { + "name": "invitation_inviter_id_user_id_fk", + "tableFrom": "invitation", + "tableTo": "user", + "columnsFrom": [ + "inviter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_organization_id_organization_id_fk": { + "name": "invitation_organization_id_organization_id_fk", + "tableFrom": "invitation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.member": { + "name": "member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "member_user_id_idx": { + "name": "member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_organization_id_idx": { + "name": "member_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_user_org_unique_idx": { + "name": "member_user_org_unique_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "member_user_id_user_id_fk": { + "name": "member_user_id_user_id_fk", + "tableFrom": "member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "member_organization_id_organization_id_fk": { + "name": "member_organization_id_organization_id_fk", + "tableFrom": "member", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limit": { + "name": "rate_limit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_request": { + "name": "last_request", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "rate_limit_key_idx": { + "name": "rate_limit_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscription": { + "name": "subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'incomplete'" + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_start": { + "name": "trial_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_end": { + "name": "trial_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cancel_at": { + "name": "cancel_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "billing_interval": { + "name": "billing_interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_schedule_id": { + "name": "stripe_schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "subscription_reference_id_idx": { + "name": "subscription_reference_id_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "subscription_stripe_customer_id_idx": { + "name": "subscription_stripe_customer_id_idx", + "columns": [ + { + "expression": "stripe_customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.activity_log": { + "name": "activity_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "activity_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "activity_log_organization_id_idx": { + "name": "activity_log_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_actor_id_idx": { + "name": "activity_log_actor_id_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_resource_idx": { + "name": "activity_log_resource_idx", + "columns": [ + { + "expression": "resource_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resource_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_created_at_idx": { + "name": "activity_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_log_organization_id_organization_id_fk": { + "name": "activity_log_organization_id_organization_id_fk", + "tableFrom": "activity_log", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "activity_log_actor_id_user_id_fk": { + "name": "activity_log_actor_id_user_id_fk", + "tableFrom": "activity_log", + "tableTo": "user", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_config": { + "name": "ai_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Default'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gpt-4o-mini'" + }, + "api_key_encrypted": { + "name": "api_key_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4096 + }, + "input_price_per_1m": { + "name": "input_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "output_price_per_1m": { + "name": "output_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_default_chatbot": { + "name": "is_default_chatbot", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_default_analysis": { + "name": "is_default_analysis", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_config_organization_id_idx": { + "name": "ai_config_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_config_default_chatbot_idx": { + "name": "ai_config_default_chatbot_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_config\".\"is_default_chatbot\" = true", + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_config_default_analysis_idx": { + "name": "ai_config_default_analysis_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_config\".\"is_default_analysis\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_config_organization_id_organization_id_fk": { + "name": "ai_config_organization_id_organization_id_fk", + "tableFrom": "ai_config", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.analysis_run": { + "name": "analysis_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "analysis_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'completed'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "criteria_snapshot": { + "name": "criteria_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "composite_score": { + "name": "composite_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "prompt_tokens": { + "name": "prompt_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "completion_tokens": { + "name": "completion_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cost_usd_micros": { + "name": "cost_usd_micros", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "billing_mode": { + "name": "billing_mode", + "type": "analysis_billing_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'byok'" + }, + "raw_response": { + "name": "raw_response", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scored_by_id": { + "name": "scored_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "analysis_run_organization_id_idx": { + "name": "analysis_run_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analysis_run_application_id_idx": { + "name": "analysis_run_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analysis_run_created_at_idx": { + "name": "analysis_run_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "analysis_run_organization_id_organization_id_fk": { + "name": "analysis_run_organization_id_organization_id_fk", + "tableFrom": "analysis_run", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_run_application_id_application_id_fk": { + "name": "analysis_run_application_id_application_id_fk", + "tableFrom": "analysis_run", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_run_scored_by_id_user_id_fk": { + "name": "analysis_run_scored_by_id_user_id_fk", + "tableFrom": "analysis_run", + "tableTo": "user", + "columnsFrom": [ + "scored_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application": { + "name": "application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "application_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cover_letter_text": { + "name": "cover_letter_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_rule": { + "name": "auto_rule", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_organization_id_idx": { + "name": "application_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_candidate_id_idx": { + "name": "application_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_job_id_idx": { + "name": "application_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_org_candidate_job_idx": { + "name": "application_org_candidate_job_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_organization_id_organization_id_fk": { + "name": "application_organization_id_organization_id_fk", + "tableFrom": "application", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_candidate_id_candidate_id_fk": { + "name": "application_candidate_id_candidate_id_fk", + "tableFrom": "application", + "tableTo": "candidate", + "columnsFrom": [ + "candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_job_id_job_id_fk": { + "name": "application_job_id_job_id_fk", + "tableFrom": "application", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application_rule": { + "name": "application_rule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_type": { + "name": "match_type", + "type": "rule_match_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'all'" + }, + "action": { + "name": "action", + "type": "rule_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'rejected'" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_rule_organization_id_idx": { + "name": "application_rule_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_rule_job_id_idx": { + "name": "application_rule_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_rule_organization_id_organization_id_fk": { + "name": "application_rule_organization_id_organization_id_fk", + "tableFrom": "application_rule", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_rule_job_id_job_id_fk": { + "name": "application_rule_job_id_job_id_fk", + "tableFrom": "application_rule", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application_source": { + "name": "application_source", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "source_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'direct'" + }, + "tracking_link_id": { + "name": "tracking_link_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_source": { + "name": "utm_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_medium": { + "name": "utm_medium", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_campaign": { + "name": "utm_campaign", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_term": { + "name": "utm_term", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_content": { + "name": "utm_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "referrer_domain": { + "name": "referrer_domain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_source_organization_id_idx": { + "name": "application_source_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_application_id_idx": { + "name": "application_source_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_channel_idx": { + "name": "application_source_channel_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_tracking_link_id_idx": { + "name": "application_source_tracking_link_id_idx", + "columns": [ + { + "expression": "tracking_link_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_application_idx": { + "name": "application_source_application_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_source_organization_id_organization_id_fk": { + "name": "application_source_organization_id_organization_id_fk", + "tableFrom": "application_source", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_source_application_id_application_id_fk": { + "name": "application_source_application_id_application_id_fk", + "tableFrom": "application_source", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_source_tracking_link_id_tracking_link_id_fk": { + "name": "application_source_tracking_link_id_tracking_link_id_fk", + "tableFrom": "application_source", + "tableTo": "tracking_link", + "columnsFrom": [ + "tracking_link_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.calendar_integration": { + "name": "calendar_integration", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "calendar_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'google'" + }, + "access_token_encrypted": { + "name": "access_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token_encrypted": { + "name": "refresh_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "calendar_id": { + "name": "calendar_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'primary'" + }, + "account_email": { + "name": "account_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_channel_id": { + "name": "webhook_channel_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_resource_id": { + "name": "webhook_resource_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_expiration": { + "name": "webhook_expiration", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sync_token": { + "name": "sync_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "calendar_integration_user_provider_idx": { + "name": "calendar_integration_user_provider_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "calendar_integration_webhook_channel_idx": { + "name": "calendar_integration_webhook_channel_idx", + "columns": [ + { + "expression": "webhook_channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "calendar_integration_user_id_user_id_fk": { + "name": "calendar_integration_user_id_user_id_fk", + "tableFrom": "calendar_integration", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate": { + "name": "candidate", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "gender", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quick_notes": { + "name": "quick_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retention_exempt_until": { + "name": "retention_exempt_until", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "retention_exempt_reason": { + "name": "retention_exempt_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retention_reviewed_at": { + "name": "retention_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "quarantined_at": { + "name": "quarantined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scheduled_purge_at": { + "name": "scheduled_purge_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_organization_id_idx": { + "name": "candidate_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_gender_idx": { + "name": "candidate_gender_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "gender", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_org_email_idx": { + "name": "candidate_org_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_quarantine_idx": { + "name": "candidate_quarantine_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_purge_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_organization_id_organization_id_fk": { + "name": "candidate_organization_id_organization_id_fk", + "tableFrom": "candidate", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_conversation": { + "name": "candidate_conversation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_token": { + "name": "reply_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unread_count": { + "name": "unread_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_conversation_organization_id_idx": { + "name": "candidate_conversation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_application_id_idx": { + "name": "candidate_conversation_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_reply_token_idx": { + "name": "candidate_conversation_reply_token_idx", + "columns": [ + { + "expression": "reply_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_last_message_at_idx": { + "name": "candidate_conversation_last_message_at_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_conversation_organization_id_organization_id_fk": { + "name": "candidate_conversation_organization_id_organization_id_fk", + "tableFrom": "candidate_conversation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_conversation_application_id_application_id_fk": { + "name": "candidate_conversation_application_id_application_id_fk", + "tableFrom": "candidate_conversation", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message": { + "name": "candidate_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "candidate_message_direction", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "candidate_message_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'message'" + }, + "interview_id": { + "name": "interview_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calendar_attachment_status": { + "name": "calendar_attachment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_applicable'" + }, + "calendar_attachment_error": { + "name": "calendar_attachment_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calendar_sequence": { + "name": "calendar_sequence", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internet_message_id": { + "name": "internet_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "in_reply_to": { + "name": "in_reply_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "references": { + "name": "references", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sent_by_id": { + "name": "sent_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_status_at": { + "name": "provider_status_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_organization_id_idx": { + "name": "candidate_message_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_conversation_id_idx": { + "name": "candidate_message_conversation_id_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_interview_id_idx": { + "name": "candidate_message_interview_id_idx", + "columns": [ + { + "expression": "interview_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_provider_id_idx": { + "name": "candidate_message_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_internet_id_idx": { + "name": "candidate_message_internet_id_idx", + "columns": [ + { + "expression": "internet_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_message_organization_id_organization_id_fk": { + "name": "candidate_message_organization_id_organization_id_fk", + "tableFrom": "candidate_message", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_conversation_id_candidate_conversation_id_fk": { + "name": "candidate_message_conversation_id_candidate_conversation_id_fk", + "tableFrom": "candidate_message", + "tableTo": "candidate_conversation", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_interview_id_interview_id_fk": { + "name": "candidate_message_interview_id_interview_id_fk", + "tableFrom": "candidate_message", + "tableTo": "interview", + "columnsFrom": [ + "interview_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidate_message_sent_by_id_user_id_fk": { + "name": "candidate_message_sent_by_id_user_id_fk", + "tableFrom": "candidate_message", + "tableTo": "user", + "columnsFrom": [ + "sent_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message_attachment": { + "name": "candidate_message_attachment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "provider_attachment_id": { + "name": "provider_attachment_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_attachment_organization_id_idx": { + "name": "candidate_message_attachment_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_attachment_message_id_idx": { + "name": "candidate_message_attachment_message_id_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_message_attachment_organization_id_organization_id_fk": { + "name": "candidate_message_attachment_organization_id_organization_id_fk", + "tableFrom": "candidate_message_attachment", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_attachment_message_id_candidate_message_id_fk": { + "name": "candidate_message_attachment_message_id_candidate_message_id_fk", + "tableFrom": "candidate_message_attachment", + "tableTo": "candidate_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "candidate_message_attachment_storage_key_unique": { + "name": "candidate_message_attachment_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + }, + "candidate_message_attachment_provider_attachment_id_unique": { + "name": "candidate_message_attachment_provider_attachment_id_unique", + "nullsNotDistinct": false, + "columns": [ + "provider_attachment_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message_webhook_event": { + "name": "candidate_message_webhook_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_webhook_provider_id_idx": { + "name": "candidate_message_webhook_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_webhook_unprocessed_idx": { + "name": "candidate_message_webhook_unprocessed_idx", + "columns": [ + { + "expression": "processed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.career_page": { + "name": "career_page", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "accent_color": { + "name": "accent_color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headline": { + "name": "headline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_storage_key": { + "name": "logo_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_storage_key": { + "name": "banner_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_position": { + "name": "banner_position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "career_page_organization_id_idx": { + "name": "career_page_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "career_page_slug_idx": { + "name": "career_page_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "career_page_organization_id_organization_id_fk": { + "name": "career_page_organization_id_organization_id_fk", + "tableFrom": "career_page", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_agent": { + "name": "chatbot_agent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system_prompt": { + "name": "system_prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(3, 2)", + "primaryKey": false, + "notNull": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_agent_org_user_idx": { + "name": "chatbot_agent_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_agent_default_per_user_idx": { + "name": "chatbot_agent_default_per_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"chatbot_agent\".\"is_default\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_agent_organization_id_organization_id_fk": { + "name": "chatbot_agent_organization_id_organization_id_fk", + "tableFrom": "chatbot_agent", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_agent_user_id_user_id_fk": { + "name": "chatbot_agent_user_id_user_id_fk", + "tableFrom": "chatbot_agent", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_conversation": { + "name": "chatbot_conversation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ai_config_id": { + "name": "ai_config_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'New chat'" + }, + "scope": { + "name": "scope", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "thinking": { + "name": "thinking", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "last_message_preview": { + "name": "last_message_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_conversation_org_user_idx": { + "name": "chatbot_conversation_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_conversation_folder_idx": { + "name": "chatbot_conversation_folder_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_conversation_last_message_at_idx": { + "name": "chatbot_conversation_last_message_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_conversation_organization_id_organization_id_fk": { + "name": "chatbot_conversation_organization_id_organization_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_conversation_user_id_user_id_fk": { + "name": "chatbot_conversation_user_id_user_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_conversation_folder_id_chatbot_folder_id_fk": { + "name": "chatbot_conversation_folder_id_chatbot_folder_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "chatbot_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chatbot_conversation_agent_id_chatbot_agent_id_fk": { + "name": "chatbot_conversation_agent_id_chatbot_agent_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "chatbot_agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chatbot_conversation_ai_config_id_ai_config_id_fk": { + "name": "chatbot_conversation_ai_config_id_ai_config_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "ai_config", + "columnsFrom": [ + "ai_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_folder": { + "name": "chatbot_folder", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_folder_org_user_idx": { + "name": "chatbot_folder_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_folder_organization_id_organization_id_fk": { + "name": "chatbot_folder_organization_id_organization_id_fk", + "tableFrom": "chatbot_folder", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_folder_user_id_user_id_fk": { + "name": "chatbot_folder_user_id_user_id_fk", + "tableFrom": "chatbot_folder", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_message": { + "name": "chatbot_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "chatbot_message_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_calls": { + "name": "tool_calls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sources": { + "name": "sources", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_message_conversation_idx": { + "name": "chatbot_message_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_message_conversation_id_chatbot_conversation_id_fk": { + "name": "chatbot_message_conversation_id_chatbot_conversation_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "chatbot_conversation", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_message_organization_id_organization_id_fk": { + "name": "chatbot_message_organization_id_organization_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_message_user_id_user_id_fk": { + "name": "chatbot_message_user_id_user_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comment": { + "name": "comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "comment_target", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comment_organization_id_idx": { + "name": "comment_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "comment_target_idx": { + "name": "comment_target_idx", + "columns": [ + { + "expression": "target_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "comment_author_id_idx": { + "name": "comment_author_id_idx", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "comment_organization_id_organization_id_fk": { + "name": "comment_organization_id_organization_id_fk", + "tableFrom": "comment", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comment_author_id_user_id_fk": { + "name": "comment_author_id_user_id_fk", + "tableFrom": "comment", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.criterion_score": { + "name": "criterion_score", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "criterion_key": { + "name": "criterion_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "max_score": { + "name": "max_score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "applicant_score": { + "name": "applicant_score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "confidence": { + "name": "confidence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "evidence": { + "name": "evidence", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "strengths": { + "name": "strengths", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "gaps": { + "name": "gaps", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "criterion_score_organization_id_idx": { + "name": "criterion_score_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "criterion_score_application_id_idx": { + "name": "criterion_score_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "criterion_score_app_criterion_idx": { + "name": "criterion_score_app_criterion_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "criterion_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "criterion_score_organization_id_organization_id_fk": { + "name": "criterion_score_organization_id_organization_id_fk", + "tableFrom": "criterion_score", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "criterion_score_application_id_application_id_fk": { + "name": "criterion_score_application_id_application_id_fk", + "tableFrom": "criterion_score", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.document": { + "name": "document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "document_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'resume'" + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "original_filename": { + "name": "original_filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parsed_content": { + "name": "parsed_content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "document_organization_id_idx": { + "name": "document_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "document_candidate_id_idx": { + "name": "document_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "document_organization_id_organization_id_fk": { + "name": "document_organization_id_organization_id_fk", + "tableFrom": "document", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "document_candidate_id_candidate_id_fk": { + "name": "document_candidate_id_candidate_id_fk", + "tableFrom": "document", + "tableTo": "candidate", + "columnsFrom": [ + "candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "document_storage_key_unique": { + "name": "document_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_suppression": { + "name": "email_suppression", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "email_suppression_reason", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_suppression_email_idx": { + "name": "email_suppression_email_idx", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_template": { + "name": "email_template", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_template_organization_id_idx": { + "name": "email_template_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "email_template_created_by_id_idx": { + "name": "email_template_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_template_organization_id_organization_id_fk": { + "name": "email_template_organization_id_organization_id_fk", + "tableFrom": "email_template", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_template_created_by_id_user_id_fk": { + "name": "email_template_created_by_id_user_id_fk", + "tableFrom": "email_template", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_job": { + "name": "import_job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "import_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'processing'" + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "columns": { + "name": "columns", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "target_job_id": { + "name": "target_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_rows": { + "name": "total_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "committed_rows": { + "name": "committed_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "import_job_organization_id_idx": { + "name": "import_job_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_job_status_idx": { + "name": "import_job_status_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_job_organization_id_organization_id_fk": { + "name": "import_job_organization_id_organization_id_fk", + "tableFrom": "import_job", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_job_created_by_user_id_fk": { + "name": "import_job_created_by_user_id_fk", + "tableFrom": "import_job", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_job_target_job_id_job_id_fk": { + "name": "import_job_target_job_id_job_id_fk", + "tableFrom": "import_job", + "tableTo": "job", + "columnsFrom": [ + "target_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_row": { + "name": "import_row", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_index": { + "name": "row_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "raw_data": { + "name": "raw_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "normalized_data": { + "name": "normalized_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "import_row_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'ready'" + }, + "dedupe_hash": { + "name": "dedupe_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "matched_candidate_id": { + "name": "matched_candidate_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_candidate_id": { + "name": "created_candidate_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "import_row_job_id_idx": { + "name": "import_row_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_row_job_status_idx": { + "name": "import_row_job_status_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_row_dedupe_idx": { + "name": "import_row_dedupe_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_row_organization_id_organization_id_fk": { + "name": "import_row_organization_id_organization_id_fk", + "tableFrom": "import_row", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_job_id_import_job_id_fk": { + "name": "import_row_job_id_import_job_id_fk", + "tableFrom": "import_row", + "tableTo": "import_job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_matched_candidate_id_candidate_id_fk": { + "name": "import_row_matched_candidate_id_candidate_id_fk", + "tableFrom": "import_row", + "tableTo": "candidate", + "columnsFrom": [ + "matched_candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "import_row_created_candidate_id_candidate_id_fk": { + "name": "import_row_created_candidate_id_candidate_id_fk", + "tableFrom": "import_row", + "tableTo": "candidate", + "columnsFrom": [ + "created_candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.interview": { + "name": "interview", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "interview_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'video'" + }, + "status": { + "name": "status", + "type": "interview_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "personal_note": { + "name": "personal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interviewers": { + "name": "interviewers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invitation_sent_at": { + "name": "invitation_sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "candidate_response": { + "name": "candidate_response", + "type": "candidate_response", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "candidate_responded_at": { + "name": "candidate_responded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "google_calendar_event_id": { + "name": "google_calendar_event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_calendar_event_link": { + "name": "google_calendar_event_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'UTC'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "interview_organization_id_idx": { + "name": "interview_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_application_id_idx": { + "name": "interview_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_scheduled_at_idx": { + "name": "interview_scheduled_at_idx", + "columns": [ + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_status_idx": { + "name": "interview_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_created_by_id_idx": { + "name": "interview_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "interview_organization_id_organization_id_fk": { + "name": "interview_organization_id_organization_id_fk", + "tableFrom": "interview", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "interview_application_id_application_id_fk": { + "name": "interview_application_id_application_id_fk", + "tableFrom": "interview", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "interview_created_by_id_user_id_fk": { + "name": "interview_created_by_id_user_id_fk", + "tableFrom": "interview", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invite_link": { + "name": "invite_link", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "max_uses": { + "name": "max_uses", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invite_link_organization_id_idx": { + "name": "invite_link_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invite_link_token_idx": { + "name": "invite_link_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invite_link_organization_id_organization_id_fk": { + "name": "invite_link_organization_id_organization_id_fk", + "tableFrom": "invite_link", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invite_link_created_by_id_user_id_fk": { + "name": "invite_link_created_by_id_user_id_fk", + "tableFrom": "invite_link", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invite_link_token_unique": { + "name": "invite_link_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job": { + "name": "job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "job_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'full_time'" + }, + "status": { + "name": "status", + "type": "job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "salary_min": { + "name": "salary_min", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "salary_max": { + "name": "salary_max", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "salary_currency": { + "name": "salary_currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salary_unit": { + "name": "salary_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salary_negotiable": { + "name": "salary_negotiable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "remote_status": { + "name": "remote_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valid_through": { + "name": "valid_through", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "experience_level": { + "name": "experience_level", + "type": "experience_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "phone_requirement": { + "name": "phone_requirement", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'optional'" + }, + "require_resume": { + "name": "require_resume", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "require_cover_letter": { + "name": "require_cover_letter", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_score_on_apply": { + "name": "auto_score_on_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "analysis_context": { + "name": "analysis_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"coverLetter\":true,\"screeningAnswers\":true,\"recruiterNotes\":false}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_organization_id_idx": { + "name": "job_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_organization_id_organization_id_fk": { + "name": "job_organization_id_organization_id_fk", + "tableFrom": "job", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "job_slug_unique": { + "name": "job_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job_question": { + "name": "job_question", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "question_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'short_text'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "options": { + "name": "options", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_question_organization_id_idx": { + "name": "job_question_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_question_job_id_idx": { + "name": "job_question_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_question_organization_id_organization_id_fk": { + "name": "job_question_organization_id_organization_id_fk", + "tableFrom": "job_question", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_question_job_id_job_id_fk": { + "name": "job_question_job_id_job_id_fk", + "tableFrom": "job_question", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.join_request": { + "name": "join_request", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "join_request_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "reviewed_by_id": { + "name": "reviewed_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "join_request_organization_id_idx": { + "name": "join_request_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "join_request_user_id_idx": { + "name": "join_request_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "join_request_status_idx": { + "name": "join_request_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "join_request_user_id_user_id_fk": { + "name": "join_request_user_id_user_id_fk", + "tableFrom": "join_request", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "join_request_organization_id_organization_id_fk": { + "name": "join_request_organization_id_organization_id_fk", + "tableFrom": "join_request", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "join_request_reviewed_by_id_user_id_fk": { + "name": "join_request_reviewed_by_id_user_id_fk", + "tableFrom": "join_request", + "tableTo": "user", + "columnsFrom": [ + "reviewed_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_outbox": { + "name": "notification_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_email": { + "name": "recipient_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "cadence": { + "name": "cadence", + "type": "notification_cadence", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "notification_outbox_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "digest_bucket": { + "name": "digest_bucket", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_outbox_dedupe_key_idx": { + "name": "notification_outbox_dedupe_key_idx", + "columns": [ + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_pull_idx": { + "name": "notification_outbox_pull_idx", + "columns": [ + { + "expression": "cadence", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"notification_outbox\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_provider_id_idx": { + "name": "notification_outbox_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"notification_outbox\".\"provider_message_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_organization_id_idx": { + "name": "notification_outbox_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_digest_idx": { + "name": "notification_outbox_digest_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "digest_bucket", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_outbox_organization_id_organization_id_fk": { + "name": "notification_outbox_organization_id_organization_id_fk", + "tableFrom": "notification_outbox", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_outbox_recipient_user_id_user_id_fk": { + "name": "notification_outbox_recipient_user_id_user_id_fk", + "tableFrom": "notification_outbox", + "tableTo": "user", + "columnsFrom": [ + "recipient_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_preference": { + "name": "notification_preference", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "channel_mode": { + "name": "channel_mode", + "type": "notification_channel_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_preference_user_org_type_idx": { + "name": "notification_preference_user_org_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_preference_organization_id_idx": { + "name": "notification_preference_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_preference_user_id_user_id_fk": { + "name": "notification_preference_user_id_user_id_fk", + "tableFrom": "notification_preference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preference_organization_id_organization_id_fk": { + "name": "notification_preference_organization_id_organization_id_fk", + "tableFrom": "notification_preference", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.onboarding_survey_response": { + "name": "onboarding_survey_response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signup_plan": { + "name": "signup_plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signup_billing": { + "name": "signup_billing", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company_size": { + "name": "company_size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_role": { + "name": "user_role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discovery_source": { + "name": "discovery_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_hiring_process": { + "name": "current_hiring_process", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_roles_12m": { + "name": "expected_roles_12m", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_count": { + "name": "answered_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped_count": { + "name": "skipped_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_survey_response_user_id_idx": { + "name": "onboarding_survey_response_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_survey_response_organization_id_idx": { + "name": "onboarding_survey_response_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_survey_response_user_id_user_id_fk": { + "name": "onboarding_survey_response_user_id_user_id_fk", + "tableFrom": "onboarding_survey_response", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_survey_response_organization_id_organization_id_fk": { + "name": "onboarding_survey_response_organization_id_organization_id_fk", + "tableFrom": "onboarding_survey_response", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_settings": { + "name": "org_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name_display_format": { + "name": "name_display_format", + "type": "name_display_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'first_last'" + }, + "date_format": { + "name": "date_format", + "type": "date_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'mdy'" + }, + "retention_enabled": { + "name": "retention_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "retention_months": { + "name": "retention_months", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "quarantine_days": { + "name": "quarantine_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "retention_activated_at": { + "name": "retention_activated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "privacy_policy_url": { + "name": "privacy_policy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privacy_policy_text": { + "name": "privacy_policy_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privacy_contact_email": { + "name": "privacy_contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_settings_organization_id_idx": { + "name": "org_settings_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "org_settings_organization_id_organization_id_fk": { + "name": "org_settings_organization_id_organization_id_fk", + "tableFrom": "org_settings", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_ai_config": { + "name": "platform_ai_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Platform (OpenRouter)'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openrouter'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai/gpt-5.4-mini'" + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4096 + }, + "input_price_per_1m": { + "name": "input_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "output_price_per_1m": { + "name": "output_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_default_analysis": { + "name": "is_default_analysis", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_enabled": { + "name": "is_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "platform_ai_config_organization_id_idx": { + "name": "platform_ai_config_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "platform_ai_config_organization_id_organization_id_fk": { + "name": "platform_ai_config_organization_id_organization_id_fk", + "tableFrom": "platform_ai_config", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.property_definition": { + "name": "property_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "property_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "property_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "property_definition_org_idx": { + "name": "property_definition_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_definition_org_entity_idx": { + "name": "property_definition_org_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_definition_job_idx": { + "name": "property_definition_job_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "property_definition_organization_id_organization_id_fk": { + "name": "property_definition_organization_id_organization_id_fk", + "tableFrom": "property_definition", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "property_definition_job_id_job_id_fk": { + "name": "property_definition_job_id_job_id_fk", + "tableFrom": "property_definition", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.property_value": { + "name": "property_value", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "property_definition_id": { + "name": "property_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "property_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "property_value_org_idx": { + "name": "property_value_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_entity_idx": { + "name": "property_value_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_definition_idx": { + "name": "property_value_definition_idx", + "columns": [ + { + "expression": "property_definition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_def_entity_idx": { + "name": "property_value_def_entity_idx", + "columns": [ + { + "expression": "property_definition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "property_value_organization_id_organization_id_fk": { + "name": "property_value_organization_id_organization_id_fk", + "tableFrom": "property_value", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "property_value_property_definition_id_property_definition_id_fk": { + "name": "property_value_property_definition_id_property_definition_id_fk", + "tableFrom": "property_value", + "tableTo": "property_definition", + "columnsFrom": [ + "property_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.question_response": { + "name": "question_response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "question_id": { + "name": "question_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "question_response_organization_id_idx": { + "name": "question_response_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "question_response_application_id_idx": { + "name": "question_response_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "question_response_question_id_idx": { + "name": "question_response_question_id_idx", + "columns": [ + { + "expression": "question_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "question_response_organization_id_organization_id_fk": { + "name": "question_response_organization_id_organization_id_fk", + "tableFrom": "question_response", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "question_response_application_id_application_id_fk": { + "name": "question_response_application_id_application_id_fk", + "tableFrom": "question_response", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "question_response_question_id_job_question_id_fk": { + "name": "question_response_question_id_job_question_id_fk", + "tableFrom": "question_response", + "tableTo": "job_question", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.retention_audit": { + "name": "retention_audit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "retention_audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'success'" + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "retention_audit_organization_id_idx": { + "name": "retention_audit_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "retention_audit_candidate_id_idx": { + "name": "retention_audit_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "retention_audit_created_at_idx": { + "name": "retention_audit_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "retention_audit_organization_id_organization_id_fk": { + "name": "retention_audit_organization_id_organization_id_fk", + "tableFrom": "retention_audit", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scoring_criterion": { + "name": "scoring_criterion", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "criterion_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'custom'" + }, + "max_score": { + "name": "max_score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "weight": { + "name": "weight", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "scoring_criterion_organization_id_idx": { + "name": "scoring_criterion_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scoring_criterion_job_id_idx": { + "name": "scoring_criterion_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scoring_criterion_job_key_idx": { + "name": "scoring_criterion_job_key_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "scoring_criterion_organization_id_organization_id_fk": { + "name": "scoring_criterion_organization_id_organization_id_fk", + "tableFrom": "scoring_criterion", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "scoring_criterion_job_id_job_id_fk": { + "name": "scoring_criterion_job_id_job_id_fk", + "tableFrom": "scoring_criterion", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tracking_link": { + "name": "tracking_link", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "source_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'custom'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "utm_source": { + "name": "utm_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_medium": { + "name": "utm_medium", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_campaign": { + "name": "utm_campaign", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_term": { + "name": "utm_term", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_content": { + "name": "utm_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "click_count": { + "name": "click_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "application_count": { + "name": "application_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tracking_link_organization_id_idx": { + "name": "tracking_link_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_job_id_idx": { + "name": "tracking_link_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_code_idx": { + "name": "tracking_link_code_idx", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_channel_idx": { + "name": "tracking_link_channel_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tracking_link_organization_id_organization_id_fk": { + "name": "tracking_link_organization_id_organization_id_fk", + "tableFrom": "tracking_link", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tracking_link_job_id_job_id_fk": { + "name": "tracking_link_job_id_job_id_fk", + "tableFrom": "tracking_link", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tracking_link_created_by_id_user_id_fk": { + "name": "tracking_link_created_by_id_user_id_fk", + "tableFrom": "tracking_link", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tracking_link_code_unique": { + "name": "tracking_link_code_unique", + "nullsNotDistinct": false, + "columns": [ + "code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sso_provider": { + "name": "sso_provider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "issuer": { + "name": "issuer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "oidc_config": { + "name": "oidc_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "saml_config": { + "name": "saml_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sso_provider_domain_idx": { + "name": "sso_provider_domain_idx", + "columns": [ + { + "expression": "domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_provider_id_idx": { + "name": "sso_provider_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_organization_id_idx": { + "name": "sso_provider_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sso_provider_user_id_user_id_fk": { + "name": "sso_provider_user_id_user_id_fk", + "tableFrom": "sso_provider", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sso_provider_organization_id_organization_id_fk": { + "name": "sso_provider_organization_id_organization_id_fk", + "tableFrom": "sso_provider", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.activity_action": { + "name": "activity_action", + "schema": "public", + "values": [ + "created", + "updated", + "deleted", + "status_changed", + "comment_added", + "member_invited", + "member_removed", + "member_role_changed", + "scored" + ] + }, + "public.analysis_billing_mode": { + "name": "analysis_billing_mode", + "schema": "public", + "values": [ + "platform", + "byok" + ] + }, + "public.analysis_run_status": { + "name": "analysis_run_status", + "schema": "public", + "values": [ + "completed", + "failed", + "partial" + ] + }, + "public.application_status": { + "name": "application_status", + "schema": "public", + "values": [ + "new", + "screening", + "interview", + "offer", + "hired", + "rejected" + ] + }, + "public.calendar_provider": { + "name": "calendar_provider", + "schema": "public", + "values": [ + "google" + ] + }, + "public.candidate_message_direction": { + "name": "candidate_message_direction", + "schema": "public", + "values": [ + "inbound", + "outbound" + ] + }, + "public.candidate_message_status": { + "name": "candidate_message_status", + "schema": "public", + "values": [ + "queued", + "sent", + "delivered", + "delayed", + "bounced", + "failed", + "complained" + ] + }, + "public.candidate_response": { + "name": "candidate_response", + "schema": "public", + "values": [ + "pending", + "accepted", + "declined", + "tentative" + ] + }, + "public.chatbot_message_role": { + "name": "chatbot_message_role", + "schema": "public", + "values": [ + "user", + "assistant" + ] + }, + "public.comment_target": { + "name": "comment_target", + "schema": "public", + "values": [ + "candidate", + "application", + "job" + ] + }, + "public.criterion_category": { + "name": "criterion_category", + "schema": "public", + "values": [ + "technical", + "experience", + "soft_skills", + "education", + "culture", + "custom" + ] + }, + "public.date_format": { + "name": "date_format", + "schema": "public", + "values": [ + "mdy", + "dmy", + "ymd" + ] + }, + "public.document_type": { + "name": "document_type", + "schema": "public", + "values": [ + "resume", + "cover_letter", + "other" + ] + }, + "public.email_suppression_reason": { + "name": "email_suppression_reason", + "schema": "public", + "values": [ + "bounce", + "complaint" + ] + }, + "public.experience_level": { + "name": "experience_level", + "schema": "public", + "values": [ + "junior", + "mid", + "senior", + "lead" + ] + }, + "public.gender": { + "name": "gender", + "schema": "public", + "values": [ + "male", + "female", + "other", + "prefer_not_to_say" + ] + }, + "public.import_job_status": { + "name": "import_job_status", + "schema": "public", + "values": [ + "processing", + "previewing", + "committing", + "completed", + "failed" + ] + }, + "public.import_row_status": { + "name": "import_row_status", + "schema": "public", + "values": [ + "ready", + "duplicate", + "duplicate_in_file", + "error", + "committed", + "skipped" + ] + }, + "public.import_source": { + "name": "import_source", + "schema": "public", + "values": [ + "csv", + "xlsx", + "resume_zip" + ] + }, + "public.interview_status": { + "name": "interview_status", + "schema": "public", + "values": [ + "scheduled", + "completed", + "cancelled", + "no_show" + ] + }, + "public.interview_type": { + "name": "interview_type", + "schema": "public", + "values": [ + "phone", + "video", + "in_person", + "panel", + "technical", + "take_home" + ] + }, + "public.job_status": { + "name": "job_status", + "schema": "public", + "values": [ + "draft", + "open", + "closed", + "archived" + ] + }, + "public.job_type": { + "name": "job_type", + "schema": "public", + "values": [ + "full_time", + "part_time", + "contract", + "internship" + ] + }, + "public.join_request_status": { + "name": "join_request_status", + "schema": "public", + "values": [ + "pending", + "approved", + "rejected" + ] + }, + "public.name_display_format": { + "name": "name_display_format", + "schema": "public", + "values": [ + "first_last", + "last_first" + ] + }, + "public.notification_cadence": { + "name": "notification_cadence", + "schema": "public", + "values": [ + "instant", + "digest" + ] + }, + "public.notification_channel_mode": { + "name": "notification_channel_mode", + "schema": "public", + "values": [ + "instant", + "digest", + "off" + ] + }, + "public.notification_outbox_status": { + "name": "notification_outbox_status", + "schema": "public", + "values": [ + "pending", + "sent", + "skipped", + "dead" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "candidate_replied", + "application_created", + "interview_response" + ] + }, + "public.property_entity_type": { + "name": "property_entity_type", + "schema": "public", + "values": [ + "candidate", + "application" + ] + }, + "public.property_type": { + "name": "property_type", + "schema": "public", + "values": [ + "text", + "long_text", + "number", + "select", + "multi_select", + "date", + "checkbox", + "url", + "email", + "person", + "file" + ] + }, + "public.question_type": { + "name": "question_type", + "schema": "public", + "values": [ + "short_text", + "long_text", + "single_select", + "multi_select", + "number", + "date", + "url", + "checkbox", + "file_upload" + ] + }, + "public.retention_audit_action": { + "name": "retention_audit_action", + "schema": "public", + "values": [ + "quarantined", + "restored", + "erased", + "exempted", + "unexempted", + "exported" + ] + }, + "public.rule_action": { + "name": "rule_action", + "schema": "public", + "values": [ + "rejected", + "screening", + "interview" + ] + }, + "public.rule_match_type": { + "name": "rule_match_type", + "schema": "public", + "values": [ + "all", + "any" + ] + }, + "public.source_channel": { + "name": "source_channel", + "schema": "public", + "values": [ + "linkedin", + "indeed", + "glassdoor", + "ziprecruiter", + "monster", + "handshake", + "angellist", + "wellfound", + "dice", + "stackoverflow", + "weworkremotely", + "remoteok", + "builtin", + "hired", + "lever", + "greenhouse_board", + "google_jobs", + "facebook", + "twitter", + "instagram", + "tiktok", + "reddit", + "referral", + "career_site", + "email", + "event", + "agency", + "direct", + "other", + "custom" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/server/database/migrations/meta/0053_snapshot.json b/server/database/migrations/meta/0053_snapshot.json new file mode 100644 index 00000000..5ccc1df0 --- /dev/null +++ b/server/database/migrations/meta/0053_snapshot.json @@ -0,0 +1,8018 @@ +{ + "id": "f64582af-c6d7-4b97-836f-5512e08dbae5", + "prevId": "4d7cb462-bca2-40d1-9dba-7a9c27ded8ce", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation": { + "name": "invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inviter_id": { + "name": "inviter_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_organization_id_idx": { + "name": "invitation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_inviter_id_user_id_fk": { + "name": "invitation_inviter_id_user_id_fk", + "tableFrom": "invitation", + "tableTo": "user", + "columnsFrom": [ + "inviter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_organization_id_organization_id_fk": { + "name": "invitation_organization_id_organization_id_fk", + "tableFrom": "invitation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.member": { + "name": "member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "member_user_id_idx": { + "name": "member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_organization_id_idx": { + "name": "member_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_user_org_unique_idx": { + "name": "member_user_org_unique_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "member_user_id_user_id_fk": { + "name": "member_user_id_user_id_fk", + "tableFrom": "member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "member_organization_id_organization_id_fk": { + "name": "member_organization_id_organization_id_fk", + "tableFrom": "member", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limit": { + "name": "rate_limit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_request": { + "name": "last_request", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "rate_limit_key_idx": { + "name": "rate_limit_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscription": { + "name": "subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'incomplete'" + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_start": { + "name": "trial_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_end": { + "name": "trial_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cancel_at": { + "name": "cancel_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "billing_interval": { + "name": "billing_interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_schedule_id": { + "name": "stripe_schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "subscription_reference_id_idx": { + "name": "subscription_reference_id_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "subscription_stripe_customer_id_idx": { + "name": "subscription_stripe_customer_id_idx", + "columns": [ + { + "expression": "stripe_customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.activity_log": { + "name": "activity_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "activity_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "activity_log_organization_id_idx": { + "name": "activity_log_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_actor_id_idx": { + "name": "activity_log_actor_id_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_resource_idx": { + "name": "activity_log_resource_idx", + "columns": [ + { + "expression": "resource_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resource_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_log_created_at_idx": { + "name": "activity_log_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_log_organization_id_organization_id_fk": { + "name": "activity_log_organization_id_organization_id_fk", + "tableFrom": "activity_log", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "activity_log_actor_id_user_id_fk": { + "name": "activity_log_actor_id_user_id_fk", + "tableFrom": "activity_log", + "tableTo": "user", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_config": { + "name": "ai_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Default'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gpt-4o-mini'" + }, + "api_key_encrypted": { + "name": "api_key_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4096 + }, + "input_price_per_1m": { + "name": "input_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "output_price_per_1m": { + "name": "output_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_default_chatbot": { + "name": "is_default_chatbot", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_default_analysis": { + "name": "is_default_analysis", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_config_organization_id_idx": { + "name": "ai_config_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_config_default_chatbot_idx": { + "name": "ai_config_default_chatbot_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_config\".\"is_default_chatbot\" = true", + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_config_default_analysis_idx": { + "name": "ai_config_default_analysis_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_config\".\"is_default_analysis\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_config_organization_id_organization_id_fk": { + "name": "ai_config_organization_id_organization_id_fk", + "tableFrom": "ai_config", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.analysis_run": { + "name": "analysis_run", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "analysis_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'completed'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "criteria_snapshot": { + "name": "criteria_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "composite_score": { + "name": "composite_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "prompt_tokens": { + "name": "prompt_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "completion_tokens": { + "name": "completion_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cost_usd_micros": { + "name": "cost_usd_micros", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "billing_mode": { + "name": "billing_mode", + "type": "analysis_billing_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'byok'" + }, + "raw_response": { + "name": "raw_response", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scored_by_id": { + "name": "scored_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "analysis_run_organization_id_idx": { + "name": "analysis_run_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analysis_run_application_id_idx": { + "name": "analysis_run_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analysis_run_created_at_idx": { + "name": "analysis_run_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "analysis_run_organization_id_organization_id_fk": { + "name": "analysis_run_organization_id_organization_id_fk", + "tableFrom": "analysis_run", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_run_application_id_application_id_fk": { + "name": "analysis_run_application_id_application_id_fk", + "tableFrom": "analysis_run", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_run_scored_by_id_user_id_fk": { + "name": "analysis_run_scored_by_id_user_id_fk", + "tableFrom": "analysis_run", + "tableTo": "user", + "columnsFrom": [ + "scored_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application": { + "name": "application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "application_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cover_letter_text": { + "name": "cover_letter_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_rule": { + "name": "auto_rule", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_organization_id_idx": { + "name": "application_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_candidate_id_idx": { + "name": "application_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_job_id_idx": { + "name": "application_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_org_candidate_job_idx": { + "name": "application_org_candidate_job_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_organization_id_organization_id_fk": { + "name": "application_organization_id_organization_id_fk", + "tableFrom": "application", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_candidate_id_candidate_id_fk": { + "name": "application_candidate_id_candidate_id_fk", + "tableFrom": "application", + "tableTo": "candidate", + "columnsFrom": [ + "candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_job_id_job_id_fk": { + "name": "application_job_id_job_id_fk", + "tableFrom": "application", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application_rule": { + "name": "application_rule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_type": { + "name": "match_type", + "type": "rule_match_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'all'" + }, + "action": { + "name": "action", + "type": "rule_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'rejected'" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_rule_organization_id_idx": { + "name": "application_rule_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_rule_job_id_idx": { + "name": "application_rule_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_rule_organization_id_organization_id_fk": { + "name": "application_rule_organization_id_organization_id_fk", + "tableFrom": "application_rule", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_rule_job_id_job_id_fk": { + "name": "application_rule_job_id_job_id_fk", + "tableFrom": "application_rule", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.application_source": { + "name": "application_source", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "source_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'direct'" + }, + "tracking_link_id": { + "name": "tracking_link_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_source": { + "name": "utm_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_medium": { + "name": "utm_medium", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_campaign": { + "name": "utm_campaign", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_term": { + "name": "utm_term", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_content": { + "name": "utm_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "referrer_domain": { + "name": "referrer_domain", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "application_source_organization_id_idx": { + "name": "application_source_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_application_id_idx": { + "name": "application_source_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_channel_idx": { + "name": "application_source_channel_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_tracking_link_id_idx": { + "name": "application_source_tracking_link_id_idx", + "columns": [ + { + "expression": "tracking_link_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "application_source_application_idx": { + "name": "application_source_application_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "application_source_organization_id_organization_id_fk": { + "name": "application_source_organization_id_organization_id_fk", + "tableFrom": "application_source", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_source_application_id_application_id_fk": { + "name": "application_source_application_id_application_id_fk", + "tableFrom": "application_source", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "application_source_tracking_link_id_tracking_link_id_fk": { + "name": "application_source_tracking_link_id_tracking_link_id_fk", + "tableFrom": "application_source", + "tableTo": "tracking_link", + "columnsFrom": [ + "tracking_link_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.calendar_integration": { + "name": "calendar_integration", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "calendar_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'google'" + }, + "access_token_encrypted": { + "name": "access_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token_encrypted": { + "name": "refresh_token_encrypted", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "calendar_id": { + "name": "calendar_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'primary'" + }, + "account_email": { + "name": "account_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_channel_id": { + "name": "webhook_channel_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_resource_id": { + "name": "webhook_resource_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_expiration": { + "name": "webhook_expiration", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sync_token": { + "name": "sync_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "calendar_integration_user_provider_idx": { + "name": "calendar_integration_user_provider_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "calendar_integration_webhook_channel_idx": { + "name": "calendar_integration_webhook_channel_idx", + "columns": [ + { + "expression": "webhook_channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "calendar_integration_user_id_user_id_fk": { + "name": "calendar_integration_user_id_user_id_fk", + "tableFrom": "calendar_integration", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate": { + "name": "candidate", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "gender", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quick_notes": { + "name": "quick_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retention_exempt_until": { + "name": "retention_exempt_until", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "retention_exempt_reason": { + "name": "retention_exempt_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retention_reviewed_at": { + "name": "retention_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "quarantined_at": { + "name": "quarantined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scheduled_purge_at": { + "name": "scheduled_purge_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_organization_id_idx": { + "name": "candidate_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_gender_idx": { + "name": "candidate_gender_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "gender", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_org_email_idx": { + "name": "candidate_org_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_quarantine_idx": { + "name": "candidate_quarantine_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_purge_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_organization_id_organization_id_fk": { + "name": "candidate_organization_id_organization_id_fk", + "tableFrom": "candidate", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_conversation": { + "name": "candidate_conversation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_token": { + "name": "reply_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unread_count": { + "name": "unread_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_conversation_organization_id_idx": { + "name": "candidate_conversation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_application_id_idx": { + "name": "candidate_conversation_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_reply_token_idx": { + "name": "candidate_conversation_reply_token_idx", + "columns": [ + { + "expression": "reply_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_conversation_last_message_at_idx": { + "name": "candidate_conversation_last_message_at_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_conversation_organization_id_organization_id_fk": { + "name": "candidate_conversation_organization_id_organization_id_fk", + "tableFrom": "candidate_conversation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_conversation_application_id_application_id_fk": { + "name": "candidate_conversation_application_id_application_id_fk", + "tableFrom": "candidate_conversation", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message": { + "name": "candidate_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "candidate_message_direction", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "candidate_message_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'message'" + }, + "interview_id": { + "name": "interview_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calendar_attachment_status": { + "name": "calendar_attachment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_applicable'" + }, + "calendar_attachment_error": { + "name": "calendar_attachment_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calendar_sequence": { + "name": "calendar_sequence", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internet_message_id": { + "name": "internet_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "in_reply_to": { + "name": "in_reply_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "references": { + "name": "references", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sent_by_id": { + "name": "sent_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_status_at": { + "name": "provider_status_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_organization_id_idx": { + "name": "candidate_message_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_conversation_id_idx": { + "name": "candidate_message_conversation_id_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_interview_id_idx": { + "name": "candidate_message_interview_id_idx", + "columns": [ + { + "expression": "interview_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_provider_id_idx": { + "name": "candidate_message_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_internet_id_idx": { + "name": "candidate_message_internet_id_idx", + "columns": [ + { + "expression": "internet_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_message_organization_id_organization_id_fk": { + "name": "candidate_message_organization_id_organization_id_fk", + "tableFrom": "candidate_message", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_conversation_id_candidate_conversation_id_fk": { + "name": "candidate_message_conversation_id_candidate_conversation_id_fk", + "tableFrom": "candidate_message", + "tableTo": "candidate_conversation", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_interview_id_interview_id_fk": { + "name": "candidate_message_interview_id_interview_id_fk", + "tableFrom": "candidate_message", + "tableTo": "interview", + "columnsFrom": [ + "interview_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidate_message_sent_by_id_user_id_fk": { + "name": "candidate_message_sent_by_id_user_id_fk", + "tableFrom": "candidate_message", + "tableTo": "user", + "columnsFrom": [ + "sent_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message_attachment": { + "name": "candidate_message_attachment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "provider_attachment_id": { + "name": "provider_attachment_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_attachment_organization_id_idx": { + "name": "candidate_message_attachment_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_attachment_message_id_idx": { + "name": "candidate_message_attachment_message_id_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidate_message_attachment_organization_id_organization_id_fk": { + "name": "candidate_message_attachment_organization_id_organization_id_fk", + "tableFrom": "candidate_message_attachment", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidate_message_attachment_message_id_candidate_message_id_fk": { + "name": "candidate_message_attachment_message_id_candidate_message_id_fk", + "tableFrom": "candidate_message_attachment", + "tableTo": "candidate_message", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "candidate_message_attachment_storage_key_unique": { + "name": "candidate_message_attachment_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + }, + "candidate_message_attachment_provider_attachment_id_unique": { + "name": "candidate_message_attachment_provider_attachment_id_unique", + "nullsNotDistinct": false, + "columns": [ + "provider_attachment_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidate_message_webhook_event": { + "name": "candidate_message_webhook_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidate_message_webhook_provider_id_idx": { + "name": "candidate_message_webhook_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidate_message_webhook_unprocessed_idx": { + "name": "candidate_message_webhook_unprocessed_idx", + "columns": [ + { + "expression": "processed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.career_page": { + "name": "career_page", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "accent_color": { + "name": "accent_color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headline": { + "name": "headline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo_storage_key": { + "name": "logo_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_storage_key": { + "name": "banner_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banner_position": { + "name": "banner_position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "career_page_organization_id_idx": { + "name": "career_page_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "career_page_slug_idx": { + "name": "career_page_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "career_page_organization_id_organization_id_fk": { + "name": "career_page_organization_id_organization_id_fk", + "tableFrom": "career_page", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_agent": { + "name": "chatbot_agent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system_prompt": { + "name": "system_prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(3, 2)", + "primaryKey": false, + "notNull": false + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_agent_org_user_idx": { + "name": "chatbot_agent_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_agent_default_per_user_idx": { + "name": "chatbot_agent_default_per_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"chatbot_agent\".\"is_default\" = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_agent_organization_id_organization_id_fk": { + "name": "chatbot_agent_organization_id_organization_id_fk", + "tableFrom": "chatbot_agent", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_agent_user_id_user_id_fk": { + "name": "chatbot_agent_user_id_user_id_fk", + "tableFrom": "chatbot_agent", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_conversation": { + "name": "chatbot_conversation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ai_config_id": { + "name": "ai_config_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'New chat'" + }, + "scope": { + "name": "scope", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "thinking": { + "name": "thinking", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "last_message_preview": { + "name": "last_message_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_conversation_org_user_idx": { + "name": "chatbot_conversation_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_conversation_folder_idx": { + "name": "chatbot_conversation_folder_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "chatbot_conversation_last_message_at_idx": { + "name": "chatbot_conversation_last_message_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_conversation_organization_id_organization_id_fk": { + "name": "chatbot_conversation_organization_id_organization_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_conversation_user_id_user_id_fk": { + "name": "chatbot_conversation_user_id_user_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_conversation_folder_id_chatbot_folder_id_fk": { + "name": "chatbot_conversation_folder_id_chatbot_folder_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "chatbot_folder", + "columnsFrom": [ + "folder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chatbot_conversation_agent_id_chatbot_agent_id_fk": { + "name": "chatbot_conversation_agent_id_chatbot_agent_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "chatbot_agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chatbot_conversation_ai_config_id_ai_config_id_fk": { + "name": "chatbot_conversation_ai_config_id_ai_config_id_fk", + "tableFrom": "chatbot_conversation", + "tableTo": "ai_config", + "columnsFrom": [ + "ai_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_folder": { + "name": "chatbot_folder", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_folder_org_user_idx": { + "name": "chatbot_folder_org_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_folder_organization_id_organization_id_fk": { + "name": "chatbot_folder_organization_id_organization_id_fk", + "tableFrom": "chatbot_folder", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_folder_user_id_user_id_fk": { + "name": "chatbot_folder_user_id_user_id_fk", + "tableFrom": "chatbot_folder", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chatbot_message": { + "name": "chatbot_message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "chatbot_message_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tool_calls": { + "name": "tool_calls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "sources": { + "name": "sources", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "chatbot_message_conversation_idx": { + "name": "chatbot_message_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chatbot_message_conversation_id_chatbot_conversation_id_fk": { + "name": "chatbot_message_conversation_id_chatbot_conversation_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "chatbot_conversation", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_message_organization_id_organization_id_fk": { + "name": "chatbot_message_organization_id_organization_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chatbot_message_user_id_user_id_fk": { + "name": "chatbot_message_user_id_user_id_fk", + "tableFrom": "chatbot_message", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comment": { + "name": "comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "comment_target", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comment_organization_id_idx": { + "name": "comment_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "comment_target_idx": { + "name": "comment_target_idx", + "columns": [ + { + "expression": "target_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "comment_author_id_idx": { + "name": "comment_author_id_idx", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "comment_organization_id_organization_id_fk": { + "name": "comment_organization_id_organization_id_fk", + "tableFrom": "comment", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comment_author_id_user_id_fk": { + "name": "comment_author_id_user_id_fk", + "tableFrom": "comment", + "tableTo": "user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.criterion_score": { + "name": "criterion_score", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "criterion_key": { + "name": "criterion_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "max_score": { + "name": "max_score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "applicant_score": { + "name": "applicant_score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "confidence": { + "name": "confidence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "evidence": { + "name": "evidence", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "strengths": { + "name": "strengths", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "gaps": { + "name": "gaps", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "criterion_score_organization_id_idx": { + "name": "criterion_score_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "criterion_score_application_id_idx": { + "name": "criterion_score_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "criterion_score_app_criterion_idx": { + "name": "criterion_score_app_criterion_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "criterion_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "criterion_score_organization_id_organization_id_fk": { + "name": "criterion_score_organization_id_organization_id_fk", + "tableFrom": "criterion_score", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "criterion_score_application_id_application_id_fk": { + "name": "criterion_score_application_id_application_id_fk", + "tableFrom": "criterion_score", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.document": { + "name": "document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "document_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'resume'" + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "original_filename": { + "name": "original_filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parsed_content": { + "name": "parsed_content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "document_organization_id_idx": { + "name": "document_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "document_candidate_id_idx": { + "name": "document_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "document_organization_id_organization_id_fk": { + "name": "document_organization_id_organization_id_fk", + "tableFrom": "document", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "document_candidate_id_candidate_id_fk": { + "name": "document_candidate_id_candidate_id_fk", + "tableFrom": "document", + "tableTo": "candidate", + "columnsFrom": [ + "candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "document_storage_key_unique": { + "name": "document_storage_key_unique", + "nullsNotDistinct": false, + "columns": [ + "storage_key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_suppression": { + "name": "email_suppression", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "email_suppression_reason", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_suppression_email_idx": { + "name": "email_suppression_email_idx", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_template": { + "name": "email_template", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_template_organization_id_idx": { + "name": "email_template_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "email_template_created_by_id_idx": { + "name": "email_template_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_template_organization_id_organization_id_fk": { + "name": "email_template_organization_id_organization_id_fk", + "tableFrom": "email_template", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_template_created_by_id_user_id_fk": { + "name": "email_template_created_by_id_user_id_fk", + "tableFrom": "email_template", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_job": { + "name": "import_job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "import_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'processing'" + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "columns": { + "name": "columns", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "target_job_id": { + "name": "target_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_rows": { + "name": "total_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "committed_rows": { + "name": "committed_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "import_job_organization_id_idx": { + "name": "import_job_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_job_status_idx": { + "name": "import_job_status_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_job_organization_id_organization_id_fk": { + "name": "import_job_organization_id_organization_id_fk", + "tableFrom": "import_job", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_job_created_by_user_id_fk": { + "name": "import_job_created_by_user_id_fk", + "tableFrom": "import_job", + "tableTo": "user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_job_target_job_id_job_id_fk": { + "name": "import_job_target_job_id_job_id_fk", + "tableFrom": "import_job", + "tableTo": "job", + "columnsFrom": [ + "target_job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.import_row": { + "name": "import_row", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_index": { + "name": "row_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "raw_data": { + "name": "raw_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "normalized_data": { + "name": "normalized_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "import_row_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'ready'" + }, + "dedupe_hash": { + "name": "dedupe_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "matched_candidate_id": { + "name": "matched_candidate_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_candidate_id": { + "name": "created_candidate_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "import_row_job_id_idx": { + "name": "import_row_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_row_job_status_idx": { + "name": "import_row_job_status_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "import_row_dedupe_idx": { + "name": "import_row_dedupe_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "import_row_organization_id_organization_id_fk": { + "name": "import_row_organization_id_organization_id_fk", + "tableFrom": "import_row", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_job_id_import_job_id_fk": { + "name": "import_row_job_id_import_job_id_fk", + "tableFrom": "import_row", + "tableTo": "import_job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "import_row_matched_candidate_id_candidate_id_fk": { + "name": "import_row_matched_candidate_id_candidate_id_fk", + "tableFrom": "import_row", + "tableTo": "candidate", + "columnsFrom": [ + "matched_candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "import_row_created_candidate_id_candidate_id_fk": { + "name": "import_row_created_candidate_id_candidate_id_fk", + "tableFrom": "import_row", + "tableTo": "candidate", + "columnsFrom": [ + "created_candidate_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.interview": { + "name": "interview", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "interview_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'video'" + }, + "status": { + "name": "status", + "type": "interview_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "personal_note": { + "name": "personal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interviewers": { + "name": "interviewers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invitation_sent_at": { + "name": "invitation_sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "candidate_response": { + "name": "candidate_response", + "type": "candidate_response", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "candidate_responded_at": { + "name": "candidate_responded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "google_calendar_event_id": { + "name": "google_calendar_event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_calendar_event_link": { + "name": "google_calendar_event_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'UTC'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "interview_organization_id_idx": { + "name": "interview_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_application_id_idx": { + "name": "interview_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_scheduled_at_idx": { + "name": "interview_scheduled_at_idx", + "columns": [ + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_status_idx": { + "name": "interview_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "interview_created_by_id_idx": { + "name": "interview_created_by_id_idx", + "columns": [ + { + "expression": "created_by_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "interview_organization_id_organization_id_fk": { + "name": "interview_organization_id_organization_id_fk", + "tableFrom": "interview", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "interview_application_id_application_id_fk": { + "name": "interview_application_id_application_id_fk", + "tableFrom": "interview", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "interview_created_by_id_user_id_fk": { + "name": "interview_created_by_id_user_id_fk", + "tableFrom": "interview", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invite_link": { + "name": "invite_link", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "max_uses": { + "name": "max_uses", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invite_link_organization_id_idx": { + "name": "invite_link_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invite_link_token_idx": { + "name": "invite_link_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invite_link_organization_id_organization_id_fk": { + "name": "invite_link_organization_id_organization_id_fk", + "tableFrom": "invite_link", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invite_link_created_by_id_user_id_fk": { + "name": "invite_link_created_by_id_user_id_fk", + "tableFrom": "invite_link", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invite_link_token_unique": { + "name": "invite_link_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job": { + "name": "job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "job_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'full_time'" + }, + "status": { + "name": "status", + "type": "job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "salary_min": { + "name": "salary_min", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "salary_max": { + "name": "salary_max", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "salary_currency": { + "name": "salary_currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salary_unit": { + "name": "salary_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "salary_negotiable": { + "name": "salary_negotiable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "remote_status": { + "name": "remote_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "valid_through": { + "name": "valid_through", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "experience_level": { + "name": "experience_level", + "type": "experience_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "phone_requirement": { + "name": "phone_requirement", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'optional'" + }, + "require_resume": { + "name": "require_resume", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "require_cover_letter": { + "name": "require_cover_letter", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_score_on_apply": { + "name": "auto_score_on_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "analysis_context": { + "name": "analysis_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"coverLetter\":true,\"screeningAnswers\":true,\"recruiterNotes\":false}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_organization_id_idx": { + "name": "job_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_organization_id_organization_id_fk": { + "name": "job_organization_id_organization_id_fk", + "tableFrom": "job", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "job_slug_unique": { + "name": "job_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job_question": { + "name": "job_question", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "question_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'short_text'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "options": { + "name": "options", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_question_organization_id_idx": { + "name": "job_question_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_question_job_id_idx": { + "name": "job_question_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_question_organization_id_organization_id_fk": { + "name": "job_question_organization_id_organization_id_fk", + "tableFrom": "job_question", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_question_job_id_job_id_fk": { + "name": "job_question_job_id_job_id_fk", + "tableFrom": "job_question", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.join_request": { + "name": "join_request", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "join_request_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "reviewed_by_id": { + "name": "reviewed_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "join_request_organization_id_idx": { + "name": "join_request_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "join_request_user_id_idx": { + "name": "join_request_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "join_request_status_idx": { + "name": "join_request_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "join_request_user_id_user_id_fk": { + "name": "join_request_user_id_user_id_fk", + "tableFrom": "join_request", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "join_request_organization_id_organization_id_fk": { + "name": "join_request_organization_id_organization_id_fk", + "tableFrom": "join_request", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "join_request_reviewed_by_id_user_id_fk": { + "name": "join_request_reviewed_by_id_user_id_fk", + "tableFrom": "join_request", + "tableTo": "user", + "columnsFrom": [ + "reviewed_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_outbox": { + "name": "notification_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_email": { + "name": "recipient_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "cadence": { + "name": "cadence", + "type": "notification_cadence", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "notification_outbox_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "digest_bucket": { + "name": "digest_bucket", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_message_id": { + "name": "provider_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_outbox_dedupe_key_idx": { + "name": "notification_outbox_dedupe_key_idx", + "columns": [ + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_pull_idx": { + "name": "notification_outbox_pull_idx", + "columns": [ + { + "expression": "cadence", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"notification_outbox\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_provider_id_idx": { + "name": "notification_outbox_provider_id_idx", + "columns": [ + { + "expression": "provider_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"notification_outbox\".\"provider_message_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_organization_id_idx": { + "name": "notification_outbox_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_outbox_digest_idx": { + "name": "notification_outbox_digest_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "digest_bucket", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_outbox_organization_id_organization_id_fk": { + "name": "notification_outbox_organization_id_organization_id_fk", + "tableFrom": "notification_outbox", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_outbox_recipient_user_id_user_id_fk": { + "name": "notification_outbox_recipient_user_id_user_id_fk", + "tableFrom": "notification_outbox", + "tableTo": "user", + "columnsFrom": [ + "recipient_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_preference": { + "name": "notification_preference", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "channel_mode": { + "name": "channel_mode", + "type": "notification_channel_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_preference_user_org_type_idx": { + "name": "notification_preference_user_org_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_preference_organization_id_idx": { + "name": "notification_preference_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_preference_user_id_user_id_fk": { + "name": "notification_preference_user_id_user_id_fk", + "tableFrom": "notification_preference", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preference_organization_id_organization_id_fk": { + "name": "notification_preference_organization_id_organization_id_fk", + "tableFrom": "notification_preference", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.onboarding_survey_response": { + "name": "onboarding_survey_response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signup_plan": { + "name": "signup_plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signup_billing": { + "name": "signup_billing", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company_size": { + "name": "company_size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_role": { + "name": "user_role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discovery_source": { + "name": "discovery_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_hiring_process": { + "name": "current_hiring_process", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_roles_12m": { + "name": "expected_roles_12m", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_count": { + "name": "answered_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped_count": { + "name": "skipped_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_survey_response_user_id_idx": { + "name": "onboarding_survey_response_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_survey_response_organization_id_idx": { + "name": "onboarding_survey_response_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_survey_response_user_id_user_id_fk": { + "name": "onboarding_survey_response_user_id_user_id_fk", + "tableFrom": "onboarding_survey_response", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_survey_response_organization_id_organization_id_fk": { + "name": "onboarding_survey_response_organization_id_organization_id_fk", + "tableFrom": "onboarding_survey_response", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_settings": { + "name": "org_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name_display_format": { + "name": "name_display_format", + "type": "name_display_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'first_last'" + }, + "date_format": { + "name": "date_format", + "type": "date_format", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'mdy'" + }, + "retention_enabled": { + "name": "retention_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "retention_months": { + "name": "retention_months", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "quarantine_days": { + "name": "quarantine_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "retention_activated_at": { + "name": "retention_activated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "privacy_policy_url": { + "name": "privacy_policy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privacy_policy_text": { + "name": "privacy_policy_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "privacy_contact_email": { + "name": "privacy_contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_settings_organization_id_idx": { + "name": "org_settings_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "org_settings_organization_id_organization_id_fk": { + "name": "org_settings_organization_id_organization_id_fk", + "tableFrom": "org_settings", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_ai_config": { + "name": "platform_ai_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Platform (OpenRouter)'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openrouter'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai/gpt-5.4-mini'" + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4096 + }, + "input_price_per_1m": { + "name": "input_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "output_price_per_1m": { + "name": "output_price_per_1m", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_default_analysis": { + "name": "is_default_analysis", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_enabled": { + "name": "is_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "platform_ai_config_organization_id_idx": { + "name": "platform_ai_config_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "platform_ai_config_organization_id_organization_id_fk": { + "name": "platform_ai_config_organization_id_organization_id_fk", + "tableFrom": "platform_ai_config", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.property_definition": { + "name": "property_definition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "property_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "property_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "property_definition_org_idx": { + "name": "property_definition_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_definition_org_entity_idx": { + "name": "property_definition_org_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_definition_job_idx": { + "name": "property_definition_job_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "property_definition_organization_id_organization_id_fk": { + "name": "property_definition_organization_id_organization_id_fk", + "tableFrom": "property_definition", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "property_definition_job_id_job_id_fk": { + "name": "property_definition_job_id_job_id_fk", + "tableFrom": "property_definition", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.property_value": { + "name": "property_value", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "property_definition_id": { + "name": "property_definition_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "property_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "property_value_org_idx": { + "name": "property_value_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_entity_idx": { + "name": "property_value_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_definition_idx": { + "name": "property_value_definition_idx", + "columns": [ + { + "expression": "property_definition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "property_value_def_entity_idx": { + "name": "property_value_def_entity_idx", + "columns": [ + { + "expression": "property_definition_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "property_value_organization_id_organization_id_fk": { + "name": "property_value_organization_id_organization_id_fk", + "tableFrom": "property_value", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "property_value_property_definition_id_property_definition_id_fk": { + "name": "property_value_property_definition_id_property_definition_id_fk", + "tableFrom": "property_value", + "tableTo": "property_definition", + "columnsFrom": [ + "property_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.question_response": { + "name": "question_response", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "application_id": { + "name": "application_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "question_id": { + "name": "question_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "question_response_organization_id_idx": { + "name": "question_response_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "question_response_application_id_idx": { + "name": "question_response_application_id_idx", + "columns": [ + { + "expression": "application_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "question_response_question_id_idx": { + "name": "question_response_question_id_idx", + "columns": [ + { + "expression": "question_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "question_response_organization_id_organization_id_fk": { + "name": "question_response_organization_id_organization_id_fk", + "tableFrom": "question_response", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "question_response_application_id_application_id_fk": { + "name": "question_response_application_id_application_id_fk", + "tableFrom": "question_response", + "tableTo": "application", + "columnsFrom": [ + "application_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "question_response_question_id_job_question_id_fk": { + "name": "question_response_question_id_job_question_id_fk", + "tableFrom": "question_response", + "tableTo": "job_question", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.retention_audit": { + "name": "retention_audit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "candidate_id": { + "name": "candidate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "retention_audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'success'" + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "retention_audit_organization_id_idx": { + "name": "retention_audit_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "retention_audit_candidate_id_idx": { + "name": "retention_audit_candidate_id_idx", + "columns": [ + { + "expression": "candidate_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "retention_audit_created_at_idx": { + "name": "retention_audit_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "retention_audit_organization_id_organization_id_fk": { + "name": "retention_audit_organization_id_organization_id_fk", + "tableFrom": "retention_audit", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scoring_criterion": { + "name": "scoring_criterion", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "criterion_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'custom'" + }, + "max_score": { + "name": "max_score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "weight": { + "name": "weight", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "display_order": { + "name": "display_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "scoring_criterion_organization_id_idx": { + "name": "scoring_criterion_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scoring_criterion_job_id_idx": { + "name": "scoring_criterion_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "scoring_criterion_job_key_idx": { + "name": "scoring_criterion_job_key_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "scoring_criterion_organization_id_organization_id_fk": { + "name": "scoring_criterion_organization_id_organization_id_fk", + "tableFrom": "scoring_criterion", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "scoring_criterion_job_id_job_id_fk": { + "name": "scoring_criterion_job_id_job_id_fk", + "tableFrom": "scoring_criterion", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tracking_link": { + "name": "tracking_link", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "source_channel", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'custom'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "utm_source": { + "name": "utm_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_medium": { + "name": "utm_medium", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_campaign": { + "name": "utm_campaign", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_term": { + "name": "utm_term", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "utm_content": { + "name": "utm_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "click_count": { + "name": "click_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "application_count": { + "name": "application_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tracking_link_organization_id_idx": { + "name": "tracking_link_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_job_id_idx": { + "name": "tracking_link_job_id_idx", + "columns": [ + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_code_idx": { + "name": "tracking_link_code_idx", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tracking_link_channel_idx": { + "name": "tracking_link_channel_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tracking_link_organization_id_organization_id_fk": { + "name": "tracking_link_organization_id_organization_id_fk", + "tableFrom": "tracking_link", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tracking_link_job_id_job_id_fk": { + "name": "tracking_link_job_id_job_id_fk", + "tableFrom": "tracking_link", + "tableTo": "job", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tracking_link_created_by_id_user_id_fk": { + "name": "tracking_link_created_by_id_user_id_fk", + "tableFrom": "tracking_link", + "tableTo": "user", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tracking_link_code_unique": { + "name": "tracking_link_code_unique", + "nullsNotDistinct": false, + "columns": [ + "code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sso_provider": { + "name": "sso_provider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "issuer": { + "name": "issuer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "oidc_config": { + "name": "oidc_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "saml_config": { + "name": "saml_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sso_provider_domain_idx": { + "name": "sso_provider_domain_idx", + "columns": [ + { + "expression": "domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_provider_id_idx": { + "name": "sso_provider_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_organization_id_idx": { + "name": "sso_provider_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sso_provider_user_id_user_id_fk": { + "name": "sso_provider_user_id_user_id_fk", + "tableFrom": "sso_provider", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sso_provider_organization_id_organization_id_fk": { + "name": "sso_provider_organization_id_organization_id_fk", + "tableFrom": "sso_provider", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.activity_action": { + "name": "activity_action", + "schema": "public", + "values": [ + "created", + "updated", + "deleted", + "status_changed", + "comment_added", + "member_invited", + "member_removed", + "member_role_changed", + "scored" + ] + }, + "public.analysis_billing_mode": { + "name": "analysis_billing_mode", + "schema": "public", + "values": [ + "platform", + "byok" + ] + }, + "public.analysis_run_status": { + "name": "analysis_run_status", + "schema": "public", + "values": [ + "completed", + "failed", + "partial" + ] + }, + "public.application_status": { + "name": "application_status", + "schema": "public", + "values": [ + "new", + "screening", + "interview", + "offer", + "hired", + "rejected" + ] + }, + "public.calendar_provider": { + "name": "calendar_provider", + "schema": "public", + "values": [ + "google" + ] + }, + "public.candidate_message_direction": { + "name": "candidate_message_direction", + "schema": "public", + "values": [ + "inbound", + "outbound" + ] + }, + "public.candidate_message_status": { + "name": "candidate_message_status", + "schema": "public", + "values": [ + "queued", + "sent", + "delivered", + "delayed", + "bounced", + "failed", + "complained" + ] + }, + "public.candidate_response": { + "name": "candidate_response", + "schema": "public", + "values": [ + "pending", + "accepted", + "declined", + "tentative" + ] + }, + "public.chatbot_message_role": { + "name": "chatbot_message_role", + "schema": "public", + "values": [ + "user", + "assistant" + ] + }, + "public.comment_target": { + "name": "comment_target", + "schema": "public", + "values": [ + "candidate", + "application", + "job" + ] + }, + "public.criterion_category": { + "name": "criterion_category", + "schema": "public", + "values": [ + "technical", + "experience", + "soft_skills", + "education", + "culture", + "custom" + ] + }, + "public.date_format": { + "name": "date_format", + "schema": "public", + "values": [ + "mdy", + "dmy", + "ymd" + ] + }, + "public.document_type": { + "name": "document_type", + "schema": "public", + "values": [ + "resume", + "cover_letter", + "other" + ] + }, + "public.email_suppression_reason": { + "name": "email_suppression_reason", + "schema": "public", + "values": [ + "bounce", + "complaint" + ] + }, + "public.experience_level": { + "name": "experience_level", + "schema": "public", + "values": [ + "junior", + "mid", + "senior", + "lead" + ] + }, + "public.gender": { + "name": "gender", + "schema": "public", + "values": [ + "male", + "female", + "other", + "prefer_not_to_say" + ] + }, + "public.import_job_status": { + "name": "import_job_status", + "schema": "public", + "values": [ + "processing", + "previewing", + "committing", + "completed", + "failed" + ] + }, + "public.import_row_status": { + "name": "import_row_status", + "schema": "public", + "values": [ + "ready", + "duplicate", + "duplicate_in_file", + "error", + "committed", + "skipped" + ] + }, + "public.import_source": { + "name": "import_source", + "schema": "public", + "values": [ + "csv", + "xlsx", + "resume_zip" + ] + }, + "public.interview_status": { + "name": "interview_status", + "schema": "public", + "values": [ + "scheduled", + "completed", + "cancelled", + "no_show" + ] + }, + "public.interview_type": { + "name": "interview_type", + "schema": "public", + "values": [ + "phone", + "video", + "in_person", + "panel", + "technical", + "take_home" + ] + }, + "public.job_status": { + "name": "job_status", + "schema": "public", + "values": [ + "draft", + "open", + "closed", + "archived" + ] + }, + "public.job_type": { + "name": "job_type", + "schema": "public", + "values": [ + "full_time", + "part_time", + "contract", + "internship" + ] + }, + "public.join_request_status": { + "name": "join_request_status", + "schema": "public", + "values": [ + "pending", + "approved", + "rejected" + ] + }, + "public.name_display_format": { + "name": "name_display_format", + "schema": "public", + "values": [ + "first_last", + "last_first" + ] + }, + "public.notification_cadence": { + "name": "notification_cadence", + "schema": "public", + "values": [ + "instant", + "digest" + ] + }, + "public.notification_channel_mode": { + "name": "notification_channel_mode", + "schema": "public", + "values": [ + "instant", + "digest", + "off" + ] + }, + "public.notification_outbox_status": { + "name": "notification_outbox_status", + "schema": "public", + "values": [ + "pending", + "sent", + "skipped", + "dead" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "candidate_replied", + "application_created", + "interview_response" + ] + }, + "public.property_entity_type": { + "name": "property_entity_type", + "schema": "public", + "values": [ + "candidate", + "application" + ] + }, + "public.property_type": { + "name": "property_type", + "schema": "public", + "values": [ + "text", + "long_text", + "number", + "select", + "multi_select", + "date", + "checkbox", + "url", + "email", + "person", + "file" + ] + }, + "public.question_type": { + "name": "question_type", + "schema": "public", + "values": [ + "short_text", + "long_text", + "single_select", + "multi_select", + "number", + "date", + "url", + "checkbox", + "file_upload" + ] + }, + "public.retention_audit_action": { + "name": "retention_audit_action", + "schema": "public", + "values": [ + "quarantined", + "restored", + "erased", + "exempted", + "unexempted", + "exported" + ] + }, + "public.rule_action": { + "name": "rule_action", + "schema": "public", + "values": [ + "rejected", + "screening", + "interview" + ] + }, + "public.rule_match_type": { + "name": "rule_match_type", + "schema": "public", + "values": [ + "all", + "any" + ] + }, + "public.source_channel": { + "name": "source_channel", + "schema": "public", + "values": [ + "linkedin", + "indeed", + "glassdoor", + "ziprecruiter", + "monster", + "handshake", + "angellist", + "wellfound", + "dice", + "stackoverflow", + "weworkremotely", + "remoteok", + "builtin", + "hired", + "lever", + "greenhouse_board", + "google_jobs", + "facebook", + "twitter", + "instagram", + "tiktok", + "reddit", + "referral", + "career_site", + "email", + "event", + "agency", + "direct", + "other", + "custom" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/server/database/migrations/meta/_journal.json b/server/database/migrations/meta/_journal.json index 9cc65ec4..d5526c24 100644 --- a/server/database/migrations/meta/_journal.json +++ b/server/database/migrations/meta/_journal.json @@ -358,6 +358,27 @@ "when": 1784538415712, "tag": "0050_numerous_red_wolf", "breakpoints": true + }, + { + "idx": 51, + "version": "7", + "when": 1784797852982, + "tag": "0051_marvelous_molly_hayes", + "breakpoints": true + }, + { + "idx": 52, + "version": "7", + "when": 1784799977810, + "tag": "0052_application_auto_rule", + "breakpoints": true + }, + { + "idx": 53, + "version": "7", + "when": 1784813234463, + "tag": "0053_glorious_jigsaw", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/database/schema/app.ts b/server/database/schema/app.ts index 2019c23f..12dc4ddf 100644 --- a/server/database/schema/app.ts +++ b/server/database/schema/app.ts @@ -176,6 +176,15 @@ export const application = pgTable('application', { score: integer('score'), notes: text('notes'), coverLetterText: text('cover_letter_text'), + /** + * Snapshot of the automation rule that auto-set this application's status on + * submit (see server/utils/rules/applyRules.ts) — rule id/name, the action, + * and the ids of the responses that triggered it. Null when the status was + * never touched by a rule. Purely informational: surfaced as a small badge on + * the status and on each triggering response so recruiters can tell an + * automated categorization from a manual one and see why it fired. + */ + autoRule: jsonb('auto_rule').$type(), createdAt: timestamp('created_at').notNull().defaultNow(), updatedAt: timestamp('updated_at').notNull().defaultNow(), }, (t) => ([ @@ -699,7 +708,10 @@ export const analysisBillingModeEnum = pgEnum('analysis_billing_mode', [ export const activityLog = pgTable('activity_log', { id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()), organizationId: text('organization_id').notNull().references(() => organization.id, { onDelete: 'cascade' }), - actorId: text('actor_id').notNull().references(() => user.id, { onDelete: 'cascade' }), + // Null actor = system-generated activity (e.g. an application-rule auto status + // change). Timeline endpoints left-join `user` and the UI renders these as + // "System", so automated actions still appear in the audit trail. + actorId: text('actor_id').references(() => user.id, { onDelete: 'cascade' }), action: activityActionEnum('action').notNull(), resourceType: text('resource_type').notNull(), resourceId: text('resource_id').notNull(), @@ -881,6 +893,39 @@ export const scoringCriterion = pgTable('scoring_criterion', { uniqueIndex('scoring_criterion_job_key_idx').on(t.jobId, t.key), ])) +/** + * Per-job automation rules that read a candidate's application-form answers and + * automatically set the application status on submit ("knockout questions"). + * + * `conditions` is a JSONB array of { questionId, operator, value }. The rule + * fires when its conditions satisfy `matchType` (all = AND, any = OR); the first + * enabled matching rule (by displayOrder) applies its `action`. See + * shared/application-rules.ts for the operator catalogue and the evaluator. + * + * Condition `questionId`s are NOT enforced by a foreign key (they live inside + * JSONB). Deleting a question leaves a dangling reference; the evaluator treats + * an unknown question as non-matching and the builder UI surfaces it for cleanup. + */ +export const ruleMatchTypeEnum = pgEnum('rule_match_type', ['all', 'any']) +export const ruleActionEnum = pgEnum('rule_action', ['rejected', 'screening', 'interview']) + +export const applicationRule = pgTable('application_rule', { + id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()), + organizationId: text('organization_id').notNull().references(() => organization.id, { onDelete: 'cascade' }), + jobId: text('job_id').notNull().references(() => job.id, { onDelete: 'cascade' }), + name: text('name').notNull(), + matchType: ruleMatchTypeEnum('match_type').notNull().default('all'), + action: ruleActionEnum('action').notNull().default('rejected'), + enabled: boolean('enabled').notNull().default(true), + conditions: jsonb('conditions').$type().notNull().default([]), + displayOrder: integer('display_order').notNull().default(0), + createdAt: timestamp('created_at').notNull().defaultNow(), + updatedAt: timestamp('updated_at').notNull().defaultNow(), +}, (t) => ([ + index('application_rule_organization_id_idx').on(t.organizationId), + index('application_rule_job_id_idx').on(t.jobId), +])) + /** * Individual criterion scores computed by AI for each application. * Stores the raw AI output including evidence and confidence. @@ -1173,6 +1218,11 @@ export const scoringCriterionRelations = relations(scoringCriterion, ({ one }) = job: one(job, { fields: [scoringCriterion.jobId], references: [job.id] }), })) +export const applicationRuleRelations = relations(applicationRule, ({ one }) => ({ + organization: one(organization, { fields: [applicationRule.organizationId], references: [organization.id] }), + job: one(job, { fields: [applicationRule.jobId], references: [job.id] }), +})) + export const criterionScoreRelations = relations(criterionScore, ({ one }) => ({ organization: one(organization, { fields: [criterionScore.organizationId], references: [organization.id] }), application: one(application, { fields: [criterionScore.applicationId], references: [application.id] }), diff --git a/server/utils/recordActivity.ts b/server/utils/recordActivity.ts index de38107b..5501e2c6 100644 --- a/server/utils/recordActivity.ts +++ b/server/utils/recordActivity.ts @@ -11,7 +11,8 @@ type ActivityAction = typeof activityLog.$inferInsert.action */ export async function recordActivity(params: { organizationId: string - actorId: string + /** Null for system-generated activity (e.g. application-rule auto changes). */ + actorId: string | null action: ActivityAction resourceType: string resourceId: string @@ -20,7 +21,7 @@ export async function recordActivity(params: { try { await db.insert(activityLog).values({ organizationId: params.organizationId, - actorId: params.actorId, + actorId: params.actorId ?? null, action: params.action, resourceType: params.resourceType, resourceId: params.resourceId, diff --git a/server/utils/rules/applyRules.ts b/server/utils/rules/applyRules.ts new file mode 100644 index 00000000..8b55b07c --- /dev/null +++ b/server/utils/rules/applyRules.ts @@ -0,0 +1,302 @@ +import { eq, and, asc, inArray } from 'drizzle-orm' +import { application, applicationRule, jobQuestion, questionResponse } from '../../database/schema' +import { + evaluateApplicationRules, + type EvaluatedRule, + type QuestionType, + type ResponseValue, + type RuleMatch, +} from '~~/shared/application-rules' +import { APPLICATION_STATUS_TRANSITIONS } from '~~/shared/status-transitions' + +/** + * Evaluate a job's automation rules against a single application's answers and, + * if a rule matches, update the application status accordingly. + * + * Only acts on applications currently in `new` — rules classify fresh + * applicants and must never override a status a recruiter has already advanced. + * The target action is additionally checked against the manual transition rules + * so automation can never reach a status a human couldn't from `new`. + * + * Returns the match that was applied, or null if nothing matched / no change. + * Never throws — callers treat rule evaluation as best-effort. + */ +export async function applyRulesToApplication( + applicationId: string, + organizationId: string, +): Promise { + try { + const app = await db.query.application.findFirst({ + where: and( + eq(application.id, applicationId), + eq(application.organizationId, organizationId), + ), + columns: { id: true, jobId: true, status: true }, + }) + + // Only classify applications still sitting in `new`. + if (!app || app.status !== 'new') return null + + const rules = await db + .select() + .from(applicationRule) + .where(and( + eq(applicationRule.jobId, app.jobId), + eq(applicationRule.organizationId, organizationId), + eq(applicationRule.enabled, true), + )) + .orderBy(asc(applicationRule.displayOrder)) + + if (rules.length === 0) return null + + // Question type lookup for the job (drives operator semantics). + const questions = await db + .select({ id: jobQuestion.id, type: jobQuestion.type }) + .from(jobQuestion) + .where(and( + eq(jobQuestion.jobId, app.jobId), + eq(jobQuestion.organizationId, organizationId), + )) + + const questionTypesById: Record = {} + for (const q of questions) questionTypesById[q.id] = q.type as QuestionType + + // Stored answers for this application (includes file_upload → documentId). + const responses = await db + .select({ questionId: questionResponse.questionId, value: questionResponse.value }) + .from(questionResponse) + .where(and( + eq(questionResponse.applicationId, applicationId), + eq(questionResponse.organizationId, organizationId), + )) + + const responsesByQuestionId: Record = {} + for (const r of responses) responsesByQuestionId[r.questionId] = r.value as ResponseValue + + const evaluated: EvaluatedRule[] = rules.map(r => ({ + id: r.id, + name: r.name, + matchType: r.matchType, + action: r.action, + enabled: r.enabled, + conditions: r.conditions, + })) + + const match = evaluateApplicationRules(evaluated, responsesByQuestionId, questionTypesById) + if (!match) return null + + // Respect the manual transition graph — automation can't reach a status a + // recruiter couldn't reach from `new`. + const allowed = APPLICATION_STATUS_TRANSITIONS.new ?? [] + if (!allowed.includes(match.action)) return null + + const updated = await db.update(application) + .set({ status: match.action, autoRule: match, updatedAt: new Date() }) + .where(and( + eq(application.id, applicationId), + eq(application.organizationId, organizationId), + // Guard against a concurrent manual change between read and write. + eq(application.status, 'new'), + )) + .returning({ id: application.id }) + + // The guard matched no rows — a recruiter changed status between our read and + // write. Nothing was applied, so report no match (avoids over-counting and + // skipping auto-scoring for a rejection that never happened). + if (updated.length === 0) return null + + logInfo('application.auto_categorized', { + application_id: applicationId, + job_id: app.jobId, + rule_id: match.ruleId, + rule_name: match.ruleName, + action: match.action, + }) + + // Mirror the manual status-change audit trail (applications/[id].patch.ts) + // with a null (system) actor so auto changes appear in the timeline. + recordActivity({ + organizationId, + actorId: null, + action: 'status_changed', + resourceType: 'application', + resourceId: applicationId, + metadata: { from: 'new', to: match.action, ruleId: match.ruleId, ruleName: match.ruleName }, + }) + + return match + } catch (err) { + logError('application.auto_categorize_failed', { + application_id: applicationId, + error_message: err instanceof Error ? err.message : String(err), + }) + return null + } +} + +export interface ApplyRulesBatchResult { + evaluated: number + matched: number + byAction: Record +} + +// Cap how many `new` applications a single retroactive run touches. Keeps the +// request bounded on the high-volume ICP; callers can re-invoke to drain the +// rest since only `new` applications are ever re-selected. +const RUN_BATCH_LIMIT = 2000 +// Bound concurrent status writes so a large batch doesn't exhaust the DB pool. +const WRITE_CONCURRENCY = 20 + +/** + * Retroactively evaluate a job's rule set against every application still in + * `new`, in a single batch. Unlike calling {@link applyRulesToApplication} per + * application, the rules and question-type lookups are fetched once and every + * application's responses are loaded in one grouped query — turning a 4×N query + * N+1 into a constant number of reads. Writes are per matched application (to + * preserve per-application `autoRule` attribution) but run with bounded + * concurrency and only for applications that actually matched. + * + * Processes at most {@link RUN_BATCH_LIMIT} applications per call; re-invoke to + * continue draining a very large backlog. + */ +export async function applyRulesToNewJobApplications( + jobId: string, + organizationId: string, +): Promise { + const empty: ApplyRulesBatchResult = { evaluated: 0, matched: 0, byAction: {} } + + // Rules — fetched once for the whole batch. + const rules = await db + .select() + .from(applicationRule) + .where(and( + eq(applicationRule.jobId, jobId), + eq(applicationRule.organizationId, organizationId), + eq(applicationRule.enabled, true), + )) + .orderBy(asc(applicationRule.displayOrder)) + + if (rules.length === 0) return empty + + const evaluated: EvaluatedRule[] = rules.map(r => ({ + id: r.id, + name: r.name, + matchType: r.matchType, + action: r.action, + enabled: r.enabled, + conditions: r.conditions, + })) + + // Question types — fetched once for the whole batch. + const questions = await db + .select({ id: jobQuestion.id, type: jobQuestion.type }) + .from(jobQuestion) + .where(and( + eq(jobQuestion.jobId, jobId), + eq(jobQuestion.organizationId, organizationId), + )) + + const questionTypesById: Record = {} + for (const q of questions) questionTypesById[q.id] = q.type as QuestionType + + // Applications still sitting in `new`, capped to keep the request bounded. + const newApps = await db + .select({ id: application.id }) + .from(application) + .where(and( + eq(application.jobId, jobId), + eq(application.organizationId, organizationId), + eq(application.status, 'new'), + )) + .limit(RUN_BATCH_LIMIT) + + if (newApps.length === 0) return empty + + const appIds = newApps.map(a => a.id) + + // All responses for the batch in one query, grouped by application in memory. + const responsesByApp = new Map>() + for (const id of appIds) responsesByApp.set(id, {}) + const allResponses = await db + .select({ + applicationId: questionResponse.applicationId, + questionId: questionResponse.questionId, + value: questionResponse.value, + }) + .from(questionResponse) + .where(and( + inArray(questionResponse.applicationId, appIds), + eq(questionResponse.organizationId, organizationId), + )) + for (const r of allResponses) { + responsesByApp.get(r.applicationId)![r.questionId] = r.value as ResponseValue + } + + const allowed = APPLICATION_STATUS_TRANSITIONS.new ?? [] + + // Evaluate everything in memory first; collect the ones that need a write. + const toWrite: Array<{ id: string, match: RuleMatch }> = [] + for (const app of newApps) { + const match = evaluateApplicationRules( + evaluated, + responsesByApp.get(app.id) ?? {}, + questionTypesById, + ) + if (!match) continue + // Automation can't reach a status a recruiter couldn't reach from `new`. + if (!allowed.includes(match.action)) continue + toWrite.push({ id: app.id, match }) + } + + const byAction: Record = {} + let matched = 0 + + // Per-application writes preserve `autoRule` attribution; bounded concurrency + // keeps a large batch from exhausting the connection pool. + for (let i = 0; i < toWrite.length; i += WRITE_CONCURRENCY) { + const chunk = toWrite.slice(i, i + WRITE_CONCURRENCY) + await Promise.all(chunk.map(async ({ id, match }) => { + try { + const updated = await db.update(application) + .set({ status: match.action, autoRule: match, updatedAt: new Date() }) + .where(and( + eq(application.id, id), + eq(application.organizationId, organizationId), + // Guard against a concurrent manual change between read and write. + eq(application.status, 'new'), + )) + .returning({ id: application.id }) + + // Guard matched no rows (concurrent manual change) — don't count or log it. + if (updated.length === 0) return + + matched++ + byAction[match.action] = (byAction[match.action] ?? 0) + 1 + logInfo('application.auto_categorized', { + application_id: id, + job_id: jobId, + rule_id: match.ruleId, + rule_name: match.ruleName, + action: match.action, + }) + + // Mirror the manual status-change audit trail with a null (system) actor. + recordActivity({ + organizationId, + actorId: null, + action: 'status_changed', + resourceType: 'application', + resourceId: id, + metadata: { from: 'new', to: match.action, ruleId: match.ruleId, ruleName: match.ruleName }, + }) + } catch (err) { + logError('application.auto_categorize_failed', { + application_id: id, + error_message: err instanceof Error ? err.message : String(err), + }) + } + })) + } + + return { evaluated: newApps.length, matched, byAction } +} diff --git a/server/utils/schemas/applicationRule.ts b/server/utils/schemas/applicationRule.ts new file mode 100644 index 00000000..0aa4a828 --- /dev/null +++ b/server/utils/schemas/applicationRule.ts @@ -0,0 +1,38 @@ +import { z } from 'zod' +import { ALL_OPERATORS, RULE_ACTIONS } from '~~/shared/application-rules' +import type { RuleOperator } from '~~/shared/application-rules' + +// ───────────────────────────────────────────── +// Application automation rule validation schemas +// ───────────────────────────────────────────── + +const conditionSchema = z.object({ + questionId: z.string().min(1, 'Pick a question'), + operator: z.enum(ALL_OPERATORS as [RuleOperator, ...RuleOperator[]]), + // Comparison value — string, number, or list of option labels. Omitted for + // presence operators (is_answered, is_provided, is_true, …). + value: z.union([ + z.string().max(1000), + z.number(), + z.array(z.string().max(500)).max(50), + z.null(), + ]).optional(), +}) + +const ruleSchema = z.object({ + name: z.string().trim().min(1, 'Name is required').max(200), + matchType: z.enum(['all', 'any']).default('all'), + action: z.enum(RULE_ACTIONS), + enabled: z.boolean().default(true), + conditions: z.array(conditionSchema).min(1, 'Add at least one condition').max(20), +}) + +/** Bulk replace the full rule set for a job (atomic save from the builder). */ +export const bulkRulesSchema = z.object({ + rules: z.array(ruleSchema).max(50), +}) + +/** Route param schema for job id */ +export const ruleJobIdParamSchema = z.object({ + id: z.string().min(1), +}) diff --git a/shared/application-rules.ts b/shared/application-rules.ts new file mode 100644 index 00000000..80423bd6 --- /dev/null +++ b/shared/application-rules.ts @@ -0,0 +1,302 @@ +/** + * ───────────────────────────────────────────── + * Application automation rules — single source of truth + * ───────────────────────────────────────────── + * + * Recruiters configure per-job rules that read a candidate's application-form + * answers and automatically set the application status on submit — the classic + * ATS "knockout question" pattern (auto-reject) generalized to any status. + * + * A rule is an ordered list of conditions combined with `matchType` (all = AND, + * any = OR) plus an `action` (the status to set). On a new application the rules + * are evaluated in `displayOrder`; the FIRST enabled rule that matches wins and + * its action is applied. Nothing matches → the application stays `new`. + * + * This module is imported by BOTH client and server so the operator catalogue, + * labels, and the pure evaluator never drift between the builder UI and the + * server that actually enforces the rules. + */ + +// ─── Question types (mirrors questionTypeEnum in the DB schema) ───── +export type QuestionType = + | 'short_text' | 'long_text' | 'single_select' | 'multi_select' + | 'number' | 'date' | 'url' | 'checkbox' | 'file_upload' + +/** A stored answer value, shaped by the question type. */ +export type ResponseValue = string | string[] | number | boolean | null | undefined + +// ─── Operators ───────────────────────────────────────────────────── +export type RuleOperator = + // presence (any type) + | 'is_answered' | 'is_unanswered' + // text / url + | 'equals' | 'not_equals' | 'contains' | 'not_contains' + // single_select + | 'is_one_of' | 'is_not_one_of' + // multi_select + | 'includes_any' | 'includes_all' | 'includes_none' + // number + | 'gt' | 'gte' | 'lt' | 'lte' + // date + | 'date_before' | 'date_after' | 'date_on' + // checkbox + | 'is_true' | 'is_false' + // file_upload + | 'is_provided' | 'is_missing' + +/** How the value input for an operator should be rendered in the builder. */ +export type ValueInput = 'none' | 'text' | 'number' | 'date' | 'select' | 'multiselect' + +export interface OperatorMeta { + label: string + valueInput: ValueInput +} + +export const OPERATOR_META: Record = { + is_answered: { label: 'is answered', valueInput: 'none' }, + is_unanswered: { label: 'is not answered', valueInput: 'none' }, + equals: { label: 'is exactly', valueInput: 'text' }, + not_equals: { label: 'is not', valueInput: 'text' }, + contains: { label: 'contains', valueInput: 'text' }, + not_contains: { label: 'does not contain', valueInput: 'text' }, + is_one_of: { label: 'is one of', valueInput: 'multiselect' }, + is_not_one_of: { label: 'is not one of', valueInput: 'multiselect' }, + includes_any: { label: 'includes any of', valueInput: 'multiselect' }, + includes_all: { label: 'includes all of', valueInput: 'multiselect' }, + includes_none: { label: 'includes none of', valueInput: 'multiselect' }, + gt: { label: 'is greater than', valueInput: 'number' }, + gte: { label: 'is at least', valueInput: 'number' }, + lt: { label: 'is less than', valueInput: 'number' }, + lte: { label: 'is at most', valueInput: 'number' }, + date_before: { label: 'is before', valueInput: 'date' }, + date_after: { label: 'is after', valueInput: 'date' }, + date_on: { label: 'is on', valueInput: 'date' }, + is_true: { label: 'is checked', valueInput: 'none' }, + is_false: { label: 'is not checked', valueInput: 'none' }, + is_provided: { label: 'is provided', valueInput: 'none' }, + is_missing: { label: 'is not provided', valueInput: 'none' }, +} + +/** Which operators are offered for each question type, in menu order. */ +export const OPERATORS_BY_QUESTION_TYPE: Record = { + short_text: ['equals', 'not_equals', 'contains', 'not_contains', 'is_answered', 'is_unanswered'], + long_text: ['contains', 'not_contains', 'is_answered', 'is_unanswered'], + url: ['contains', 'not_contains', 'equals', 'is_answered', 'is_unanswered'], + single_select: ['is_one_of', 'is_not_one_of', 'is_answered', 'is_unanswered'], + multi_select: ['includes_any', 'includes_all', 'includes_none', 'is_answered', 'is_unanswered'], + number: ['gt', 'gte', 'lt', 'lte', 'is_answered', 'is_unanswered'], + date: ['date_before', 'date_after', 'date_on', 'is_answered', 'is_unanswered'], + checkbox: ['is_true', 'is_false'], + file_upload: ['is_provided', 'is_missing'], +} + +/** All valid operators — used for Zod validation. */ +export const ALL_OPERATORS = Object.keys(OPERATOR_META) as RuleOperator[] + +// ─── Actions ─────────────────────────────────────────────────────── +// Restricted to statuses reachable from `new` (see shared/status-transitions.ts) +// so an automated jump never violates the manual transition rules. +export const RULE_ACTIONS = ['rejected', 'screening', 'interview'] as const +export type RuleAction = typeof RULE_ACTIONS[number] + +export const RULE_ACTION_LABELS: Record = { + rejected: 'Reject', + screening: 'Move to Screening', + interview: 'Move to Interview', +} + +export type RuleMatchType = 'all' | 'any' + +// ─── Rule shapes ─────────────────────────────────────────────────── +export interface RuleCondition { + questionId: string + operator: RuleOperator + /** Comparison value — omitted for presence operators (valueInput === 'none'). */ + value?: string | string[] | number | null +} + +export interface ApplicationRuleInput { + name: string + matchType: RuleMatchType + action: RuleAction + enabled: boolean + conditions: RuleCondition[] +} + +// ───────────────────────────────────────────── +// Pure evaluator — server-authoritative, also usable client-side. +// ───────────────────────────────────────────── + +function toArray(v: ResponseValue): string[] { + if (Array.isArray(v)) return v.map(String) + if (v === null || v === undefined || v === '') return [] + return [String(v)] +} + +function isEmpty(v: ResponseValue): boolean { + if (v === null || v === undefined) return true + if (typeof v === 'string') return v.trim() === '' + if (Array.isArray(v)) return v.length === 0 + return false +} + +/** Case-insensitive equality for text comparisons. */ +function eqText(a: unknown, b: unknown): boolean { + return String(a).trim().toLowerCase() === String(b).trim().toLowerCase() +} + +/** + * Evaluate a single condition against a stored answer. + * + * `questionType` may be undefined when the referenced question has been deleted + * — in that case the condition is treated as NOT matched (never fires a rule on + * a dangling reference). + */ +export function evaluateCondition( + condition: RuleCondition, + response: ResponseValue, + questionType: QuestionType | undefined, +): boolean { + if (!questionType) return false + + const { operator, value } = condition + + switch (operator) { + case 'is_answered': + case 'is_provided': + return !isEmpty(response) + case 'is_unanswered': + case 'is_missing': + return isEmpty(response) + + case 'equals': + return !isEmpty(response) && eqText(response, value) + case 'not_equals': + // Unanswered counts as "not equal to X". + return isEmpty(response) || !eqText(response, value) + case 'contains': + return String(response ?? '').toLowerCase().includes(String(value ?? '').toLowerCase()) + case 'not_contains': + return !String(response ?? '').toLowerCase().includes(String(value ?? '').toLowerCase()) + + case 'is_one_of': { + const set = toArray(value as ResponseValue).map(s => s.toLowerCase()) + return set.includes(String(response ?? '').toLowerCase()) + } + case 'is_not_one_of': { + const set = toArray(value as ResponseValue).map(s => s.toLowerCase()) + return !set.includes(String(response ?? '').toLowerCase()) + } + + case 'includes_any': { + const picked = toArray(response).map(s => s.toLowerCase()) + const want = toArray(value as ResponseValue).map(s => s.toLowerCase()) + return want.some(w => picked.includes(w)) + } + case 'includes_all': { + const picked = toArray(response).map(s => s.toLowerCase()) + const want = toArray(value as ResponseValue).map(s => s.toLowerCase()) + return want.length > 0 && want.every(w => picked.includes(w)) + } + case 'includes_none': { + const picked = toArray(response).map(s => s.toLowerCase()) + const want = toArray(value as ResponseValue).map(s => s.toLowerCase()) + return !want.some(w => picked.includes(w)) + } + + case 'gt': + case 'gte': + case 'lt': + case 'lte': { + const n = typeof response === 'number' ? response : Number(response) + const target = typeof value === 'number' ? value : Number(value) + if (Number.isNaN(n) || Number.isNaN(target)) return false + if (operator === 'gt') return n > target + if (operator === 'gte') return n >= target + if (operator === 'lt') return n < target + return n <= target + } + + case 'date_before': + case 'date_after': + case 'date_on': { + const r = Date.parse(String(response ?? '')) + const t = Date.parse(String(value ?? '')) + if (Number.isNaN(r) || Number.isNaN(t)) return false + if (operator === 'date_before') return r < t + if (operator === 'date_after') return r > t + return r === t + } + + case 'is_true': + return response === true || response === 'true' + case 'is_false': + return !(response === true || response === 'true') + + default: + return false + } +} + +/** + * Evaluate one rule against a map of answers. + * `responsesByQuestionId` / `questionTypesById` are keyed by jobQuestion id. + */ +export function evaluateRule( + rule: Pick, + responsesByQuestionId: Record, + questionTypesById: Record, +): boolean { + if (rule.conditions.length === 0) return false + + const results = rule.conditions.map(c => + evaluateCondition(c, responsesByQuestionId[c.questionId], questionTypesById[c.questionId]), + ) + + return rule.matchType === 'any' ? results.some(Boolean) : results.every(Boolean) +} + +export interface EvaluatedRule extends Pick { + id: string + name: string +} + +export interface RuleMatch { + ruleId: string + ruleName: string + action: RuleAction + /** + * Question ids whose condition contributed to the match — for `all` every + * condition's question, for `any` only the questions that passed. Lets the UI + * attribute the automated status change to the exact responses that caused it. + */ + matchedQuestionIds: string[] +} + +/** + * Evaluate an ordered list of rules and return the first enabled match, or null. + * Rules must be pre-sorted by displayOrder. + */ +export function evaluateApplicationRules( + rules: EvaluatedRule[], + responsesByQuestionId: Record, + questionTypesById: Record, +): RuleMatch | null { + for (const rule of rules) { + if (!rule.enabled) continue + if (rule.conditions.length === 0) continue + + const results = rule.conditions.map(c => ({ + questionId: c.questionId, + ok: evaluateCondition(c, responsesByQuestionId[c.questionId], questionTypesById[c.questionId]), + })) + const matched = rule.matchType === 'any' ? results.some(r => r.ok) : results.every(r => r.ok) + if (!matched) continue + + // For "any", only the passing conditions triggered; for "all", they all did. + const contributing = rule.matchType === 'any' ? results.filter(r => r.ok) : results + const matchedQuestionIds = [...new Set(contributing.map(r => r.questionId))] + return { ruleId: rule.id, ruleName: rule.name, action: rule.action, matchedQuestionIds } + } + return null +} diff --git a/tests/unit/application-rules.test.ts b/tests/unit/application-rules.test.ts new file mode 100644 index 00000000..a4ec0c36 --- /dev/null +++ b/tests/unit/application-rules.test.ts @@ -0,0 +1,114 @@ +import { describe, it, expect } from 'vitest' +import { + evaluateCondition, + evaluateRule, + evaluateApplicationRules, + type EvaluatedRule, + type QuestionType, +} from '~~/shared/application-rules' + +describe('evaluateCondition', () => { + it('handles presence operators', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'is_answered' }, 'hi', 'short_text')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'is_answered' }, '', 'short_text')).toBe(false) + expect(evaluateCondition({ questionId: 'q', operator: 'is_unanswered' }, undefined, 'short_text')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'is_unanswered' }, ' ', 'short_text')).toBe(true) + }) + + it('text equals/contains are case-insensitive and trimmed', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'equals', value: 'Yes' }, ' yes ', 'short_text')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'not_equals', value: 'Yes' }, 'no', 'short_text')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'contains', value: 'react' }, 'I love React', 'long_text')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'not_contains', value: 'react' }, 'Vue only', 'long_text')).toBe(true) + }) + + it('not_equals treats an unanswered field as not equal', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'not_equals', value: 'Yes' }, undefined, 'short_text')).toBe(true) + }) + + it('single-select membership', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'is_one_of', value: ['A', 'B'] }, 'a', 'single_select')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'is_not_one_of', value: ['A', 'B'] }, 'C', 'single_select')).toBe(true) + }) + + it('multi-select set operators', () => { + const val = ['React', 'Node'] + expect(evaluateCondition({ questionId: 'q', operator: 'includes_any', value: ['node', 'go'] }, val, 'multi_select')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'includes_all', value: ['react', 'node'] }, val, 'multi_select')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'includes_all', value: ['react', 'go'] }, val, 'multi_select')).toBe(false) + expect(evaluateCondition({ questionId: 'q', operator: 'includes_none', value: ['php'] }, val, 'multi_select')).toBe(true) + }) + + it('number comparisons', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'gte', value: 5 }, 5, 'number')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'lt', value: 3 }, 5, 'number')).toBe(false) + expect(evaluateCondition({ questionId: 'q', operator: 'gt', value: 2 }, '5', 'number')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'gt', value: 2 }, 'abc', 'number')).toBe(false) + }) + + it('date comparisons', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'date_before', value: '2026-01-01' }, '2025-06-01', 'date')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'date_after', value: '2026-01-01' }, '2025-06-01', 'date')).toBe(false) + }) + + it('checkbox and file operators', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'is_true' }, true, 'checkbox')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'is_false' }, false, 'checkbox')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'is_provided' }, 'doc-id', 'file_upload')).toBe(true) + expect(evaluateCondition({ questionId: 'q', operator: 'is_missing' }, undefined, 'file_upload')).toBe(true) + }) + + it('treats a deleted (unknown-type) question as non-matching', () => { + expect(evaluateCondition({ questionId: 'q', operator: 'is_answered' }, 'x', undefined)).toBe(false) + }) +}) + +describe('evaluateRule matchType', () => { + const types: Record = { q1: 'short_text', q2: 'number' } + + it('ALL requires every condition', () => { + const rule = { + matchType: 'all' as const, + conditions: [ + { questionId: 'q1', operator: 'equals' as const, value: 'yes' }, + { questionId: 'q2', operator: 'gte' as const, value: 3 }, + ], + } + expect(evaluateRule(rule, { q1: 'yes', q2: 5 }, types)).toBe(true) + expect(evaluateRule(rule, { q1: 'yes', q2: 1 }, types)).toBe(false) + }) + + it('ANY requires only one condition', () => { + const rule = { + matchType: 'any' as const, + conditions: [ + { questionId: 'q1', operator: 'equals' as const, value: 'yes' }, + { questionId: 'q2', operator: 'gte' as const, value: 3 }, + ], + } + expect(evaluateRule(rule, { q1: 'no', q2: 5 }, types)).toBe(true) + expect(evaluateRule(rule, { q1: 'no', q2: 1 }, types)).toBe(false) + }) + + it('an empty condition list never matches', () => { + expect(evaluateRule({ matchType: 'all', conditions: [] }, {}, types)).toBe(false) + }) +}) + +describe('evaluateApplicationRules ordering', () => { + const types: Record = { q1: 'single_select' } + const rules: EvaluatedRule[] = [ + { id: 'r1', name: 'Disabled reject', enabled: false, matchType: 'all', action: 'rejected', conditions: [{ questionId: 'q1', operator: 'is_one_of', value: ['No'] }] }, + { id: 'r2', name: 'Reject no', enabled: true, matchType: 'all', action: 'rejected', conditions: [{ questionId: 'q1', operator: 'is_one_of', value: ['No'] }] }, + { id: 'r3', name: 'Advance yes', enabled: true, matchType: 'all', action: 'interview', conditions: [{ questionId: 'q1', operator: 'is_one_of', value: ['Yes'] }] }, + ] + + it('returns the first enabled matching rule', () => { + expect(evaluateApplicationRules(rules, { q1: 'No' }, types)).toEqual({ ruleId: 'r2', ruleName: 'Reject no', action: 'rejected', matchedQuestionIds: ['q1'] }) + expect(evaluateApplicationRules(rules, { q1: 'Yes' }, types)).toEqual({ ruleId: 'r3', ruleName: 'Advance yes', action: 'interview', matchedQuestionIds: ['q1'] }) + }) + + it('skips disabled rules and returns null when nothing matches', () => { + expect(evaluateApplicationRules(rules, { q1: 'Maybe' }, types)).toBeNull() + }) +})