From 384b79ef8d23daa7a099da45c96c2f03701f80f9 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 19 Feb 2025 12:59:24 -0800 Subject: [PATCH] fix(starter): updated table variable names in schema.ts to match actual supabase table names --- app/api/scheduled/execute/route.ts | 10 +++++----- app/api/settings/environment/route.ts | 10 +++++----- db/schema.ts | 6 +++--- lib/logging.ts | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/api/scheduled/execute/route.ts b/app/api/scheduled/execute/route.ts index 7213a8edb0..965d5bc0ea 100644 --- a/app/api/scheduled/execute/route.ts +++ b/app/api/scheduled/execute/route.ts @@ -8,7 +8,7 @@ import { decryptSecret } from '@/lib/utils' import { BlockState, WorkflowState } from '@/stores/workflow/types' import { mergeSubblockState } from '@/stores/workflow/utils' import { db } from '@/db' -import { userEnvironment, workflow, workflowSchedule } from '@/db/schema' +import { environment, workflow, workflowSchedule } from '@/db/schema' import { Executor } from '@/executor' import { Serializer } from '@/serializer' @@ -170,8 +170,8 @@ export async function POST(req: NextRequest) { // Retrieve environment variables for this user const [userEnv] = await db .select() - .from(userEnvironment) - .where(eq(userEnvironment.userId, workflowRecord.userId)) + .from(environment) + .where(eq(environment.userId, workflowRecord.userId)) .limit(1) if (!userEnv) { @@ -312,8 +312,8 @@ export async function GET(req: NextRequest) { // Retrieve environment variables for this user const [userEnv] = await db .select() - .from(userEnvironment) - .where(eq(userEnvironment.userId, workflowRecord.userId)) + .from(environment) + .where(eq(environment.userId, workflowRecord.userId)) .limit(1) if (!userEnv) { diff --git a/app/api/settings/environment/route.ts b/app/api/settings/environment/route.ts index 3d94eb9f7c..68c03a602e 100644 --- a/app/api/settings/environment/route.ts +++ b/app/api/settings/environment/route.ts @@ -5,7 +5,7 @@ import { getSession } from '@/lib/auth' import { encryptSecret } from '@/lib/utils' import { EnvironmentVariable } from '@/stores/settings/environment/types' import { db } from '@/db' -import { userEnvironment } from '@/db/schema' +import { environment } from '@/db/schema' // Schema for environment variable updates const EnvVarSchema = z.object({ @@ -31,7 +31,7 @@ export async function POST(req: NextRequest) { // Upsert the environment variables await db - .insert(userEnvironment) + .insert(environment) .values({ id: crypto.randomUUID(), userId: session.user.id, @@ -39,7 +39,7 @@ export async function POST(req: NextRequest) { updatedAt: new Date(), }) .onConflictDoUpdate({ - target: [userEnvironment.userId], + target: [environment.userId], set: { variables: encryptedVariables, updatedAt: new Date(), @@ -70,8 +70,8 @@ export async function GET(request: Request) { const result = await db .select() - .from(userEnvironment) - .where(eq(userEnvironment.userId, userId)) + .from(environment) + .where(eq(environment.userId, userId)) .limit(1) if (!result.length || !result[0].variables) { diff --git a/db/schema.ts b/db/schema.ts index 6e634e4057..213fb6e6f7 100644 --- a/db/schema.ts +++ b/db/schema.ts @@ -1,4 +1,4 @@ -import { boolean, integer, json, pgTable, text, timestamp, unique } from 'drizzle-orm/pg-core' +import { boolean, json, pgTable, text, timestamp } from 'drizzle-orm/pg-core' export const user = pgTable('user', { id: text('id').primaryKey(), @@ -71,7 +71,7 @@ export const waitlist = pgTable('waitlist', { updatedAt: timestamp('updated_at').notNull().defaultNow(), }) -export const consoleLog = pgTable('workflow_logs', { +export const workflowLogs = pgTable('workflow_logs', { id: text('id').primaryKey(), workflowId: text('workflow_id') .notNull() @@ -82,7 +82,7 @@ export const consoleLog = pgTable('workflow_logs', { createdAt: timestamp('created_at').notNull().defaultNow(), }) -export const userEnvironment = pgTable('environment', { +export const environment = pgTable('environment', { id: text('id').primaryKey(), // Use the user id as the key userId: text('user_id') .notNull() diff --git a/lib/logging.ts b/lib/logging.ts index 906621cc5e..e922db70aa 100644 --- a/lib/logging.ts +++ b/lib/logging.ts @@ -1,5 +1,5 @@ import { db } from '@/db' -import { consoleLog } from '@/db/schema' +import { workflowLogs } from '@/db/schema' export interface LogEntry { id: string @@ -11,5 +11,5 @@ export interface LogEntry { } export async function persistLog(log: LogEntry) { - await db.insert(consoleLog).values(log) + await db.insert(workflowLogs).values(log) }