Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions prisma/schema/alert.prisma
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
// prisma/schema/alert.prisma

model PriceAlert {
id String @id @default(cuid())
enum AlertDirection {
ABOVE
BELOW
}

enum AlertStatus {
PENDING
TRIGGERED
FAILED
}

model Alert {
id String @id @default(cuid())
creatorId String
walletAddress String
targetPrice Decimal
direction String // "above" | "below"
targetPrice Decimal @db.Decimal(38, 18)
direction AlertDirection
callbackUrl String
isActive Boolean @default(true)
status AlertStatus @default(PENDING)
retryCount Int @default(0)
lastError String?
triggeredAt DateTime?
createdAt DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

@@index([creatorId])
@@index([walletAddress])
@@index([status])
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- CreateEnum
CREATE TYPE "AlertDirection" AS ENUM ('ABOVE', 'BELOW');

-- CreateEnum
CREATE TYPE "AlertStatus" AS ENUM ('PENDING', 'TRIGGERED', 'FAILED');

-- CreateTable
CREATE TABLE "Alert" (
"id" TEXT NOT NULL,
"creatorId" TEXT NOT NULL,
"walletAddress" TEXT NOT NULL,
"targetPrice" DECIMAL(38,18) NOT NULL,
"direction" "AlertDirection" NOT NULL,
"callbackUrl" TEXT NOT NULL,
"status" "AlertStatus" NOT NULL DEFAULT 'PENDING',
"retryCount" INTEGER NOT NULL DEFAULT 0,
"lastError" TEXT,
"triggeredAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Alert_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "Alert_creatorId_idx" ON "Alert"("creatorId");

-- CreateIndex
CREATE INDEX "Alert_status_idx" ON "Alert"("status");
114 changes: 0 additions & 114 deletions src/modules/alerts/__tests__/alert-duplicate.integration.test.ts

This file was deleted.

This file was deleted.

Loading
Loading