Skip to content

Commit

Permalink
Merge pull request #2 from usherlabs/feat/added_datasource
Browse files Browse the repository at this point in the history
Feat/added Database
  • Loading branch information
xlassix authored Aug 22, 2024
2 parents 89e2ab3 + c0362bc commit 0e46334
Show file tree
Hide file tree
Showing 7 changed files with 1,175 additions and 1,497 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ ROOCH_PRIVATE_KEY="" # for Rooch authentication
ROOCH_CHAIN_ID="testnet"
ROOCH_ORACLE_ADDRESS="0x0000000000000000000000000000000000000000"
ROOCH_INDEXER_CRON="*/5 * * * * *"
DATABASE_URL="file:./.db"

# Optionals
SENTRY_DSN=""
ECDSA_PRIVATE_KEY="" # for verity analysis.
ECDSA_PRIVATE_KEY="" # for verity analysis.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ cache
.cache

# Move
build
build
temp*
19 changes: 19 additions & 0 deletions orchestrator/prisma/migrations/20240822103300_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- CreateTable
CREATE TABLE "Events" (
"id" TEXT NOT NULL PRIMARY KEY,
"eventHandleId" TEXT NOT NULL,
"eventSeq" INTEGER NOT NULL,
"eventType" TEXT NOT NULL,
"eventData" TEXT NOT NULL,
"eventIndex" TEXT NOT NULL,
"decoded_event_data" TEXT NOT NULL,
"status" INTEGER NOT NULL,
"retries" INTEGER NOT NULL,
"response" TEXT NOT NULL,
"executedAt" DATETIME NOT NULL,
"indexedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updateAt" DATETIME NOT NULL
);

-- CreateIndex
CREATE INDEX "Events_eventHandleId_eventSeq_idx" ON "Events"("eventHandleId", "eventSeq");
3 changes: 3 additions & 0 deletions orchestrator/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 (i.e. Git)
provider = "sqlite"
30 changes: 30 additions & 0 deletions orchestrator/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}

model Events{
id String @id @default(cuid())
eventHandleId String
eventSeq Int
eventType String
eventData String
eventIndex String
decoded_event_data String //JSON String
status Int
retries Int
response String //JSON String
executedAt DateTime
indexedAt DateTime @default(now())
updateAt DateTime @updatedAt
@@index([eventHandleId, eventSeq])
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
"husky": "^9.1.5",
"jest": "^29.7.0",
"lint-staged": "^15.2.9",
"prisma": "5.18.0",
"ts-node": "^10.9.2",
"tsup": "^8.2.4",
"typescript": "^5.5.4"
},
"dependencies": {
"@prisma/client": "5.18.0",
"@roochnetwork/rooch-sdk": "^0.2.3",
"@sentry/node": "^8.26.0",
"@sentry/profiling-node": "^8.26.0",
Expand All @@ -50,6 +53,9 @@
"lint-staged": {
"*.{js,ts,cjs,mjs,d.cts,d.mts,json,jsonc}": ["biome check --apply --no-errors-on-unmatched"]
},
"prisma": {
"schema": "orchestrator/prisma/schema.prisma"
},
"tsup": {
"entry": ["./orchestrator/src"],
"splitting": false,
Expand Down
Loading

0 comments on commit 0e46334

Please sign in to comment.