import { SupportCategories } from '@supabase/shared-types/out/constants' import { Search } from 'lucide-react' import { useRef, useState } from 'react' import { Button, Card, cn, SidePanel, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tooltip, TooltipContent, TooltipTrigger, } from 'ui' import { Admonition, TimestampInfo } from 'ui-patterns' import { Input } from 'ui-patterns/DataInputs/Input' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { MigrationsEmptyState } from './MigrationsEmptyState' import { SupportLink } from '@/components/interfaces/Support/SupportLink' import CodeEditor from '@/components/ui/CodeEditor/CodeEditor' import { InlineLink } from '@/components/ui/InlineLink' import { DatabaseMigration, useMigrationsQuery } from '@/data/database/migrations-query' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' import { DOCS_URL } from '@/lib/constants' import { formatMigrationVersionLabel, parseMigrationVersion } from '@/lib/migration-utils' import { SHORTCUT_IDS } from '@/state/shortcuts/registry' import { useShortcut } from '@/state/shortcuts/useShortcut' const Migrations = () => { const [search, setSearch] = useState('') const [selectedMigration, setSelectedMigration] = useState() const searchInputRef = useRef(null) useShortcut( SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH, () => { searchInputRef.current?.focus() searchInputRef.current?.select() }, { label: 'Search migrations' } ) useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, () => setSearch('')) const { data: project } = useSelectedProjectQuery() const { data = [], isPending: isLoading, isSuccess, isError, error, } = useMigrationsQuery({ projectRef: project?.ref, connectionString: project?.connectionString, }) const migrations = search.length === 0 ? data : (data.filter( (migration) => migration.version.includes(search) || migration.name?.includes(search) ) ?? []) return ( <> {isLoading && (
)}
{isError && (

Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.

Error: {error?.message ?? 'Unknown'}

} >
)} {isSuccess && (
{data.length <= 0 && } {data.length > 0 && (
setSearch(e.target.value)} icon={} /> Version Name Inserted at (UTC) {migrations.length > 0 ? ( migrations.map((migration) => { const versionDayjs = parseMigrationVersion(migration.version) const label = formatMigrationVersionLabel(migration.version) const insertedAt = versionDayjs ? versionDayjs.toISOString() : undefined return ( {migration.version} {migration?.name ?? 'Name not available'} {!!insertedAt ? ( ) : (

Unknown

)}
{!insertedAt && ( This migration was not generated via the{' '} Briven CLI {' '} and hence we're unable to parse when this migration was inserted at. )}
) }) ) : (

No results found

Your search for "{search}" did not return any results

)}
)}
)}
setSelectedMigration(undefined)} customFooter={
} >
) } export default Migrations