52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import {
|
|
pgTable,
|
|
uuid,
|
|
timestamp,
|
|
text,
|
|
boolean,
|
|
integer,
|
|
bigint,
|
|
} from "drizzle-orm/pg-core"
|
|
|
|
import { tenants } from "./tenants"
|
|
import { authUsers } from "./auth_users"
|
|
import { filetags } from "./filetags"
|
|
import { folderFunctionsEnum } from "./enums"
|
|
|
|
export const folders = pgTable("folders", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
|
|
tenant: bigint("tenant", { mode: "number" })
|
|
.notNull()
|
|
.references(() => tenants.id),
|
|
|
|
name: text("name").notNull(),
|
|
icon: text("icon"),
|
|
|
|
parent: uuid("parent").references(() => folders.id),
|
|
|
|
isSystemUsed: boolean("isSystemUsed").notNull().default(false),
|
|
|
|
function: folderFunctionsEnum("function"),
|
|
|
|
year: integer("year"),
|
|
|
|
standardFiletype: uuid("standardFiletype").references(() => filetags.id),
|
|
|
|
standardFiletypeIsOptional: boolean("standardFiletypeIsOptional")
|
|
.notNull()
|
|
.default(true),
|
|
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }),
|
|
updatedBy: uuid("updated_by").references(() => authUsers.id),
|
|
|
|
archived: boolean("archived").notNull().default(false),
|
|
})
|
|
|
|
export type Folder = typeof folders.$inferSelect
|
|
export type NewFolder = typeof folders.$inferInsert
|