feat: implement app directory routing, authentication flow, and dynamic reporting module
This commit is contained in:
+18
-4
@@ -11,9 +11,15 @@ datasource db {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id
|
||||
name String @unique
|
||||
id String @id @default(uuid())
|
||||
username String @unique
|
||||
name String
|
||||
password String
|
||||
photo String?
|
||||
role String @default("user")
|
||||
is_active Boolean @default(true)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
orders Order[] @relation("CreatedOrders")
|
||||
purchases Submission[]
|
||||
}
|
||||
@@ -28,13 +34,17 @@ model Order {
|
||||
creator User @relation("CreatedOrders", fields: [creator_id], references: [id])
|
||||
available_items AvailableItem[]
|
||||
submissions Submission[]
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
|
||||
model AvailableItem {
|
||||
id String @id @default(uuid())
|
||||
order_id String
|
||||
name String
|
||||
order Order @relation(fields: [order_id], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
order Order @relation(fields: [order_id], references: [id], onDelete: Cascade)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Submission {
|
||||
@@ -46,6 +56,8 @@ model Submission {
|
||||
order Order @relation(fields: [order_id], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
||||
items SubmissionItem[]
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
|
||||
model SubmissionItem {
|
||||
@@ -55,4 +67,6 @@ model SubmissionItem {
|
||||
qty Int @default(1)
|
||||
is_custom Boolean @default(false)
|
||||
submission Submission @relation(fields: [submission_id], references: [id], onDelete: Cascade)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import bcrypt from 'bcryptjs'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function main() {
|
||||
const superadminUsername = 'superadmin'
|
||||
const superadminPassword = 'titipin123!'
|
||||
|
||||
const hashedPassword = await bcrypt.hash(superadminPassword, 10)
|
||||
|
||||
const superadmin = await prisma.user.upsert({
|
||||
where: { username: superadminUsername },
|
||||
update: {},
|
||||
create: {
|
||||
username: superadminUsername,
|
||||
name: 'Super Admin',
|
||||
password: hashedPassword,
|
||||
role: 'superadmin',
|
||||
is_active: true,
|
||||
},
|
||||
})
|
||||
|
||||
console.log({ superadmin })
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e)
|
||||
await prisma.$disconnect()
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user