mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 06:36:37 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
71 lines
2 KiB
TypeScript
71 lines
2 KiB
TypeScript
import pgMeta from '@supabase/pg-meta'
|
|
import { PGTriggerUpdate } from '@supabase/pg-meta/src/pg-meta-triggers'
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import { executeSql } from 'data/sql/execute-sql-query'
|
|
import { toast } from 'sonner'
|
|
import type { ResponseError, UseCustomMutationOptions } from 'types'
|
|
import { databaseTriggerKeys } from './keys'
|
|
|
|
export type DatabaseTriggerUpdateVariables = {
|
|
originalTrigger: {
|
|
id: number
|
|
name: string
|
|
schema: string
|
|
table: string
|
|
}
|
|
projectRef: string
|
|
connectionString?: string | null
|
|
payload: PGTriggerUpdate
|
|
}
|
|
|
|
export async function updateDatabaseTrigger({
|
|
originalTrigger,
|
|
projectRef,
|
|
connectionString,
|
|
payload,
|
|
}: DatabaseTriggerUpdateVariables) {
|
|
const { sql } = pgMeta.triggers.update(originalTrigger, payload)
|
|
|
|
const { result } = await executeSql({
|
|
projectRef,
|
|
connectionString,
|
|
sql,
|
|
queryKey: ['trigger', 'update', originalTrigger.id],
|
|
})
|
|
|
|
return result
|
|
}
|
|
|
|
type DatabaseTriggerUpdateData = Awaited<ReturnType<typeof updateDatabaseTrigger>>
|
|
|
|
export const useDatabaseTriggerUpdateMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseCustomMutationOptions<
|
|
DatabaseTriggerUpdateData,
|
|
ResponseError,
|
|
DatabaseTriggerUpdateVariables
|
|
>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<DatabaseTriggerUpdateData, ResponseError, DatabaseTriggerUpdateVariables>({
|
|
mutationFn: (vars) => updateDatabaseTrigger(vars),
|
|
async onSuccess(data, variables, context) {
|
|
const { projectRef } = variables
|
|
await queryClient.invalidateQueries({ queryKey: databaseTriggerKeys.list(projectRef) })
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to update database trigger: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
})
|
|
}
|