task-managment / src / database / schema / tools.ts
tools.ts
Raw
import { relations } from 'drizzle-orm';
import {  pgTable,serial,char,pgEnum, primaryKey,integer,index,uniqueIndex,timestamp,unique, varchar, uuid } from 'drizzle-orm/pg-core';
import { task } from './task';
import { userTool } from './userTool';


export const tool = pgTable("tool", {
    id: uuid("id").primaryKey().notNull(),
	name: varchar("name", { length: 255 }).notNull(),
    quantity:integer('quantity').default(1).notNull(),
	createdAt: timestamp('createdAt',{mode:'date'}).notNull().defaultNow(),
	updatedAt: timestamp('updatedAt',{mode:'date'}).notNull().defaultNow(),
});


export const toolRelations=relations(tool,({one,many})=>({
	userTool:many(userTool),
}))

export type ToolSelect = typeof tool.$inferSelect