/ opencodehub / src / db / schema / system-config.ts
swadhinbiswas Fix: Add date validation in analysis.ts to prevent RangeError · 1/20/2026
a7662cd
26 lines · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * System Configuration Schema - Drizzle ORM
 * Stores dynamic system settings like storage config, SMTP settings, etc.
 */

import { relations } from "drizzle-orm";
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { users } from "./users";

export const systemConfig = pgTable("system_config", {
    key: text("key").primaryKey(), // e.g., 'storage_config'
    value: text("value").notNull(), // JSON string
    updatedAt: timestamp("updated_at").notNull().defaultNow(),
    updatedById: text("updated_by_id").references(() => users.id),
});

export const systemConfigRelations = relations(systemConfig, ({ one }) => ({
    updatedBy: one(users, {
        fields: [systemConfig.updatedById],
        references: [users.id],
    }),
}));

export type SystemConfig = typeof systemConfig.$inferSelect;
export type NewSystemConfig = typeof systemConfig.$inferInsert;