import { Search } from 'lucide-react' import { useState } from 'react' import { SupportCategories } from '@supabase/shared-types/out/constants' 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 { parseMigrationVersion } from 'lib/migration-utils' import { Button, Card, cn, SidePanel, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tooltip, TooltipContent, TooltipTrigger, } from 'ui' import { Admonition } from 'ui-patterns' import { Input } from 'ui-patterns/DataInputs/Input' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { MigrationsEmptyState } from './MigrationsEmptyState' const Migrations = () => { const [search, setSearch] = useState('') const [selectedMigration, setSelectedMigration] = useState() 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 as any)?.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 insertedAt = versionDayjs ? versionDayjs.format('DD MMM YYYY, HH:mm:ss') : undefined return ( {migration.version} {migration?.name ?? 'Name not available'} {insertedAt ?? 'Unknown'} {!insertedAt && ( This migration was not generated via the{' '} Supabase 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