Files
website/src/lib/server/db/schema/blog.ts
Stan Runge 64fb8df262 db: Drizzle schemas on domain Postgres schemas, baseline migration, reorg SQL
- pgSchema tables for auth, money, house, ref, games, cs, animaldex, site, meta
  (lists excluded via schemaFilter; runtime list tables are managed by meta.*)
- drizzle/ baseline matches the reorged DB exactly (catalog diff = 0 on rehearsal)
- db/reorg: one-time SQL that moves the flat public schema (rehearsed on a prod copy)
- scripts/db-migrate.ts: migrator with --init to record the baseline and a guard
  against running the baseline on a non-empty, unrecorded database
2026-10-23 22:03:42 +00:00

24 lines
812 B
TypeScript

import { text, unique } from 'drizzle-orm/pg-core';
import { siteSchema } from './schemas';
import { id, timestamps } from './helpers';
export const blogArticleStatus = siteSchema.enum('blog_article_status', ['draft', 'published']);
export const blogArticles = siteSchema.table(
'blog_articles',
{
id: id(),
title: text('title').notNull(),
slug: text('slug').notNull(),
content: text('content').notNull().default(''),
tags: text('tags').array().notNull().default([]),
status: blogArticleStatus('status').notNull().default('draft'),
...timestamps
},
(table) => [unique().on(table.slug)]
);
export type BlogArticle = typeof blogArticles.$inferSelect;
export type NewBlogArticle = typeof blogArticles.$inferInsert;
export type BlogArticleStatus = (typeof blogArticleStatus.enumValues)[number];