Skip to content

Commit

Permalink
🗃️ Make subscription fields required
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Feb 17, 2025
1 parent 7cf578b commit 58feda3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Warnings:
- You are about to drop the column `interval_count` on the `subscriptions` table. All the data in the column will be lost.
- Made the column `currency` on table `subscriptions` required. This step will fail if there are existing NULL values in that column.
- Made the column `interval` on table `subscriptions` required. This step will fail if there are existing NULL values in that column.
- Made the column `amount` on table `subscriptions` required. This step will fail if there are existing NULL values in that column.
- Made the column `status` on table `subscriptions` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "subscriptions" DROP COLUMN "interval_count",
ALTER COLUMN "currency" SET NOT NULL,
ALTER COLUMN "interval" SET NOT NULL,
ALTER COLUMN "amount" SET NOT NULL,
ALTER COLUMN "status" SET NOT NULL;
9 changes: 4 additions & 5 deletions packages/database/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ model UserPaymentData {
model Subscription {
id String @id
priceId String @map("price_id")
amount Int?
status String?
amount Int
status String
active Boolean
currency String?
interval String?
intervalCount Int? @map("interval_count")
currency String
interval String
createdAt DateTime @default(now()) @map("created_at")
periodStart DateTime @map("period_start")
periodEnd DateTime @map("period_end")
Expand Down
6 changes: 5 additions & 1 deletion packages/database/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ async function main() {
subscription: {
create: {
id: "sub_123",
currency:"usd",
amount: 700,
interval: "month",
status: "active",
active: true,
priceId: "price_123",
periodStart: new Date(),
periodEnd: dayjs().add(1, "year").toDate(),
periodEnd: dayjs().add(1, "month").toDate(),
},
},
},
Expand Down

0 comments on commit 58feda3

Please sign in to comment.