File tree Expand file tree Collapse file tree
migrations/20260926192617_add_item_price_table Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ -- CreateTable
2+ CREATE TABLE "ItemPrice " (
3+ " id" SERIAL NOT NULL ,
4+ " ndc" TEXT NOT NULL ,
5+ " unitPrice" MONEY NOT NULL ,
6+ " enteredById" INTEGER NOT NULL ,
7+ " createdAt" TIMESTAMP (3 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,
8+ " updatedAt" TIMESTAMP (3 ) NOT NULL ,
9+
10+ CONSTRAINT " ItemPrice_pkey" PRIMARY KEY (" id" )
11+ );
12+
13+ -- CreateIndex
14+ CREATE UNIQUE INDEX "ItemPrice_ndc_key " ON " ItemPrice" (" ndc" );
15+
16+ -- AddForeignKey
17+ ALTER TABLE " ItemPrice" ADD CONSTRAINT " ItemPrice_enteredById_fkey" FOREIGN KEY (" enteredById" ) REFERENCES " User" (" id" ) ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ model User {
138138 wishlists Wishlist []
139139 invite UserInvite ?
140140 notifications Notification []
141+ itemPrices ItemPrice []
141142
142143 streamUserId String ? @unique
143144 streamUserToken String ? @unique
@@ -243,6 +244,22 @@ model LineItem {
243244 allocation Allocation ? @relation
244245}
245246
247+ // Pricebook: one row per item code (NDC) holding the price entered by a staff
248+ // member, when it was entered, and who entered it. No price history is kept
249+ // (offers store their own copy of the price they used via LineItem.unitPrice).
250+ model ItemPrice {
251+ id Int @id @default (autoincrement () )
252+
253+ ndc String @unique // item code = the identity of the item
254+ unitPrice Decimal @db.Money
255+
256+ enteredById Int
257+ enteredBy User @relation (fields : [enteredById ] , references : [id ] )
258+
259+ createdAt DateTime @default (now () )
260+ updatedAt DateTime @updatedAt
261+ }
262+
246263model ItemEmbedding {
247264 id Int @id @default (autoincrement () )
248265 generalItemId Int ? @unique
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ async function run() {
5454 await tx . donorOffer . deleteMany ( ) ;
5555 await tx . distribution . deleteMany ( ) ;
5656 await tx . signOff . deleteMany ( ) ;
57+ await tx . itemPrice . deleteMany ( ) ;
5758 await tx . user . deleteMany ( ) ;
5859 await tx . userInvite . deleteMany ( ) ;
5960 await tx . generalItem . deleteMany ( ) ;
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ async function buildSeedData() {
133133 await db . userInvite . deleteMany ( ) ;
134134 await db . notification . deleteMany ( ) ;
135135 await db . passwordResetToken . deleteMany ( ) ;
136+ await db . itemPrice . deleteMany ( ) ;
136137 await db . user . deleteMany ( ) ;
137138 await db . tag . deleteMany ( ) ;
138139
You can’t perform that action at this time.
0 commit comments