mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
fix(starter): updated table variable names in schema.ts to match actual supabase table names
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user