import dayjs from 'dayjs' import Link from 'next/link' import { useState } from 'react' import CodeEditor from 'components/ui/CodeEditor/CodeEditor' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { DatabaseMigration, useMigrationsQuery } from 'data/database/migrations-query' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { Search } from 'lucide-react' import { Button, Card, Input, SidePanel, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from 'ui' import { Admonition } from 'ui-patterns' import MigrationsEmptyState from './MigrationsEmptyState' const Migrations = () => { const [search, setSearch] = useState('') const [selectedMigration, setSelectedMigration] = useState() const { data: project } = useSelectedProjectQuery() const { data, 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) => { // [Joshen] LEFT OFF HERE const insertedAt = dayjs(migration.version, 'YYYYMMDDHHmmss').format( 'DD MMM YYYY, HH:mm:ss' ) return ( {migration.version} {migration?.name ?? 'Name not available'} {insertedAt} ) }) ) : (

No results found

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

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