Skip to content

Commit

Permalink
fixed creation of issuer profile bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMohit2003 committed Feb 21, 2024
1 parent ef706b4 commit 48861a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 7 additions & 1 deletion controllers/issueController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const createIssue = async (req, res) => {

const { name, contact, aadhar, OrganizationName, GST, IssuerType } =
req.body;
// Create the issuer with the provided details and connect it to the user by userId
const issuer = await prisma.issuer.create({
data: {
name,
Expand All @@ -25,7 +26,12 @@ const createIssue = async (req, res) => {
OrganizationName,
GST,
IssuerType,
userId,
user: {
// Correctly establish the relation to User
connect: {
id: userId, // Connect this issuer to the existing user by ID
},
},
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Issuer" ALTER COLUMN "contact" DROP NOT NULL,
ALTER COLUMN "aadhar" DROP NOT NULL,
ALTER COLUMN "GST" DROP NOT NULL,
ALTER COLUMN "OrganizationName" DROP NOT NULL;
10 changes: 5 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ model User {
model Issuer {
userId String @id
name String
contact Int
aadhar String
GST Int
OrganizationName String
contact Int?
aadhar String?
GST Int?
OrganizationName String?
IssuerType IssuerType
createdAt DateTime @default(now())
services Service[]
user User @relation(fields: [userId], references: [id])
user User? @relation(fields: [userId], references: [id])
}

model Vendor {
Expand Down

0 comments on commit 48861a9

Please sign in to comment.