fix: ensure when getting current pricing plan is not deleted

This commit is contained in:
bennykok 2024-01-31 16:02:01 +08:00
parent 576a6744a4
commit a4cd5db360

View File

@ -1,5 +1,5 @@
import { db } from "@/db/db";
import { and, desc, eq, isNull, or } from "drizzle-orm";
import { and, desc, eq, isNull, ne, or } from "drizzle-orm";
import { subscriptionStatusTable } from "@/db/schema";
import { APIKeyUserType } from "@/server/APIKeyBodyRequest";
import { auth } from "@clerk/nextjs";
@ -28,6 +28,7 @@ export async function getCurrentPlan({ user_id, org_id }: APIKeyUserType) {
isNull(subscriptionStatusTable.org_id),
eq(subscriptionStatusTable.org_id, ""),
),
ne(subscriptionStatusTable.status, "deleted"),
),
orderBy: desc(subscriptionStatusTable.created_at),
});