Select Git revision
license.schema.ts
This project is licensed under the GNU Affero General Public License v3.0.
Learn more
license.schema.ts 1.20 KiB
import { text, varchar } from "drizzle-orm/pg-core";
import { serial } from "drizzle-orm/pg-core";
import { pgTable } from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from 'zod'
const licenseTable = pgTable('licenses', {
id: serial('id').primaryKey()
.unique()
.notNull(),
name: varchar('name', { length: 255 })
.notNull(),
description: text('description')
.notNull(),
url: varchar('url', { length: 255 })
.notNull(),
})
const licenseModelSchema = createSelectSchema(licenseTable)
const licenseDtoSchema = licenseModelSchema.omit({})
const licenseInputSchema = createInsertSchema(licenseTable)
const licenseUpdateSchema = licenseInputSchema
.partial()
.required({ id: true })
export type LicenseModel = z.infer<typeof licenseModelSchema>
export type LicenseDto = z.infer<typeof licenseDtoSchema>
export type LicenseInput = z.infer<typeof licenseInputSchema>
export type LicenseUpdate = z.infer<typeof licenseUpdateSchema>
export const licenseSchema = {
model: licenseModelSchema,
dto: licenseDtoSchema,
input: licenseInputSchema,
update: licenseUpdateSchema,
}
export default licenseTable