refactor: make block kind enum dynamic in schema (#762)

This commit is contained in:
Jeremy 2025-02-05 18:47:17 +03:00 committed by GitHub
parent 5e059844a2
commit dfc07ce0ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ import {
foreignKey, foreignKey,
boolean, boolean,
} from 'drizzle-orm/pg-core'; } from 'drizzle-orm/pg-core';
import { blockKinds } from '../blocks/server';
export const user = pgTable('User', { export const user = pgTable('User', {
id: uuid('id').primaryKey().notNull().defaultRandom(), id: uuid('id').primaryKey().notNull().defaultRandom(),
@ -72,9 +73,7 @@ export const document = pgTable(
createdAt: timestamp('createdAt').notNull(), createdAt: timestamp('createdAt').notNull(),
title: text('title').notNull(), title: text('title').notNull(),
content: text('content'), content: text('content'),
kind: varchar('text', { enum: ['text', 'code', 'image', 'sheet'] }) kind: varchar('text', { enum: blockKinds }).notNull().default('text'),
.notNull()
.default('text'),
userId: uuid('userId') userId: uuid('userId')
.notNull() .notNull()
.references(() => user.id), .references(() => user.id),