-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: modularize Prisma schema into directory-based components an… #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,3 +54,4 @@ scripts/set-azure-env-vars.sh | |
| NODEBASE_CONTEXT.md | ||
| tsc-errors.txt | ||
| *.tsc-errors.txt | ||
| github-node.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { defineConfig } from '@prisma/config' | ||
| import 'dotenv/config' | ||
|
|
||
| export default defineConfig({ | ||
| schema: "prisma/schema" | ||
| }) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // ───────────────────────────────────────────────────────────── | ||
| // Nodebase — Prisma Schema: Auth & Billing Models | ||
| // User, Session, Account, Verification, BillingEvent | ||
| // ───────────────────────────────────────────────────────────── | ||
|
|
||
| model User { | ||
| id String @id | ||
| name String | ||
| email String | ||
| emailVerified Boolean @default(false) | ||
| emailVerifyToken String? @unique | ||
| emailVerifyExpiry DateTime? | ||
| emailVerifyAttempts Int @default(0) | ||
| image String? | ||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @default(now()) @updatedAt | ||
| sessions Session[] | ||
| accounts Account[] | ||
| workflows workflow[] | ||
| credentials Credential[] | ||
| executionCount Int @default(0) | ||
|
|
||
| // ── Subscription / Billing ─────────────────────────────────────────────── | ||
| plan String @default("FREE") // FREE|STARTER|PRO|TEAM | ||
| planStatus String @default("active") // active|past_due|cancelled|paused | ||
| razorpayCustomerId String? @unique // cust_xxxx | ||
| razorpaySubId String? @unique // sub_xxxx | ||
| currentPeriodEnd DateTime? | ||
| cancelAtPeriodEnd Boolean @default(false) | ||
| workflowRunsUsed Int @default(0) | ||
| workflowRunsReset DateTime @default(now()) | ||
| billingEvents BillingEvent[] | ||
|
|
||
| @@unique([email]) | ||
| @@map("user") | ||
| } | ||
|
|
||
| model BillingEvent { | ||
| id String @id @default(cuid()) | ||
| userId String | ||
| type String // subscription.activated | payment.captured | subscription.cancelled | etc. | ||
| razorpayEventId String? @unique | ||
| amount Int? // paise | ||
| currency String @default("INR") | ||
| plan String? | ||
| status String // success | failed | pending | ||
| rawPayload String @db.Text // full Razorpay webhook JSON | ||
| createdAt DateTime @default(now()) | ||
|
|
||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
|
|
||
| @@index([userId]) | ||
| @@index([type]) | ||
| } | ||
|
|
||
| model Session { | ||
| id String @id | ||
| expiresAt DateTime | ||
| token String | ||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @updatedAt | ||
| ipAddress String? | ||
| userAgent String? | ||
| userId String | ||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
|
|
||
| @@unique([token]) | ||
| @@map("session") | ||
| } | ||
|
|
||
| model Account { | ||
| id String @id | ||
| accountId String | ||
| providerId String | ||
| userId String | ||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
| accessToken String? | ||
| refreshToken String? | ||
| idToken String? | ||
| accessTokenExpiresAt DateTime? | ||
| refreshTokenExpiresAt DateTime? | ||
| scope String? | ||
| password String? | ||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @updatedAt | ||
|
|
||
| @@map("account") | ||
| } | ||
|
|
||
| model Verification { | ||
| id String @id | ||
| identifier String | ||
| value String | ||
| expiresAt DateTime | ||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @default(now()) @updatedAt | ||
|
|
||
| @@map("verification") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // ───────────────────────────────────────────────────────────── | ||
| // Nodebase — Prisma Schema: Base Configuration | ||
| // Generator and datasource definitions | ||
| // ───────────────────────────────────────────────────────────── | ||
|
|
||
| generator client { | ||
| provider = "prisma-client-js" | ||
| output = "../../src/generated/prisma" | ||
| } | ||
|
|
||
| datasource db { | ||
| provider = "postgresql" | ||
| url = env("DATABASE_URL") | ||
| directUrl = env("DIRECT_DATABASE_URL") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| // ───────────────────────────────────────────────────────────── | ||
| // Nodebase — Prisma Schema: Core Models | ||
| // workflow, Node, Connection, Credential, Execution, NodeExecution | ||
| // ───────────────────────────────────────────────────────────── | ||
|
|
||
| model workflow { | ||
| id String @id @default(cuid()) | ||
| name String | ||
|
|
||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @default(now()) @updatedAt | ||
| nodes Node[] | ||
| connections Connection[] | ||
| executions Execution[] | ||
| webhookTrigger WebhookTrigger? | ||
| scheduleTrigger ScheduleTrigger? | ||
| ifElseNodes IfElseNode[] | ||
| gmailNodes GmailNode[] | ||
| setVariableNodes SetVariableNode[] | ||
| googleSheetsNodes GoogleSheetsNode[] | ||
| googleDriveNodes GoogleDriveNode[] | ||
| codeNodes CodeNode[] | ||
| whatsAppNodes WhatsAppNode[] | ||
| loopNodes LoopNode[] | ||
| notionNodes NotionNode[] | ||
| razorpayNodes RazorpayNode[] | ||
| slackNodes SlackNode[] | ||
| gmailWatchers GmailWatcher[] | ||
| switchNodes SwitchNode[] | ||
| waitNodes WaitNode[] | ||
| mergeNodes MergeNode[] | ||
| errorTriggerNodes ErrorTriggerNode[] | ||
| razorpayTriggers RazorpayTrigger[] | ||
| whatsappTriggers WhatsAppTrigger[] | ||
| msg91Nodes Msg91Node[] | ||
| shiprocketNodes ShiprocketNode[] | ||
| zohoCrmNodes ZohoCrmNode[] | ||
| hubspotNodes HubspotNode[] | ||
| freshdeskNodes FreshdeskNode[] | ||
| aiNodes AINode[] | ||
| mediaUploadNodes MediaUploadNode[] | ||
| sortNodes SortNode[] | ||
| filterNodes FilterNode[] | ||
| cashfreeNodes CashfreeNode[] | ||
| aggregateNodes AggregateNode[] | ||
| postgresNodes PostgresNode[] | ||
| userId String | ||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
| } | ||
|
|
||
| model Credential { | ||
| id String @id @default(cuid()) | ||
| name String | ||
| value String | ||
| userId String | ||
| type CredentialType | ||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
| Node Node[] | ||
| shiprocketNodes ShiprocketNode[] | ||
| zohoCrmNodes ZohoCrmNode[] | ||
| hubspotNodes HubspotNode[] | ||
| freshdeskNodes FreshdeskNode[] | ||
| cashfreeNodes CashfreeNode[] | ||
| postgresNodes PostgresNode[] | ||
|
|
||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @default(now()) @updatedAt | ||
| razorpayNodes RazorpayNode[] | ||
| gmailNodes GmailNode[] | ||
| googleSheetsNodes GoogleSheetsNode[] | ||
| googleDriveNodes GoogleDriveNode[] | ||
| slackNodes SlackNode[] | ||
| whatsAppNodes WhatsAppNode[] | ||
| notionNodes NotionNode[] | ||
| msg91Nodes Msg91Node[] | ||
| ainodes AINode[] | ||
| mediaUploadNodes MediaUploadNode[] | ||
|
|
||
| // TODO: @@map("Credenial") has a typo — should be "credential" | ||
| // Fixing requires: ALTER TABLE "Credenial" RENAME TO "credential"; | ||
| // plus updating all existing FK references. Do in a dedicated migration sprint. | ||
| @@map("credential") | ||
| } | ||
|
|
||
| model Node { | ||
| id String @id @default(cuid()) | ||
| name String | ||
| type NodeType | ||
| workflowId String | ||
| position Json | ||
| data Json @default("{}") | ||
| outputConnections Connection[] @relation("FromNode") | ||
| inputConnections Connection[] @relation("ToNode") | ||
| workflow workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade) | ||
| credentialId String? | ||
| credential Credential? @relation(fields: [credentialId], references: [id]) | ||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @default(now()) @updatedAt | ||
| } | ||
|
|
||
| model Connection { | ||
| id String @id @default(cuid()) | ||
| workflowId String | ||
| workflow workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade) | ||
| fromNodeId String | ||
| fromNode Node @relation("FromNode", fields: [fromNodeId], references: [id], onDelete: Cascade) | ||
| toNodeId String | ||
| toNode Node @relation("ToNode", fields: [toNodeId], references: [id], onDelete: Cascade) | ||
| fromOutput String @default("main") | ||
| toInput String @default("main") | ||
|
|
||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @default(now()) @updatedAt | ||
|
|
||
| @@unique([fromNodeId, toNodeId, fromOutput, toInput]) | ||
| } | ||
|
|
||
| model Execution { | ||
| id String @id @default(cuid()) | ||
| workflowId String | ||
| workflow workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade) | ||
| startedAt DateTime @default(now()) | ||
| completedAt DateTime? | ||
| inngestEventId String @unique | ||
| output Json? | ||
| error String? @db.Text | ||
| errorStack String? @db.Text | ||
| status ExecutionStatus @default(RUNNING) | ||
| nodeExecutions NodeExecution[] | ||
| } | ||
|
|
||
| model NodeExecution { | ||
| id String @id @default(cuid()) | ||
| executionId String | ||
| execution Execution @relation(fields: [executionId], references: [id], onDelete: Cascade) | ||
|
|
||
| nodeId String | ||
| nodeName String @default("") | ||
| nodeType String @default("") | ||
|
|
||
| status String @default("success") | ||
|
|
||
| inputJson String @default("") @db.Text | ||
| outputJson String @default("") @db.Text | ||
|
|
||
| errorMessage String @default("") | ||
|
|
||
| durationMs Int @default(0) | ||
|
|
||
| executionOrder Int @default(0) | ||
|
|
||
| createdAt DateTime @default(now()) | ||
|
|
||
| @@index([executionId]) | ||
| @@index([nodeId]) | ||
| @@index([executionId, executionOrder]) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.