refactor(api): 🏷️ Begin porting all code over to new schemas

This commit is contained in:
Jesse Wierzbinski 2025-02-12 23:25:22 +01:00
parent fda1167234
commit bff1c5f734
No known key found for this signature in database
32 changed files with 171 additions and 264 deletions

View file

@ -15,6 +15,8 @@ import {
uuid,
} from "drizzle-orm/pg-core";
import type { Source } from "~/classes/schemas/account";
import type { Notification as NotificationSchema } from "~/classes/schemas/notification.ts";
import type { Status as StatusSchema } from "~/classes/schemas/status.ts";
// biome-ignore lint/nursery/useExplicitType: Type is too complex
const createdAt = () =>
@ -376,7 +378,9 @@ export const MediasRelations = relations(Medias, ({ many }) => ({
export const Notifications = pgTable("Notifications", {
id: id(),
type: text("type").notNull(),
type: text("type")
.$type<z.infer<typeof NotificationSchema.shape.type>>()
.notNull(),
createdAt: createdAt(),
notifiedId: uuid("notifiedId")
.notNull()
@ -431,7 +435,9 @@ export const Notes = pgTable("Notes", {
}),
content: text("content").default("").notNull(),
contentType: text("content_type").default("text/plain").notNull(),
visibility: text("visibility").notNull(),
visibility: text("visibility")
.$type<z.infer<typeof StatusSchema.shape.visibility>>()
.notNull(),
replyId: uuid("replyId").references((): AnyPgColumn => Notes.id, {
onDelete: "cascade",
onUpdate: "cascade",