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>
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { UseCustomQueryOptions } from 'types'
|
|
import { executeSql, ExecuteSqlError } from '../sql/execute-sql-query'
|
|
import { databaseKeys } from './keys'
|
|
|
|
export type DatabaseMigration = {
|
|
version: string
|
|
name?: string
|
|
statements?: string[]
|
|
}
|
|
|
|
export const getMigrationsSql = () => {
|
|
const sql = /* SQL */ `
|
|
select
|
|
*
|
|
from supabase_migrations.schema_migrations sm
|
|
order by sm.version desc
|
|
`.trim()
|
|
|
|
return sql
|
|
}
|
|
|
|
export type MigrationsVariables = {
|
|
projectRef?: string
|
|
connectionString?: string | null
|
|
}
|
|
|
|
export async function getMigrations(
|
|
{ projectRef, connectionString }: MigrationsVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
const sql = getMigrationsSql()
|
|
|
|
try {
|
|
const { result } = await executeSql(
|
|
{ projectRef, connectionString, sql, queryKey: ['migrations'] },
|
|
signal
|
|
)
|
|
|
|
return result as DatabaseMigration[]
|
|
} catch (error) {
|
|
if (
|
|
(error as ExecuteSqlError).message.includes(
|
|
'relation "supabase_migrations.schema_migrations" does not exist'
|
|
)
|
|
) {
|
|
return []
|
|
}
|
|
|
|
throw error
|
|
}
|
|
}
|
|
|
|
export type MigrationsData = Awaited<ReturnType<typeof getMigrations>>
|
|
export type MigrationsError = ExecuteSqlError
|
|
|
|
export const useMigrationsQuery = <TData = MigrationsData>(
|
|
{ projectRef, connectionString }: MigrationsVariables,
|
|
{ enabled = true, ...options }: UseCustomQueryOptions<MigrationsData, MigrationsError, TData> = {}
|
|
) =>
|
|
useQuery<MigrationsData, MigrationsError, TData>({
|
|
queryKey: databaseKeys.migrations(projectRef),
|
|
queryFn: ({ signal }) => getMigrations({ projectRef, connectionString }, signal),
|
|
enabled: enabled && typeof projectRef !== 'undefined',
|
|
...options,
|
|
})
|