create review and profile
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "TripReview" (
|
||||
"id" TEXT NOT NULL,
|
||||
"rating" INTEGER NOT NULL,
|
||||
"comment" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"tripId" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "TripReview_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "TripReview_tripId_userId_key" ON "TripReview"("tripId", "userId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TripReview" ADD CONSTRAINT "TripReview_tripId_fkey" FOREIGN KEY ("tripId") REFERENCES "Trip"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TripReview" ADD CONSTRAINT "TripReview_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "TripReview" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||
@@ -18,6 +18,7 @@ model User {
|
||||
|
||||
trips Trip[]
|
||||
participations TripParticipant[]
|
||||
tripReviews TripReview[]
|
||||
}
|
||||
|
||||
model Trip {
|
||||
@@ -39,6 +40,23 @@ model Trip {
|
||||
|
||||
participants TripParticipant[]
|
||||
images TripImage[]
|
||||
reviews TripReview[]
|
||||
}
|
||||
|
||||
model TripReview {
|
||||
id String @id @default(cuid())
|
||||
rating Int
|
||||
comment String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tripId String
|
||||
trip Trip @relation(fields: [tripId], references: [id], onDelete: Cascade)
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([tripId, userId])
|
||||
}
|
||||
|
||||
model TripImage {
|
||||
|
||||
+33
-16
@@ -12,6 +12,7 @@ async function main() {
|
||||
console.log("🌱 Seeding database...\n");
|
||||
|
||||
// Clean existing data (order matters for FK)
|
||||
await prisma.tripReview.deleteMany();
|
||||
await prisma.tripParticipant.deleteMany();
|
||||
await prisma.tripImage.deleteMany();
|
||||
await prisma.trip.deleteMany();
|
||||
@@ -93,11 +94,18 @@ async function main() {
|
||||
console.log(" Password semua: password123\n");
|
||||
|
||||
// ==================== TRIPS + IMAGES ====================
|
||||
/**
|
||||
* Tanggal disimpan eksplisit di UTC agar filter `from`/`to` (YYYY-MM-DD UTC)
|
||||
* cocok dengan yang tampil di daftar.
|
||||
*
|
||||
* - Multi hari: isi `endDate` = hari terakhir trip (UTC).
|
||||
* - Satu hari / night hike satu malam: `endDate` null — filter memakai instan `date`
|
||||
* dalam rentang hari UTC yang sama (jam tetap masuk hari itu).
|
||||
*/
|
||||
const utc = (y: number, m0: number, d: number, h = 12, min = 0) =>
|
||||
new Date(Date.UTC(y, m0, d, h, min, 0, 0));
|
||||
|
||||
const now = new Date();
|
||||
const day = 24 * 60 * 60 * 1000;
|
||||
|
||||
// --- Trip 1: Papandayan (by Dede Inoen) ---
|
||||
// --- Trip 1: Papandayan (by Dede Inoen) — 2 hari ---
|
||||
const trip1 = await prisma.trip.create({
|
||||
data: {
|
||||
title: "Open Trip Papandayan Weekend",
|
||||
@@ -112,7 +120,8 @@ Itinerary:
|
||||
- Minggu: Sunrise → Turun → Pulang`,
|
||||
mountain: "Gunung Papandayan",
|
||||
location: "Garut, Jawa Barat",
|
||||
date: new Date(now.getTime() + 3 * day),
|
||||
date: utc(2026, 3, 23, 8, 0),
|
||||
endDate: utc(2026, 3, 24, 18, 0),
|
||||
maxParticipants: 10,
|
||||
price: 250000,
|
||||
status: "OPEN",
|
||||
@@ -127,7 +136,7 @@ Itinerary:
|
||||
},
|
||||
});
|
||||
|
||||
// --- Trip 2: Ciremai (by Panji Petualang) ---
|
||||
// --- Trip 2: Ciremai (by Panji Petualang) — 2 hari ---
|
||||
const trip2 = await prisma.trip.create({
|
||||
data: {
|
||||
title: "Pendakian Ciremai via Apuy",
|
||||
@@ -142,7 +151,8 @@ Itinerary:
|
||||
- Hari 2: Summit attack → Turun → Pulang`,
|
||||
mountain: "Gunung Ciremai",
|
||||
location: "Kuningan, Jawa Barat",
|
||||
date: new Date(now.getTime() + 5 * day),
|
||||
date: utc(2026, 3, 25, 4, 0),
|
||||
endDate: utc(2026, 3, 26, 18, 0),
|
||||
maxParticipants: 8,
|
||||
price: 350000,
|
||||
status: "OPEN",
|
||||
@@ -157,7 +167,7 @@ Itinerary:
|
||||
},
|
||||
});
|
||||
|
||||
// --- Trip 3: Gede-Pangrango (by Fiersa Besari) ---
|
||||
// --- Trip 3: Gede-Pangrango (by Fiersa Besari) — 2 hari ---
|
||||
const trip3 = await prisma.trip.create({
|
||||
data: {
|
||||
title: "Sunrise Trip Gede-Pangrango",
|
||||
@@ -170,7 +180,8 @@ Itinerary:
|
||||
Start malam, summit saat sunrise. View epic dijamin!`,
|
||||
mountain: "Gunung Gede",
|
||||
location: "Bogor/Cianjur, Jawa Barat",
|
||||
date: new Date(now.getTime() + 6 * day),
|
||||
date: utc(2026, 3, 27, 22, 0),
|
||||
endDate: utc(2026, 3, 28, 16, 0),
|
||||
maxParticipants: 12,
|
||||
price: 280000,
|
||||
status: "OPEN",
|
||||
@@ -186,7 +197,7 @@ Start malam, summit saat sunrise. View epic dijamin!`,
|
||||
},
|
||||
});
|
||||
|
||||
// --- Trip 4: Tangkuban Parahu (by Dede Inoen) ---
|
||||
// --- Trip 4: Tangkuban Parahu (by Dede Inoen) — 1 hari ---
|
||||
const trip4 = await prisma.trip.create({
|
||||
data: {
|
||||
title: "Trip Hemat Tangkuban Parahu",
|
||||
@@ -199,7 +210,8 @@ Start malam, summit saat sunrise. View epic dijamin!`,
|
||||
Explore Kawah Ratu, Kawah Domas, foto-foto, terus makan sate maranggi!`,
|
||||
mountain: "Gunung Tangkuban Parahu",
|
||||
location: "Bandung, Jawa Barat",
|
||||
date: new Date(now.getTime() + 2 * day),
|
||||
date: utc(2026, 3, 22, 0, 0),
|
||||
endDate: null,
|
||||
maxParticipants: 15,
|
||||
price: 120000,
|
||||
status: "OPEN",
|
||||
@@ -213,7 +225,7 @@ Explore Kawah Ratu, Kawah Domas, foto-foto, terus makan sate maranggi!`,
|
||||
},
|
||||
});
|
||||
|
||||
// --- Trip 5: Malabar (by Fiersa Besari) ---
|
||||
// --- Trip 5: Malabar (by Fiersa Besari) — 1 hari (night hike, `endDate` null) ---
|
||||
const trip5 = await prisma.trip.create({
|
||||
data: {
|
||||
title: "Malabar Night Hike",
|
||||
@@ -226,7 +238,8 @@ Explore Kawah Ratu, Kawah Domas, foto-foto, terus makan sate maranggi!`,
|
||||
Trip ringan, 3-4 jam naik. Cocok buat yang mau healing malam-malam.`,
|
||||
mountain: "Gunung Malabar",
|
||||
location: "Bandung, Jawa Barat",
|
||||
date: new Date(now.getTime() + 4 * day),
|
||||
date: utc(2026, 3, 20, 14, 0),
|
||||
endDate: null,
|
||||
maxParticipants: 10,
|
||||
price: 150000,
|
||||
status: "OPEN",
|
||||
@@ -241,7 +254,7 @@ Trip ringan, 3-4 jam naik. Cocok buat yang mau healing malam-malam.`,
|
||||
},
|
||||
});
|
||||
|
||||
// --- Trip 6: Guntur (by Panji Petualang) ---
|
||||
// --- Trip 6: Guntur (by Panji Petualang) — 2 hari ---
|
||||
const trip6 = await prisma.trip.create({
|
||||
data: {
|
||||
title: "Guntur Challenge Trip",
|
||||
@@ -254,7 +267,8 @@ Trip ringan, 3-4 jam naik. Cocok buat yang mau healing malam-malam.`,
|
||||
Buat yang suka challenge. Pemandangan kawah aktif dari dekat!`,
|
||||
mountain: "Gunung Guntur",
|
||||
location: "Garut, Jawa Barat",
|
||||
date: new Date(now.getTime() + 10 * day),
|
||||
date: utc(2026, 3, 30, 4, 0),
|
||||
endDate: utc(2026, 4, 1, 18, 0),
|
||||
maxParticipants: 8,
|
||||
price: 300000,
|
||||
status: "OPEN",
|
||||
@@ -269,7 +283,10 @@ Buat yang suka challenge. Pemandangan kawah aktif dari dekat!`,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("✅ 6 Trips + images created\n");
|
||||
console.log("✅ 6 Trips + images created (tanggal UTC + endDate untuk trip multi hari)\n");
|
||||
console.log(
|
||||
` Guntur: ${trip6.title} ${trip6.date.toISOString().slice(0, 10)} → ${trip6.endDate?.toISOString().slice(0, 10) ?? "-"}\n`
|
||||
);
|
||||
|
||||
// ==================== PARTICIPANTS ====================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user