Complete the ClickHouse migration by removing all PostgreSQL analytics code. PostgreSQL now serves only RBAC, config, and audit — all observability data is exclusively in ClickHouse. - Delete 6 dead PostgreSQL store classes (executions, stats, diagrams, events, metrics, metrics-query) and 2 integration tests - Delete RetentionScheduler (ClickHouse TTL handles retention) - Remove all 7 cameleer.storage.* feature flags from application.yml - Remove all @ConditionalOnProperty from ClickHouse beans in StorageBeanConfig - Consolidate 14 Flyway migrations (V1-V14) into single clean V1 with only RBAC/config/audit tables (no TimescaleDB, no analytics tables) - Switch from timescale/timescaledb-ha:pg16 to postgres:16 everywhere (docker-compose, deploy/postgres.yaml, test containers) - Remove TimescaleDB check and /metrics-pipeline from DatabaseAdminController - Set clickhouse.enabled default to true Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { adminFetch } from './admin-api';
|
|
import { useRefreshInterval } from '../use-refresh-interval';
|
|
|
|
// ── Types ──────────────────────────────────────────────────────────────
|
|
|
|
export interface DatabaseStatus {
|
|
connected: boolean;
|
|
version: string | null;
|
|
host: string | null;
|
|
schema: string | null;
|
|
}
|
|
|
|
export interface PoolStats {
|
|
activeConnections: number;
|
|
idleConnections: number;
|
|
threadsAwaitingConnection: number;
|
|
connectionTimeout: number;
|
|
maximumPoolSize: number;
|
|
}
|
|
|
|
export interface TableInfo {
|
|
tableName: string;
|
|
rowCount: number;
|
|
dataSize: string;
|
|
indexSize: string;
|
|
dataSizeBytes: number;
|
|
indexSizeBytes: number;
|
|
}
|
|
|
|
export interface ActiveQuery {
|
|
pid: number;
|
|
durationSeconds: number;
|
|
state: string;
|
|
query: string;
|
|
}
|
|
|
|
// ── Query Hooks ────────────────────────────────────────────────────────
|
|
|
|
export function useDatabaseStatus() {
|
|
const refetchInterval = useRefreshInterval(30_000);
|
|
return useQuery({
|
|
queryKey: ['admin', 'database', 'status'],
|
|
queryFn: () => adminFetch<DatabaseStatus>('/database/status'),
|
|
refetchInterval,
|
|
});
|
|
}
|
|
|
|
export function useConnectionPool() {
|
|
const refetchInterval = useRefreshInterval(10_000);
|
|
return useQuery({
|
|
queryKey: ['admin', 'database', 'pool'],
|
|
queryFn: () => adminFetch<PoolStats>('/database/pool'),
|
|
refetchInterval,
|
|
});
|
|
}
|
|
|
|
export function useDatabaseTables() {
|
|
const refetchInterval = useRefreshInterval(60_000);
|
|
return useQuery({
|
|
queryKey: ['admin', 'database', 'tables'],
|
|
queryFn: () => adminFetch<TableInfo[]>('/database/tables'),
|
|
refetchInterval,
|
|
});
|
|
}
|
|
|
|
export function useActiveQueries() {
|
|
const refetchInterval = useRefreshInterval(5_000);
|
|
return useQuery({
|
|
queryKey: ['admin', 'database', 'queries'],
|
|
queryFn: () => adminFetch<ActiveQuery[]>('/database/queries'),
|
|
refetchInterval,
|
|
});
|
|
}
|
|
|
|
// ── Mutation Hooks ─────────────────────────────────────────────────────
|
|
|
|
export function useKillQuery() {
|
|
const qc = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (pid: number) =>
|
|
adminFetch<void>(`/database/queries/${pid}/kill`, { method: 'POST' }),
|
|
onSuccess: () => {
|
|
qc.invalidateQueries({ queryKey: ['admin', 'database', 'queries'] });
|
|
},
|
|
});
|
|
}
|