Initial commit: Todo app with Jira-style board
This commit is contained in:
BIN
prisma/dev.db
Normal file
BIN
prisma/dev.db
Normal file
Binary file not shown.
90
prisma/schema.prisma
Normal file
90
prisma/schema.prisma
Normal file
@@ -0,0 +1,90 @@
|
||||
// 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 = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
directUrl = env("DIRECT_URL")
|
||||
}
|
||||
|
||||
// ==================== AUTH MODELS ====================
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
password String? // null if using OAuth
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
tasks Task[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String?
|
||||
access_token String?
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String?
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
@@map("verification_tokens")
|
||||
}
|
||||
|
||||
// ==================== TASK MODEL ====================
|
||||
|
||||
model Task {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
title String
|
||||
description String?
|
||||
status String @default("TODO") // TODO, IN_PROGRESS, DONE
|
||||
deadline DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@index([status])
|
||||
@@index([deadline])
|
||||
@@map("tasks")
|
||||
}
|
||||
75
prisma/seed.ts
Normal file
75
prisma/seed.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import bcrypt from 'bcryptjs'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function main() {
|
||||
// Create a demo user
|
||||
const hashedPassword = await bcrypt.hash('demo123456', 12)
|
||||
|
||||
const demoUser = await prisma.user.upsert({
|
||||
where: { email: 'demo@example.com' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'demo@example.com',
|
||||
name: 'Demo User',
|
||||
password: hashedPassword,
|
||||
},
|
||||
})
|
||||
|
||||
console.log('Created demo user:', demoUser.email)
|
||||
|
||||
// Create sample tasks
|
||||
const tasks = [
|
||||
{
|
||||
title: 'Hoàn thành báo cáo dự án',
|
||||
description: 'Viết báo cáo tổng kết dự án Q4',
|
||||
status: 'IN_PROGRESS',
|
||||
deadline: new Date(Date.now() + 2 * 24 * 60 * 60 * 1000), // 2 days from now
|
||||
},
|
||||
{
|
||||
title: 'Review code PR #123',
|
||||
description: 'Review pull request của team member',
|
||||
status: 'TODO',
|
||||
deadline: new Date(Date.now() + 1 * 24 * 60 * 60 * 1000), // tomorrow
|
||||
},
|
||||
{
|
||||
title: 'Họp team weekly',
|
||||
description: 'Cuộc họp hàng tuần với team',
|
||||
status: 'DONE',
|
||||
deadline: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000), // yesterday
|
||||
},
|
||||
{
|
||||
title: 'Cập nhật documentation',
|
||||
description: 'Cập nhật tài liệu API cho version mới',
|
||||
status: 'TODO',
|
||||
deadline: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // next week
|
||||
},
|
||||
{
|
||||
title: 'Fix bug login page',
|
||||
description: null,
|
||||
status: 'TODO',
|
||||
deadline: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000), // 2 days ago (overdue)
|
||||
},
|
||||
]
|
||||
|
||||
for (const task of tasks) {
|
||||
await prisma.task.create({
|
||||
data: {
|
||||
...task,
|
||||
userId: demoUser.id,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
console.log('Created sample tasks')
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
Reference in New Issue
Block a user