8.6 주변 제휴업체: 위치 기반 목록/지도/필터(거리/카테고리) o
This commit is contained in:
49
prisma/migrations/20251009083824_add_partner/migration.sql
Normal file
49
prisma/migrations/20251009083824_add_partner/migration.sql
Normal 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");
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user