fix(starter): updated table variable names in schema.ts to match actual supabase table names

This commit is contained in:
Waleed Latif
2025-02-19 12:59:24 -08:00
parent d5f102d419
commit 384b79ef8d
4 changed files with 15 additions and 15 deletions

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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()

View File

@@ -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)
}