Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Implement create index functionality

Joshen Lim45799b3d91b2
diff --git a/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx b/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
new file mode 100644
index 00000000000..85176b28042
--- /dev/null
+++ b/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
@@ -0,0 +1,239 @@
+import Link from 'next/link'
+import { useEffect, useMemo, useState } from 'react'
+import { Button, Input, Listbox, SidePanel } from 'ui'
+
+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+import CodeEditor from 'components/ui/CodeEditor'
+import MultiSelect, { MultiSelectOption } from 'components/ui/MultiSelect'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
+import { useSchemasQuery } from 'data/database/schemas-query'
+import { useTableColumnsQuery } from 'data/database/table-columns-query'
+import { useEntityTypesQuery } from 'data/entity-types/entity-types-infinite-query'
+import { INDEX_TYPES } from './Indexes.constants'
+import { useExecuteSqlMutation } from 'data/sql/execute-sql-mutation'
+import { useIndexesQuery } from 'data/database/indexes-query'
+import { useStore } from 'hooks'
+
+interface CreateIndexSidePanelProps {
+ visible: boolean
+ onClose: () => void
+}
+
+const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelProps) => {
+ const { ui } = useStore()
+ const { project } = useProjectContext()
+ const [selectedSchema, setSelectedSchema] = useState('public')
+ const [selectedEntity, setSelectedEntity] = useState('---')
+ const [selectedColumns, setSelectedColumns] = useState<string[]>([])
+ const [selectedIndexType, setSelectedIndexType] = useState<string>(INDEX_TYPES[0].value)
+
+ const { refetch: refetchSchemaIndexes } = useIndexesQuery({
+ schema: selectedSchema,
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ })
+ const { data: schemas } = useSchemasQuery({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ })
+ const { data: entities } = useEntityTypesQuery(
+ {
+ schema: selectedSchema,
+ sort: 'alphabetical',
+ search: undefined,
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ },
+ { keepPreviousData: true }
+ )
+ const {
+ data: tableColumns,
+ isLoading: isLoadingTableColumns,
+ isSuccess: isSuccessTableColumns,
+ } = useTableColumnsQuery({
+ table: 'countries',
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ })
+
+ const { mutate: execute, isLoading: isExecuting } = useExecuteSqlMutation({
+ onSuccess(data) {
+ refetchSchemaIndexes()
+ onClose()
+ ui.setNotification({ category: 'success', message: `Successfully created index` })
+ },
+ onError(error) {
+ ui.setNotification({
+ error,
+ category: 'error',
+ message: `Failed to create index: ${error.message}`,
+ })
+ },
+ })
+
+ const entityTypes = useMemo(
+ () => entities?.pages.flatMap((page) => page.data.entities) || [],
+ [entities?.pages]
+ )
+ const columns = tableColumns?.result[0].columns ?? []
+ const columnOptions: MultiSelectOption[] = columns.map((column) => {
+ return { id: column.attname, value: column.attname, name: column.attname, disabled: false }
+ })
+
+ const generatedSQL = `
+CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexType} (${selectedColumns.join(
+ ', '
+ )});
+`.trim()
+
+ const onSaveIndex = () => {
+ if (!project) return console.error('Project is required')
+
+ execute({
+ projectRef: project.ref,
+ connectionString: project.connectionString,
+ sql: generatedSQL,
+ })
+ }
+
+ useEffect(() => {
+ if (visible) {
+ setSelectedSchema('public')
+ setSelectedEntity('---')
+ setSelectedColumns([])
+ setSelectedIndexType(INDEX_TYPES[0].value)
+ }
+ }, [visible])
+
+ useEffect(() => {
+ setSelectedEntity('---')
+ setSelectedColumns([])
+ setSelectedIndexType(INDEX_TYPES[0].value)
+ }, [selectedSchema])
+
+ useEffect(() => {
+ setSelectedColumns([])
+ setSelectedIndexType(INDEX_TYPES[0].value)
+ }, [selectedEntity])
+
+ return (
+ <SidePanel
+ size="large"
+ header="Create new index"
+ visible={visible}
+ onCancel={onClose}
+ onConfirm={() => onSaveIndex()}
+ loading={isExecuting}
+ confirmText="Create index"
+ >
+ <div className="py-6 space-y-6">
+ <SidePanel.Content className="space-y-6">
+ <Listbox
+ size="small"
+ label="Select a schema"
+ value={selectedSchema}
+ onChange={setSelectedSchema}
+ >
+ {(schemas?.result ?? []).map((schema) => (
+ <Listbox.Option key={schema.name} value={schema.name} label={schema.name}>
+ {schema.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+
+ {entityTypes.length === 0 ? (
+ <div className="space-y-2">
+ <p className="text-sm text-scale-1100 leading-4">Select a table</p>
+ <Input placeholder="No tables available in schema" />
+ </div>
+ ) : (
+ <Listbox
+ size="small"
+ label="Select a table"
+ value={selectedEntity}
+ onChange={setSelectedEntity}
+ >
+ <Listbox.Option key="default-option-table" value="---" label="---">
+ ---
+ </Listbox.Option>
+ {(entityTypes ?? []).map((entity) => (
+ <Listbox.Option key={entity.name} value={entity.name} label={entity.name}>
+ {entity.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+ )}
+
+ {selectedEntity !== '---' && (
+ <div>
+ <p className="text-sm text-scale-1100 mb-2">Select up to 32 columns</p>
+ {isLoadingTableColumns && <ShimmeringLoader className="py-4" />}
+ {isSuccessTableColumns && (
+ <MultiSelect
+ options={columnOptions}
+ placeholder=""
+ searchPlaceholder="Search for a column"
+ value={selectedColumns}
+ onChange={setSelectedColumns}
+ />
+ )}
+ </div>
+ )}
+ </SidePanel.Content>
+
+ {selectedColumns.length > 0 && (
+ <>
+ <SidePanel.Separator />
+ <SidePanel.Content className="space-y-6">
+ <Listbox
+ size="small"
+ label="Select an index type"
+ value={selectedIndexType}
+ onChange={setSelectedIndexType}
+ >
+ {INDEX_TYPES.map((index) => (
+ <Listbox.Option key={index.name} value={index.value} label={index.name}>
+ <p>{index.name}</p>
+ <p>{index.description}</p>
+ </Listbox.Option>
+ ))}
+ </Listbox>
+ </SidePanel.Content>
+ <SidePanel.Separator />
+ <SidePanel.Content>
+ <div className="flex items-center justify-between">
+ <p className="text-sm">Preview of SQL statement</p>
+ <Link
+ passHref
+ href={
+ project !== undefined
+ ? `/project/${project.ref}/sql/new?content=${generatedSQL}`
+ : '/'
+ }
+ >
+ <a>
+ <Button type="default">Open in SQL Editor</Button>
+ </a>
+ </Link>
+ </div>
+ </SidePanel.Content>
+ <div className="h-[200px]">
+ <div className="relative h-full">
+ <CodeEditor
+ isReadOnly
+ id={`${selectedSchema}-${selectedEntity}-${selectedColumns.join(
+ ','
+ )}-${selectedIndexType}`}
+ language="pgsql"
+ defaultValue={generatedSQL}
+ />
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+ </SidePanel>
+ )
+}
+
+export default CreateIndexSidePanel
diff --git a/studio/components/interfaces/Database/Indexes/Indexes.constants.ts b/studio/components/interfaces/Database/Indexes/Indexes.constants.ts
new file mode 100644
index 00000000000..2793de20221
--- /dev/null
+++ b/studio/components/interfaces/Database/Indexes/Indexes.constants.ts
@@ -0,0 +1,32 @@
+export const INDEX_TYPES = [
+ {
+ name: 'B-Tree',
+ value: 'btree',
+ description: 'For querying data with equality or range conditions on columns.',
+ },
+ {
+ name: 'Hash',
+ value: 'hash',
+ description: 'For querying exact matches on columns',
+ },
+ {
+ name: 'GiST',
+ value: 'gist',
+ description: 'For querying complex data types or custom-defined operators',
+ },
+ {
+ name: 'SP-GiST',
+ value: 'spgist',
+ description: 'Similar to GiST, but is more specialized and customizable',
+ },
+ {
+ name: 'GIN',
+ value: 'gin',
+ description: 'For querying multi-valued data such as arrays or full-text search scenarios',
+ },
+ {
+ name: 'BRIN',
+ value: 'brin',
+ description: 'For querying large tables with sorted data',
+ },
+]
diff --git a/studio/components/interfaces/Database/Indexes/Indexes.tsx b/studio/components/interfaces/Database/Indexes/Indexes.tsx
index 304f74b21f2..a4893bafa54 100644
--- a/studio/components/interfaces/Database/Indexes/Indexes.tsx
+++ b/studio/components/interfaces/Database/Indexes/Indexes.tsx
@@ -18,11 +18,13 @@ import { DatabaseIndex, useIndexesQuery } from 'data/database/indexes-query'
import { useSchemasQuery } from 'data/database/schemas-query'
import Table from 'components/to-be-cleaned/Table'
import CodeEditor from 'components/ui/CodeEditor'
+import CreateIndexSidePanel from './CreateIndexSidePanel'
const Indexes = () => {
const [search, setSearch] = useState('')
const [selectedSchema, setSelectedSchema] = useState('public')
const [selectedIndex, setSelectedIndex] = useState<DatabaseIndex>()
+ const [showCreateIndex, setShowCreateIndex] = useState(false)
const { project } = useProjectContext()
const {
@@ -82,41 +84,50 @@ const Indexes = () => {
</div>
</div>
- <div className="flex items-center space-x-2 mb-4">
- {isLoadingSchemas && <ShimmeringLoader className="w-[260px]" />}
- {isErrorSchemas && (
- <div className="w-[260px] text-light text-sm border px-3 py-1.5 rounded flex items-center space-x-2">
- <IconAlertCircle strokeWidth={2} size={16} />
- <p>Failed to load schemas</p>
- </div>
- )}
- {isSuccessSchemas && (
- <Listbox
+ <div className="flex items-center justify-between mb-4">
+ <div className="flex items-center space-x-2">
+ {isLoadingSchemas && <ShimmeringLoader className="w-[260px]" />}
+ {isErrorSchemas && (
+ <div className="w-[260px] text-light text-sm border px-3 py-1.5 rounded flex items-center space-x-2">
+ <IconAlertCircle strokeWidth={2} size={16} />
+ <p>Failed to load schemas</p>
+ </div>
+ )}
+ {isSuccessSchemas && (
+ <Listbox
+ size="small"
+ value={selectedSchema}
+ onChange={setSelectedSchema}
+ className="w-[260px]"
+ >
+ {(schemas?.result ?? []).map((schema) => (
+ <Listbox.Option
+ key={schema.name}
+ value={schema.name}
+ label={schema.name}
+ addOnBefore={() => <span className="text-scale-900">schema</span>}
+ >
+ {schema.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+ )}
+ <Input
size="small"
- value={selectedSchema}
- onChange={setSelectedSchema}
- className="w-[260px]"
- >
- {(schemas?.result ?? []).map((schema) => (
- <Listbox.Option
- key={schema.name}
- value={schema.name}
- label={schema.name}
- addOnBefore={() => <span className="text-scale-900">schema</span>}
- >
- {schema.name}
- </Listbox.Option>
- ))}
- </Listbox>
- )}
- <Input
- size="small"
- value={search}
- className="w-[250px]"
- onChange={(e) => setSearch(e.target.value)}
- placeholder="Search for an index"
- icon={<IconSearch size={14} />}
- />
+ value={search}
+ className="w-[250px]"
+ onChange={(e) => setSearch(e.target.value)}
+ placeholder="Search for an index"
+ icon={<IconSearch size={14} />}
+ />
+ </div>
+ <Button
+ type="primary"
+ onClick={() => setShowCreateIndex(true)}
+ disabled={!isSuccessSchemas}
+ >
+ Create index
+ </Button>
</div>
{isLoadingIndexes && <GenericSkeletonLoader />}
@@ -203,6 +214,8 @@ const Indexes = () => {
</div>
</div>
</SidePanel>
+
+ <CreateIndexSidePanel visible={showCreateIndex} onClose={() => setShowCreateIndex(false)} />
</>
)
}
diff --git a/studio/components/interfaces/SQLEditor/MonacoEditor.tsx b/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
index 85a40e1a0e3..1ba9617554c 100644
--- a/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
+++ b/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
@@ -1,7 +1,7 @@
import Editor, { Monaco, OnMount } from '@monaco-editor/react'
import { useParams } from 'common'
import { useRouter } from 'next/router'
-import { MutableRefObject, useRef, useState } from 'react'
+import { MutableRefObject, useRef } from 'react'
import { cn } from 'ui'
import { SqlSnippet } from 'data/content/sql-snippets-query'
@@ -27,7 +27,7 @@ const MonacoEditor = ({
className,
executeQuery,
}: MonacoEditorProps) => {
- const { ref } = useParams()
+ const { ref, content } = useParams()
const router = useRouter()
const { profile } = useProfile()
const project = useSelectedProject()
@@ -102,7 +102,7 @@ const MonacoEditor = ({
onMount={handleEditorOnMount}
onChange={handleEditorChange}
defaultLanguage="pgsql"
- defaultValue={snippet?.snippet.content.sql}
+ defaultValue={snippet?.snippet.content.sql ?? content}
path={id}
options={{
tabSize: 2,
diff --git a/studio/components/ui/CodeEditor/CodeEditor.tsx b/studio/components/ui/CodeEditor/CodeEditor.tsx
index 06cdf43c0c7..7939c7881e7 100644
--- a/studio/components/ui/CodeEditor/CodeEditor.tsx
+++ b/studio/components/ui/CodeEditor/CodeEditor.tsx
@@ -37,6 +37,7 @@ const CodeEditor = ({
const onMount = async (editor: any, monaco: any) => {
alignEditor(editor)
+
editor.addAction({
id: 'supabase',
label: 'Run Query',
diff --git a/studio/components/ui/CodeEditor/CodeEditor.utils.ts b/studio/components/ui/CodeEditor/CodeEditor.utils.ts
index 9b7808ccc71..8f34d2d344f 100644
--- a/studio/components/ui/CodeEditor/CodeEditor.utils.ts
+++ b/studio/components/ui/CodeEditor/CodeEditor.utils.ts
@@ -3,7 +3,7 @@ export const alignEditor = (editor: any) => {
editor.changeViewZones((accessor: any) => {
accessor.addZone({
afterLineNumber: 0,
- heightInPx: 10,
+ heightInPx: 4,
domNode: document.createElement('div'),
})
})
diff --git a/studio/components/ui/MultiSelect/Badges.tsx b/studio/components/ui/MultiSelect/Badges.tsx
index 1f891906563..becb862e832 100644
--- a/studio/components/ui/MultiSelect/Badges.tsx
+++ b/studio/components/ui/MultiSelect/Badges.tsx
@@ -33,6 +33,7 @@ export const BadgeSelected = ({
className="cursor-pointer opacity-50 transition hover:opacity-100"
onClick={(e: any) => {
e.preventDefault()
+ e.stopPropagation()
handleRemove()
}}
/>
diff --git a/studio/components/ui/MultiSelect/index.tsx b/studio/components/ui/MultiSelect/index.tsx
index 6c78b84a762..275e1e704c3 100644
--- a/studio/components/ui/MultiSelect/index.tsx
+++ b/studio/components/ui/MultiSelect/index.tsx
@@ -1,13 +1,17 @@
-import { useRef, useEffect, useState, FormEvent, KeyboardEvent, ReactNode } from 'react'
-import { orderBy, filter, without } from 'lodash'
+import clsx from 'clsx'
+import { filter, orderBy, without } from 'lodash'
+import { KeyboardEvent, ReactNode, useEffect, useRef, useState } from 'react'
import {
- Popover,
- IconCheck,
IconAlertCircle,
- IconSearch,
- IconPlus,
+ IconCheck,
IconChevronDown,
+ IconPlus,
+ IconSearch,
Input,
+ PopoverContent_Shadcn_,
+ PopoverTrigger_Shadcn_,
+ Popover_Shadcn_,
+ ScrollArea,
} from 'ui'
import { BadgeDisabled, BadgeSelected } from './Badges'
@@ -54,6 +58,7 @@ export default function MultiSelect({
}: Props) {
const ref = useRef(null)
+ const [open, setOpen] = useState(false)
const [selected, setSelected] = useState<string[]>(value || [])
const [searchString, setSearchString] = useState<string>('')
const [inputWidth, setInputWidth] = useState<number>(128)
@@ -66,6 +71,10 @@ export default function MultiSelect({
setInputWidth(ref.current ? (ref.current as any).offsetWidth : inputWidth)
}, [ref.current])
+ useEffect(() => {
+ if (!open) setSearchString('')
+ }, [open])
+
const width = `${inputWidth}px`
// Order the options so disabled items are at the beginning
@@ -131,28 +140,59 @@ export default function MultiSelect({
].join(' ')}
ref={ref}
>
- <Popover
- sideOffset={4}
- side="bottom"
- align="start"
- style={{ width }}
- header={
- <div className="flex items-center space-x-2 py-1">
- <IconSearch size={14} />
- <input
- autoFocus
- className="w-72 bg-transparent text-sm placeholder-scale-1000 outline-none"
- value={searchString}
- placeholder={searchPlaceholder}
- onKeyPress={onKeyPress}
- onChange={(e: FormEvent<HTMLInputElement>) =>
- setSearchString(e.currentTarget.value)
+ <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>
+ <PopoverTrigger_Shadcn_ asChild>
+ <div
+ className={[
+ 'flex w-full flex-wrap items-start gap-1.5 p-1.5 cursor-pointer',
+ `${selectedOptions.length === 0 ? 'h-9' : ''}`,
+ ].join(' ')}
+ onClick={() => setOpen(true)}
+ >
+ {selectedOptions.length === 0 && placeholder && (
+ <div className="px-2 text-sm text-scale-1000 h-full flex items-center">
+ {placeholder}
+ </div>
+ )}
+ {selectedOptions.map((value, idx) => {
+ const id = `${value}-${idx}`
+ const option = formattedOptions.find((x) => x.value === value)
+ const isDisabled = option?.disabled ?? false
+ if (!option) {
+ return <></>
+ } else if (isDisabled) {
+ return <BadgeDisabled key={id} name={value} />
+ } else {
+ return (
+ <BadgeSelected
+ key={id}
+ name={value}
+ handleRemove={() =>
+ allowDuplicateSelection ? handleRemove(idx) : handleChange(option)
+ }
+ />
+ )
}
- />
+ })}
+ <div className="absolute inset-y-0 right-0 pl-3 pr-2 flex space-x-1 items-center cursor-pointer ">
+ <IconChevronDown size={16} strokeWidth={2} className="text-scale-900" />
+ </div>
</div>
- }
- overlay={
- <div className="max-h-[225px] space-y-1 overflow-y-auto p-1">
+ </PopoverTrigger_Shadcn_>
+ <PopoverContent_Shadcn_
+ className="p-0"
+ side="bottom"
+ align="start"
+ style={{ width, marginLeft: '-5px' }}
+ >
+ <Input
+ className="[&>div>div>div>input]:!rounded-b-none [&>div>div>div>input]:!pl-9"
+ icon={<IconSearch size={16} />}
+ placeholder={searchPlaceholder}
+ value={searchString}
+ onChange={(e) => setSearchString(e.target.value)}
+ />
+ <ScrollArea className={clsx('p-1', filteredOptions.length > 5 ? 'h-[225px]' : '')}>
{filteredOptions.length >= 1 ? (
filteredOptions.map((option) => {
const active =
@@ -185,9 +225,7 @@ export default function MultiSelect({
<IconCheck
size={16}
strokeWidth={3}
- className={`cursor-pointer transition ${
- active ? ' dark:text-green-500' : ''
- }`}
+ className={`cursor-pointer transition ${active ? 'text-brand' : ''}`}
/>
)}
{allowDuplicateSelection && (
@@ -231,46 +269,9 @@ export default function MultiSelect({
)}
</div>
)}
- </div>
- }
- onOpenChange={() => setSearchString('')}
- >
- <div
- className={[
- 'flex w-full flex-wrap items-start gap-1.5 p-1.5 cursor-default',
- `${selectedOptions.length === 0 ? 'h-9' : ''}`,
- ].join(' ')}
- >
- {selectedOptions.length === 0 && placeholder && (
- <div className="px-2 text-sm text-scale-1000 h-full flex items-center">
- {placeholder}
- </div>
- )}
- {selectedOptions.map((value, idx) => {
- const id = `${value}-${idx}`
- const option = formattedOptions.find((x) => x.value === value)
- const isDisabled = option?.disabled ?? false
- if (!option) {
- return <></>
- } else if (isDisabled) {
- return <BadgeDisabled key={id} name={value} />
- } else {
- return (
- <BadgeSelected
- key={id}
- name={value}
- handleRemove={() =>
- allowDuplicateSelection ? handleRemove(idx) : handleChange(option)
- }
- />
- )
- }
- })}
- <div className="absolute inset-y-0 right-0 pl-3 pr-2 flex space-x-1 items-center cursor-pointer ">
- <IconChevronDown size={16} strokeWidth={2} className="text-scale-900" />
- </div>
- </div>
- </Popover>
+ </ScrollArea>
+ </PopoverContent_Shadcn_>
+ </Popover_Shadcn_>
</div>
{descriptionText && (
diff --git a/studio/data/database/table-columns-query.ts b/studio/data/database/table-columns-query.ts
index 7fa27a50b4c..b0d898eb965 100644
--- a/studio/data/database/table-columns-query.ts
+++ b/studio/data/database/table-columns-query.ts
@@ -10,7 +10,7 @@ export type TableColumn = {
columns: any[]
}
-export const getTableColumnsQuery = () => {
+export const getTableColumnsQuery = (table?: string) => {
const sql = /* SQL */ `
SELECT
tbl.schemaname,
@@ -67,6 +67,7 @@ export const getTableColumnsQuery = () => {
AND NOT a.attisdropped
AND has_column_privilege(tbl.quoted_name, a.attname, 'SELECT, INSERT, UPDATE, REFERENCES')
)
+ ${table !== undefined ? `WHERE tablename = '${table}'` : ''}
GROUP BY schemaname, tablename, quoted_name, is_table;
`.trim()
@@ -76,20 +77,21 @@ export const getTableColumnsQuery = () => {
export type TableColumnsVariables = {
projectRef?: string
connectionString?: string
+ table?: string
}
export type TableColumnsData = { result: TableColumn[] }
export type TableColumnsError = unknown
export const useTableColumnsQuery = <TData extends TableColumnsData = TableColumnsData>(
- { projectRef, connectionString }: TableColumnsVariables,
+ { projectRef, connectionString, table }: TableColumnsVariables,
options: UseQueryOptions<ExecuteSqlData, TableColumnsError, TData> = {}
) => {
return useExecuteSqlQuery(
{
projectRef,
connectionString,
- sql: getTableColumnsQuery(),
+ sql: getTableColumnsQuery(table),
queryKey: ['table-columns'],
},
options
diff --git a/studio/pages/project/[ref]/sql/[id].tsx b/studio/pages/project/[ref]/sql/[id].tsx
index 538f48a21ca..1afc3c4ee53 100644
--- a/studio/pages/project/[ref]/sql/[id].tsx
+++ b/studio/pages/project/[ref]/sql/[id].tsx
@@ -1,17 +1,17 @@
+import { useMonaco } from '@monaco-editor/react'
import { useTheme } from 'common'
-import { useEffect, useRef } from 'react'
import { observer } from 'mobx-react-lite'
-import { useMonaco } from '@monaco-editor/react'
+import { useEffect, useRef } from 'react'
-import { NextPageWithLayout } from 'types'
-import { useFormatQueryMutation } from 'data/sql/format-sql-query'
-import { useKeywordsQuery } from 'data/database/keywords-query'
import { useFunctionsQuery } from 'data/database/functions-query'
+import { useKeywordsQuery } from 'data/database/keywords-query'
import { useSchemasQuery } from 'data/database/schemas-query'
import { useTableColumnsQuery } from 'data/database/table-columns-query'
+import { useFormatQueryMutation } from 'data/sql/format-sql-query'
+import { NextPageWithLayout } from 'types'
-import { SQLEditorLayout } from 'components/layouts'
import SQLEditor from 'components/interfaces/SQLEditor/SQLEditor'
+import { SQLEditorLayout } from 'components/layouts'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import getPgsqlCompletionProvider from 'components/ui/CodeEditor/Providers/PgSQLCompletionProvider'
import getPgsqlSignatureHelpProvider from 'components/ui/CodeEditor/Providers/PgSQLSignatureHelpProvider'