The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Merge branch 'master' into chore/remove-pg-meta-schema-store
Alaister Young63b568a47267
diff --cc studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsxindex 702cfa3f3b4,df17d3f14e7..ff06e68fd95--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx@@@ -1,19 -1,27 +1,29 @@@import type { PostgresColumn, PostgresSchema, PostgresTable } from '@supabase/postgres-meta'--import { Dictionary } from 'components/grid'import { find, get, isEmpty, sortBy } from 'lodash'import { useEffect, useState } from 'react'- import { IconDatabase, IconHelpCircle, Input, Listbox, SidePanel } from 'ui'+++import { Dictionary } from 'components/grid'+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'+import InformationBox from 'components/ui/InformationBox'- import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'++import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'+import { useSchemasQuery } from 'data/database/schemas-query'+import { useTablesQuery } from 'data/tables/tables-query'+ import {+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ IconAlertTriangle,+ IconDatabase,+ IconHelpCircle,+ Input,+ Listbox,+ SidePanel,+ } from 'ui'--import InformationBox from 'components/ui/InformationBox'-import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'-import { useStore } from 'hooks'import ActionBar from '../ActionBar'import { ColumnField } from '../SidePanelEditor.types'- import { FOREIGN_KEY_DELETION_OPTIONS } from './ForeignKeySelector.constants'+ import { FOREIGN_KEY_CASCADE_OPTIONS } from './ForeignKeySelector.constants'import { ForeignKey } from './ForeignKeySelector.types'- import { generateDeletionActionDescription } from './ForeignKeySelector.utils'+ import { generateCascadeActionDescription } from './ForeignKeySelector.utils'interface ForeignKeySelectorProps {column: ColumnField@@@ -37,18 -52,14 +54,19 @@@ const ForeignKeySelector = (schema: 'public',table: '',column: '',- deletionAction: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletionAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,+ updateAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,})- const schemas = meta.schemas.list()- const tables = meta.tables.list(- (table: PostgresTable) => table.schema === selectedForeignKey.schema- )+ const { data: schemas } = useSchemasQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ })+ const { data: tables } = useTablesQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ schema: selectedForeignKey.schema,+ })const foreignKey = column?.foreignKeyconst selectedTable: PostgresTable | undefined = find(tables, {diff --cc studio/components/interfaces/TableGridEditor/TableGridEditor.tsxindex 22db3524264,70f71cbb0ab..5f62aaafe73--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx@@@ -16,9 -16,8 +16,9 @@@ import} from 'components/grid'import { ERROR_PRIMARY_KEY_NOTFOUND } from 'components/grid/constants'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'+import Connecting from 'components/ui/Loading/Loading'import TwoOptionToggle from 'components/ui/TwoOptionToggle'- import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'+ import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'import {ForeignKeyConstraint,useForeignKeyConstraintsQuery,@@@ -176,18 -218,17 +176,18 @@@ const TableGridEditor = (// [Joshen] We can tweak below to eventually support composite keys as the data// returned from foreignKeyMeta should be easy to deal with, rather than pg-meta- const formattedRelationships = (selectedTable?.relationships ?? []).map(- (relationship: PostgresRelationship) => {- const relationshipMeta = foreignKeyMeta.find(- (fk: ForeignKeyConstraint) => fk.id === relationship.id- )- return {- ...relationship,- deletion_action: relationshipMeta?.deletion_action ?? FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,- }+ const formattedRelationships = (+ ('relationships' in selectedTable && selectedTable.relationships) ||+ []+ ).map((relationship: PostgresRelationship) => {+ const relationshipMeta = foreignKeyMeta.find(+ (fk: ForeignKeyConstraint) => fk.id === relationship.id+ )+ return {+ ...relationship,- deletion_action: relationshipMeta?.deletion_action ?? FOREIGN_KEY_DELETION_ACTION.NO_ACTION,++ deletion_action: relationshipMeta?.deletion_action ?? FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,}- )+ })const gridTable =!isViewSelected && !isForeignTableSelecteddiff --cc studio/stores/pgmeta/MetaStore.tsindex 4fdcb8f17d7,d62d39c278b..b57d818bf49--- a/studio/stores/pgmeta/MetaStore.ts+++ b/studio/stores/pgmeta/MetaStore.ts@@@ -1,54 -1,51 +1,54 @@@--import Papa from 'papaparse'- import { makeObservable } from 'mobx'-import { makeObservable, observable } from 'mobx'--import { find, isUndefined, isEqual, isEmpty, chunk } from 'lodash'import { Query } from 'components/grid/query/Query'++import { chunk, find, isEmpty, isEqual, isUndefined } from 'lodash'++import { makeObservable } from 'mobx'++import Papa from 'papaparse'import type {PostgresColumn,-- PostgresTable,-- PostgresRelationship,PostgresPrimaryKey,- PostgresSchema,++ PostgresRelationship,++ PostgresTable,} from '@supabase/postgres-meta'--import { IS_PLATFORM, API_URL } from 'lib/constants'import { post } from 'lib/common/fetch'++import { API_URL, IS_PLATFORM } from 'lib/constants'import { timeout, tryParseJson } from 'lib/helpers'import { ResponseError } from 'types'import { IRootStore } from '../RootStore'++import { IPostgresMetaInterface } from '../common/PostgresMetaInterface'import ColumnStore from './ColumnStore'-import SchemaStore from './SchemaStore'--import TableStore, { ITableStore } from './TableStore'import OpenApiStore, { IOpenApiStore } from './OpenApiStore'--import { IPostgresMetaInterface } from '../common/PostgresMetaInterface'++import TableStore, { ITableStore } from './TableStore'++import {++ generateCreateColumnPayload,++ generateUpdateColumnPayload,++} from 'components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils'import {ColumnField,CreateColumnPayload,ExtendedPostgresRelationship,UpdateColumnPayload,} from 'components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.types'--import {-- generateCreateColumnPayload,-- generateUpdateColumnPayload,--} from 'components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils'import { ImportContent } from 'components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.types'--import RolesStore, { IRolesStore } from './RolesStore'--import PoliciesStore from './PoliciesStore'--import TriggersStore from './TriggersStore'--import PublicationStore from './PublicationStore'++import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'++import { getCachedProjectDetail } from 'data/projects/project-detail-query'++import { getQueryClient } from 'data/query-client'++import { tableKeys } from 'data/tables/keys'++import { getTable } from 'data/tables/table-query'++import { getTables } from 'data/tables/tables-query'++import ExtensionsStore from './ExtensionsStore'++import ForeignTableStore, { IForeignTableStore } from './ForeignTableStore'import FunctionsStore from './FunctionsStore'import HooksStore from './HooksStore'--import ExtensionsStore from './ExtensionsStore'++import MaterializedViewStore, { IMaterializedViewStore } from './MaterializedViewStore'++import PoliciesStore from './PoliciesStore'++import PublicationStore from './PublicationStore'++import RolesStore, { IRolesStore } from './RolesStore'++import TriggersStore from './TriggersStore'import TypesStore from './TypesStore'--import ForeignTableStore, { IForeignTableStore } from './ForeignTableStore'import ViewStore, { IViewStore } from './ViewStore'--import MaterializedViewStore, { IMaterializedViewStore } from './MaterializedViewStore'- import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'- import { getQueryClient } from 'data/query-client'- import { tableKeys } from 'data/tables/keys'- import { getTables } from 'data/tables/tables-query'- import { getTable } from 'data/tables/table-query'- import { getCachedProjectDetail } from 'data/projects/project-detail-query'-import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'const BATCH_SIZE = 1000const CHUNK_SIZE = 1024 * 1024 * 0.1 // 0.1MB