Skip to content
Merged
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
3 changes: 3 additions & 0 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"scripts": {
"generate": "prisma generate",
"push": "prisma db push --skip-generate",
"migrate": "prisma migrate dev --create-only",
"migrate:deploy": "prisma migrate deploy",
"migrate:reset": "prisma migrate reset",
"studio": "prisma studio"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE "funding_rates" (
"id" SERIAL NOT NULL,
"ticker" TEXT NOT NULL,
"fundingRate" TEXT NOT NULL,
"readingTime" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "funding_rates_ticker_idx" ON "funding_rates"("ticker");

-- CreateIndex
CREATE INDEX "funding_rates_createdAt_idx" ON "funding_rates"("createdAt");
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- CreateEnum
CREATE TYPE "Network" AS ENUM ('Testnet', 'Mainnet');

-- AlterTable
ALTER TABLE "funding_rates" ADD COLUMN "network" "Network" NOT NULL DEFAULT 'Mainnet';

-- CreateIndex
CREATE INDEX "funding_rates_network_idx" ON "funding_rates"("network");
3 changes: 3 additions & 0 deletions packages/database/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
8 changes: 8 additions & 0 deletions packages/database/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ datasource db {
url = env("DATABASE_URL")
}

enum Network {
Testnet
Mainnet
}

model FundingRates {
id Int @id @default(autoincrement())
network Network @default(Mainnet)

ticker String
fundingRate String
readingTime DateTime
createdAt DateTime @default(now())

@@index([ticker])
@@index([createdAt])
@@index([network])
@@map("funding_rates")
}