Files
sexy/packages/backend/src/db/schema/articles.ts
Sebastian Krüger efc7624ba3
All checks were successful
Build and Push Backend Image / build (push) Successful in 46s
Build and Push Frontend Image / build (push) Successful in 5m12s
style: apply prettier formatting to all files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:27:54 +01:00

33 lines
1.2 KiB
TypeScript

import { pgTable, text, timestamp, boolean, index, uniqueIndex } from "drizzle-orm/pg-core";
import { users } from "./users";
import { files } from "./files";
export const articles = pgTable(
"articles",
{
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
slug: text("slug").notNull(),
title: text("title").notNull(),
excerpt: text("excerpt"),
content: text("content"),
image: text("image").references(() => files.id, { onDelete: "set null" }),
tags: text("tags").array().default([]),
publish_date: timestamp("publish_date").notNull().defaultNow(),
author: text("author").references(() => users.id, { onDelete: "set null" }),
category: text("category"),
featured: boolean("featured").default(false),
date_created: timestamp("date_created").notNull().defaultNow(),
date_updated: timestamp("date_updated"),
},
(t) => [
uniqueIndex("articles_slug_idx").on(t.slug),
index("articles_publish_date_idx").on(t.publish_date),
index("articles_featured_idx").on(t.featured),
],
);
export type Article = typeof articles.$inferSelect;
export type NewArticle = typeof articles.$inferInsert;