8.6 주변 제휴업체: 위치 기반 목록/지도/필터(거리/카테고리) o

This commit is contained in:
koreacomp5
2025-10-09 17:38:46 +09:00
parent bd9d3d4b95
commit 9fb4b0c783
7 changed files with 142 additions and 2 deletions

View File

@@ -0,0 +1,49 @@
-- CreateTable
CREATE TABLE "coupons" (
"id" TEXT NOT NULL PRIMARY KEY,
"code" TEXT NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT,
"stock" INTEGER NOT NULL DEFAULT 0,
"maxPerUser" INTEGER NOT NULL DEFAULT 1,
"expiresAt" DATETIME,
"active" BOOLEAN NOT NULL DEFAULT true,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- CreateTable
CREATE TABLE "coupon_redemptions" (
"id" TEXT NOT NULL PRIMARY KEY,
"couponId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "coupon_redemptions_couponId_fkey" FOREIGN KEY ("couponId") REFERENCES "coupons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "coupon_redemptions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("userId") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "partners" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"category" TEXT NOT NULL,
"latitude" REAL NOT NULL,
"longitude" REAL NOT NULL,
"address" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "coupons_code_key" ON "coupons"("code");
-- CreateIndex
CREATE INDEX "coupons_active_expiresAt_idx" ON "coupons"("active", "expiresAt");
-- CreateIndex
CREATE INDEX "coupon_redemptions_userId_createdAt_idx" ON "coupon_redemptions"("userId", "createdAt");
-- CreateIndex
CREATE UNIQUE INDEX "coupon_redemptions_couponId_userId_key" ON "coupon_redemptions"("couponId", "userId");
-- CreateIndex
CREATE INDEX "partners_category_idx" ON "partners"("category");

View File

@@ -616,3 +616,18 @@ model CouponRedemption {
@@index([userId, createdAt])
@@map("coupon_redemptions")
}
// 제휴업체(위치 기반)
model Partner {
id String @id @default(cuid())
name String
category String
latitude Float
longitude Float
address String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([category])
@@map("partners")
}

View File

@@ -202,6 +202,16 @@ async function main() {
});
await seedPolicies();
// 제휴업체 예시 데이터
const partners = [
{ name: "힐링마사지", category: "spa", latitude: 37.5665, longitude: 126.9780, address: "서울 중구" },
{ name: "웰빙테라피", category: "spa", latitude: 37.5700, longitude: 126.9769, address: "서울 종로구" },
{ name: "굿짐", category: "gym", latitude: 37.5600, longitude: 126.9820, address: "서울 중구" },
];
for (const p of partners) {
await prisma.partner.upsert({ where: { name: p.name }, update: p, create: p });
}
}
main()