You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
993 B
32 lines
993 B
import { sql } from "drizzle-orm";
|
|
import { index, integer, pgTable, primaryKey, timestamp, varchar } from "drizzle-orm/pg-core";
|
|
import { users } from "./auth";
|
|
|
|
export const appConfigs = pgTable("app_configs", {
|
|
key: varchar().primaryKey(),
|
|
value: varchar().notNull(),
|
|
valueType: varchar("value_type").notNull(),
|
|
updatedAt: timestamp("updated_at")
|
|
.defaultNow()
|
|
.$onUpdate(() => sql`CURRENT_TIMESTAMP`)
|
|
.notNull(),
|
|
});
|
|
|
|
export const userConfigs = pgTable("user_configs", {
|
|
userId: integer("user_id")
|
|
.notNull()
|
|
.references(() => users.id, { onDelete: "cascade" }),
|
|
key: varchar().notNull(),
|
|
value: varchar().notNull(),
|
|
valueType: varchar("value_type").notNull(),
|
|
updatedAt: timestamp("updated_at")
|
|
.defaultNow()
|
|
.$onUpdate(() => sql`CURRENT_TIMESTAMP`)
|
|
.notNull(),
|
|
}, (table) => [
|
|
primaryKey({
|
|
name: "user_configs_user_id_key_pk",
|
|
columns: [table.userId, table.key],
|
|
}),
|
|
index("user_configs_user_id_idx").on(table.userId),
|
|
]);
|
|
|