Skip to content

Commit

Permalink
chore(prisma): purchase model
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Aug 17, 2024
1 parent 10f66b4 commit 04c8056
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
17 changes: 17 additions & 0 deletions prisma/migrations/20240815153355_purchase/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "purchases" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"points" INTEGER DEFAULT 0,
"receipt" TEXT NOT NULL,
"product_id" TEXT NOT NULL,
"device" TEXT,
"refunded" BOOLEAN DEFAULT false,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"user_id" UUID NOT NULL,

CONSTRAINT "purchases_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "purchases" ADD CONSTRAINT "purchases_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
18 changes: 18 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,28 @@ model User {
followers Follow[]
followings Follow[] @relation("Following")
pushTokens PushToken[]
purchases Purchase[]
@@map("users")
}

model Purchase {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
points Int? @default(0)
receipt String
productId String @map("product_id")
device String?
refunded Boolean? @default(false)
createdAt DateTime? @default(now()) @map("created_at")
updatedAt DateTime? @default(now()) @updatedAt @map("updated_at")
user User @relation(fields: [userId], references: [id])
userId String @map("user_id") @db.Uuid
@@map("purchases")
}

model PushToken {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
token String
Expand Down
51 changes: 50 additions & 1 deletion src/types/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,50 @@ export type Database = {
},
]
}
purchases: {
Row: {
created_at: string | null
device: string | null
id: string
points: number | null
product_id: string
receipt: string
refunded: boolean | null
updated_at: string | null
user_id: string
}
Insert: {
created_at?: string | null
device?: string | null
id?: string
points?: number | null
product_id: string
receipt: string
refunded?: boolean | null
updated_at?: string | null
user_id: string
}
Update: {
created_at?: string | null
device?: string | null
id?: string
points?: number | null
product_id?: string
receipt?: string
refunded?: boolean | null
updated_at?: string | null
user_id?: string
}
Relationships: [
{
foreignKeyName: "purchases_user_id_fkey"
columns: ["user_id"]
isOneToOne: false
referencedRelation: "users"
referencedColumns: ["id"]
},
]
}
push_tokens: {
Row: {
created_at: string | null
Expand Down Expand Up @@ -639,7 +683,12 @@ export type Database = {
[_ in never]: never
}
Functions: {
[_ in never]: never
increment_view_count: {
Args: {
post_id: string
}
Returns: undefined
}
}
Enums: {
activity_type:
Expand Down

0 comments on commit 04c8056

Please sign in to comment.