Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Member" ADD COLUMN "birth_date" TEXT;
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use a proper date type instead of TEXT.

The migration adds birth_date as TEXT, which matches the String type in the Prisma schema but is not ideal for storing dates. After updating the schema to use DateTime (as suggested in prisma/schema.prisma), regenerate this migration to use a proper date type.

The updated migration should use either DATE or TIMESTAMP:

- ALTER TABLE "Member" ADD COLUMN     "birth_date" TEXT;
+ ALTER TABLE "Member" ADD COLUMN     "birth_date" DATE;

Use DATE if you only need to store the date (YYYY-MM-DD) without time information, or TIMESTAMP if you need date and time.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-- AlterTable
ALTER TABLE "Member" ADD COLUMN "birth_date" TEXT;
-- AlterTable
ALTER TABLE "Member" ADD COLUMN "birth_date" DATE;
🤖 Prompt for AI Agents
In prisma/migrations/20251016191132_birth_date_added_to_member/migration.sql
lines 1–2, the new "birth_date" column is created as TEXT; update the migration
to use an appropriate date/time type (e.g., ALTER TABLE "Member" ADD COLUMN
"birth_date" DATE; or ADD COLUMN "birth_date" TIMESTAMP; depending on whether
you need time) that matches the Prisma schema DateTime, then regenerate or
replace the migration SQL so it uses DATE or TIMESTAMP for your database dialect
(Postgres/MySQL) and re-run prisma migrate so the schema and migration are
consistent.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:

- The `birth_date` column on the `Member` table would be dropped and recreated. This will lead to data loss if there is data in the column.

*/
-- AlterTable
ALTER TABLE "Member" DROP COLUMN "birth_date",
ADD COLUMN "birth_date" DATE;
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ model Member {
id String @id @default(uuid())
name String
email String @unique
birth_date DateTime? @db.Date
phone String? // Single phone number
bio String?
profilePhoto String? // URL to profile photo
Expand Down
28 changes: 28 additions & 0 deletions src/services/achievement.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@ import { prisma } from "../db/client";

export const getAchievements = async () => {
return await prisma.achievement.findMany({
include: {

members: {
select: {
member: {
select: {
id: true,
name: true,
email: true,
profilePhoto: true,
},
},
},
},

createdBy: {
select: {
id: true,
name: true,
},
},
updatedBy: {
select: {
id: true,
name: true,
},
},
},
orderBy: {
achievedAt: "desc",
},
Expand Down
Loading