From d862322dc5bf2c1e456cff3289b3b947a27dc314 Mon Sep 17 00:00:00 2001 From: chronark Date: Thu, 10 Apr 2025 08:39:39 +0200 Subject: [PATCH] chore: remove old columns --- apps/api/src/pkg/testutil/harness.ts | 10 ---------- .../lib/trpc/routers/workspace/create.ts | 5 ----- internal/db/src/schema/workspaces.ts | 16 +++------------- tools/local/src/cmd/seed/apis.ts | 2 +- tools/local/src/cmd/seed/batch-operations.ts | 4 ++-- tools/local/src/cmd/seed/logs.ts | 2 +- 6 files changed, 7 insertions(+), 32 deletions(-) diff --git a/apps/api/src/pkg/testutil/harness.ts b/apps/api/src/pkg/testutil/harness.ts index a8899d0d4c..97b06c16e0 100644 --- a/apps/api/src/pkg/testutil/harness.ts +++ b/apps/api/src/pkg/testutil/harness.ts @@ -254,19 +254,14 @@ export abstract class Harness { id: newId("test"), name: "unkey", orgId: newId("test"), - __toBeDeleted: newId("test"), plan: "enterprise", tier: "Enterprise", features: {}, betaFeatures: {}, stripeCustomerId: null, stripeSubscriptionId: null, - trialEnds: null, subscriptions: null, - planLockedUntil: null, - planChanged: null, createdAtM: Date.now(), - planDowngradeRequest: null, enabled: true, deleteProtection: true, updatedAtM: null, @@ -276,19 +271,14 @@ export abstract class Harness { id: newId("test"), name: "user", orgId: newId("test"), - __toBeDeleted: newId("test"), plan: "pro", tier: "Pro Max", features: {}, betaFeatures: {}, stripeCustomerId: null, stripeSubscriptionId: null, - trialEnds: null, subscriptions: null, - planLockedUntil: null, - planChanged: null, createdAtM: Date.now(), - planDowngradeRequest: null, enabled: true, deleteProtection: true, updatedAtM: null, diff --git a/apps/dashboard/lib/trpc/routers/workspace/create.ts b/apps/dashboard/lib/trpc/routers/workspace/create.ts index 38879f89fa..9e34c5ac05 100644 --- a/apps/dashboard/lib/trpc/routers/workspace/create.ts +++ b/apps/dashboard/lib/trpc/routers/workspace/create.ts @@ -31,19 +31,14 @@ export const createWorkspace = t.procedure const workspace: Workspace = { id: newId("workspace"), orgId: orgId, - __toBeDeleted: newId("fake"), name: input.name, plan: "free", tier: "Free", stripeCustomerId: null, stripeSubscriptionId: null, - trialEnds: new Date(Date.now() + 1000 * 60 * 60 * 24 * 14), // 2 weeks features: {}, betaFeatures: {}, - planLockedUntil: null, - planChanged: null, subscriptions: {}, - planDowngradeRequest: null, enabled: true, deleteProtection: true, createdAtM: Date.now(), diff --git a/internal/db/src/schema/workspaces.ts b/internal/db/src/schema/workspaces.ts index d1e811435e..4a47fedda1 100644 --- a/internal/db/src/schema/workspaces.ts +++ b/internal/db/src/schema/workspaces.ts @@ -1,7 +1,6 @@ import type { Subscriptions } from "@unkey/billing"; -import { newId } from "@unkey/id"; import { relations } from "drizzle-orm"; -import { boolean, datetime, json, mysqlEnum, mysqlTable, varchar } from "drizzle-orm/mysql-core"; +import { boolean, json, mysqlEnum, mysqlTable, varchar } from "drizzle-orm/mysql-core"; import { apis } from "./apis"; import { identities } from "./identity"; import { keyAuth } from "./keyAuth"; @@ -15,7 +14,6 @@ import { vercelBindings, vercelIntegrations } from "./vercel_integration"; export const workspaces = mysqlTable("workspaces", { id: varchar("id", { length: 256 }).primaryKey(), - __toBeDeleted: varchar("tenant_id", { length: 256 }).$defaultFn(() => newId("fake")), orgId: varchar("org_id", { length: 256 }).notNull().unique(), name: varchar("name", { length: 256 }).notNull(), @@ -30,9 +28,6 @@ export const workspaces = mysqlTable("workspaces", { stripeCustomerId: varchar("stripe_customer_id", { length: 256 }), stripeSubscriptionId: varchar("stripe_subscription_id", { length: 256 }), - // null means there was no trial - trialEnds: datetime("trial_ends", { fsp: 3 }), - /** * feature flags * @@ -82,15 +77,10 @@ export const workspaces = mysqlTable("workspaces", { webhooks?: boolean; }>() .notNull(), - // prevent plan changes for a certain time, should be 1 day - // deprecated, use planChanged - planLockedUntil: datetime("plan_locked_until", { fsp: 3 }), + /** - * If a user requests to downgrade, we mark the workspace and downgrade it after the next - * billing happened. + * deprecated, most customers are on stripe subscriptions instead */ - planDowngradeRequest: mysqlEnum("plan_downgrade_request", ["free"]), - planChanged: datetime("plan_changed", { fsp: 3 }), subscriptions: json("subscriptions").$type(), /** * if the workspace is disabled, all API requests will be rejected diff --git a/tools/local/src/cmd/seed/apis.ts b/tools/local/src/cmd/seed/apis.ts index 18e8f8bdf5..dbee06cbf8 100644 --- a/tools/local/src/cmd/seed/apis.ts +++ b/tools/local/src/cmd/seed/apis.ts @@ -398,7 +398,7 @@ export async function seedApiAndKeys(workspaceId: string, count: number) { ); } } else { - console.log( + console.info( "No keys available for verification events. Skipping verification event generation.", ); } diff --git a/tools/local/src/cmd/seed/batch-operations.ts b/tools/local/src/cmd/seed/batch-operations.ts index 93b4d3d76c..f58727380c 100644 --- a/tools/local/src/cmd/seed/batch-operations.ts +++ b/tools/local/src/cmd/seed/batch-operations.ts @@ -92,7 +92,7 @@ export async function insertVerificationEvents( process.stdout.write("\n"); - console.log( + console.info( `\nāœ… Successfully inserted ${count.toLocaleString()} verification events with ${ generateMatchingApiRequests ? "matching API requests" : "no matching API requests" }.`, @@ -175,7 +175,7 @@ export async function insertRatelimitEvents( const totalTimeElapsed = Date.now() - progress.startTime; const avgRecordsPerSecond = count / (totalTimeElapsed / 1000); - console.log( + console.info( `āœ… Successfully inserted ${count.toLocaleString()} ratelimit events with ${ generateMatchingApiRequests ? "matching API requests" : "no matching API requests" } (avg: ${Math.round(avgRecordsPerSecond).toLocaleString()} records/sec)`, diff --git a/tools/local/src/cmd/seed/logs.ts b/tools/local/src/cmd/seed/logs.ts index c09f77971d..c42995da7a 100644 --- a/tools/local/src/cmd/seed/logs.ts +++ b/tools/local/src/cmd/seed/logs.ts @@ -51,7 +51,7 @@ async function insertApiRequestLogs( const totalTimeElapsed = Date.now() - progress.startTime; const avgRecordsPerSecond = count / (totalTimeElapsed / 1000); - console.log( + console.info( `āœ… Successfully inserted ${count.toLocaleString()} API request logs with realistic 30-day time distribution (avg: ${Math.round( avgRecordsPerSecond, ).toLocaleString()} records/sec)`,