Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
import { sql } from "drizzle-orm";
import { pgTable, text, uniqueIndex } from "drizzle-orm/pg-core";
import { projects } from "./app.schema";
// Timestamps are stored as *text* (same column shape as the SQLite schema); see
// the note in pg/app.schema.ts.
const isoNow = sql`to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`;
// Postgres mirror of the report_templates table. Column notes: see
// ../report-templates.schema.ts.
export const reportTemplates = pgTable(
"report_templates",
{
id: text("id").primaryKey(),
projectId: text("project_id")
.notNull()
.references(() => projects.id, { onDelete: "cascade" }),
name: text("name").notNull(),
description: text("description").notNull(),
instructions: text("instructions").notNull(),
createdBy: text("created_by").notNull(),
createdByUserId: text("created_by_user_id").notNull(),
createdAt: text("created_at").notNull().default(isoNow),
updatedAt: text("updated_at").notNull().default(isoNow),
},
(table) => [
uniqueIndex("report_templates_project_name_idx").on(
table.projectId,
table.name,
),
],
);