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


export const materials = pgTable("materials", {
	id: uuid("id").primaryKey().defaultRandom().notNull(),
	name:varchar('name',{length:250}).notNull(),
	price: integer("price").notNull(),
	brand:varchar('brand',{length:255}),
},(t)=>({
	unique_material_project:unique().on(t.name)
}));

export const materialsRelations=relations(materials,({many})=>({
    
	projectMaterials:many(projectMaterials)

}))

export type MaterialsSelect = typeof materials.$inferSelect
export type MaterialsInsert = typeof materials.$inferInsert