The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Rename FOREIGN_KEY_DELETION_ACTION to FOREIGN_KEY_CASCADE_ACTION
Joshen Lim8f7ba1fdc568
diff --git a/studio/components/grid/components/grid/ColumnHeader.tsx b/studio/components/grid/components/grid/ColumnHeader.tsxindex decdda4da38..4ba3545b2c0 100644--- a/studio/components/grid/components/grid/ColumnHeader.tsx+++ b/studio/components/grid/components/grid/ColumnHeader.tsx@@ -7,7 +7,7 @@ import { useDispatch } from '../../store'import { ColumnHeaderProps, ColumnType, DragItem, GridForeignKey } from '../../types'import { ColumnMenu } from '../menu'import { useTrackedState } from '../../store'-import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'+import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'import { getForeignKeyDeletionAction } from 'components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils'export function ColumnHeader<R>({@@ -207,7 +207,7 @@ function renderColumnIcon({foreignKey?.targetColumnName}</p></div>- {foreignKey?.deletionAction !== FOREIGN_KEY_DELETION_ACTION.NO_ACTION && (+ {foreignKey?.deletionAction !== FOREIGN_KEY_CASCADE_ACTION.NO_ACTION && (<p className="text-xs text-scale-1200 mt-1">On delete: {getForeignKeyDeletionAction(foreignKey?.deletionAction)}</p>diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.tsindex 98c92be6f42..aef2c4b48b3 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts@@ -14,7 +14,7 @@ import {ExtendedPostgresRelationship,UpdateColumnPayload,} from '../SidePanelEditor.types'-import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'+import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'import { ForeignKeyConstraint } from 'data/database/foreign-key-constraints-query'const isSQLExpression = (input: string) => {@@ -231,7 +231,7 @@ export const getColumnForeignKey = (const foreignKeyMeta = foreignKeys.find((fk) => fk.id === foreignKey.id)return {...foreignKey,- deletion_action: foreignKeyMeta?.deletion_action ?? FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletion_action: foreignKeyMeta?.deletion_action ?? FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,}}}@@ -244,13 +244,13 @@ const formatArrayToPostgresArray = (arrayString: string) => {export const getForeignKeyDeletionAction = (deletionAction?: string) => {switch (deletionAction) {- case FOREIGN_KEY_DELETION_ACTION.CASCADE:+ case FOREIGN_KEY_CASCADE_ACTION.CASCADE:return 'Cascade'- case FOREIGN_KEY_DELETION_ACTION.RESTRICT:+ case FOREIGN_KEY_CASCADE_ACTION.RESTRICT:return 'Restrict'- case FOREIGN_KEY_DELETION_ACTION.SET_DEFAULT:+ case FOREIGN_KEY_CASCADE_ACTION.SET_DEFAULT:return 'Set default'- case FOREIGN_KEY_DELETION_ACTION.SET_NULL:+ case FOREIGN_KEY_CASCADE_ACTION.SET_NULL:return 'Set NULL'default:return undefineddiff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.constants.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.constants.tsindex 411938bbc4e..6cfa9b617ca 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.constants.ts+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.constants.ts@@ -1,9 +1,9 @@-import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'+import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'export const FOREIGN_KEY_DELETION_OPTIONS = [- { key: 'no-action', label: 'No action', value: FOREIGN_KEY_DELETION_ACTION.NO_ACTION },- { key: 'cascade', label: 'Cascade', value: FOREIGN_KEY_DELETION_ACTION.CASCADE },- { key: 'restrict', label: 'Restrict', value: FOREIGN_KEY_DELETION_ACTION.RESTRICT },- { key: 'set-default', label: 'Set default', value: FOREIGN_KEY_DELETION_ACTION.SET_DEFAULT },- { key: 'set-null', label: 'Set NULL', value: FOREIGN_KEY_DELETION_ACTION.SET_NULL },+ { key: 'no-action', label: 'No action', value: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION },+ { key: 'cascade', label: 'Cascade', value: FOREIGN_KEY_CASCADE_ACTION.CASCADE },+ { key: 'restrict', label: 'Restrict', value: FOREIGN_KEY_CASCADE_ACTION.RESTRICT },+ { key: 'set-default', label: 'Set default', value: FOREIGN_KEY_CASCADE_ACTION.SET_DEFAULT },+ { key: 'set-null', label: 'Set NULL', value: FOREIGN_KEY_CASCADE_ACTION.SET_NULL },]diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsxindex 477252ef4eb..fd5421646fb 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx@@ -15,7 +15,7 @@ import {} from 'ui'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 { useStore } from 'hooks'import ActionBar from '../ActionBar'import { ColumnField } from '../SidePanelEditor.types'@@ -45,7 +45,7 @@ const ForeignKeySelector = ({schema: 'public',table: '',column: '',- deletionAction: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletionAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,})const schemas = meta.schemas.list()@@ -84,7 +84,7 @@ const ForeignKeySelector = ({schema: 'public',table: '',column: '',- deletionAction: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletionAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,})}}@@ -96,7 +96,7 @@ const ForeignKeySelector = ({schema,table: '',column: '',- deletionAction: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletionAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,}setSelectedForeignKey(updatedForeignKey)}@@ -108,7 +108,7 @@ const ForeignKeySelector = ({schema: '',table: '',column: '',- deletionAction: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletionAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,})}const table = find(tables, { id: tableId })@@ -120,7 +120,7 @@ const ForeignKeySelector = ({schema: table.schema,table: table.name,column: primaryColumn ?? firstColumn,- deletionAction: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletionAction: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,})}}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.utils.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.utils.tsxindex 1e5a32085d2..42632668542 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.utils.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.utils.tsx@@ -1,5 +1,5 @@import * as Tooltip from '@radix-ui/react-tooltip'-import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'+import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'import { IconHelpCircle } from 'ui'import { getForeignKeyDeletionAction } from '../ColumnEditor/ColumnEditor.utils'@@ -7,7 +7,7 @@ export const generateDeletionActionDescription = (deletionAction: string, refereconst actionName = getForeignKeyDeletionAction(deletionAction) ?? 'No action'switch (deletionAction) {- case FOREIGN_KEY_DELETION_ACTION.NO_ACTION:+ case FOREIGN_KEY_CASCADE_ACTION.NO_ACTION:return (<><span className="text-scale-1100">{actionName}</span>: Deleting a record from{' '}@@ -16,7 +16,7 @@ export const generateDeletionActionDescription = (deletionAction: string, refereexisting in this table that reference it</>)- case FOREIGN_KEY_DELETION_ACTION.CASCADE:+ case FOREIGN_KEY_CASCADE_ACTION.CASCADE:return (<><span className="text-scale-1100">{actionName}</span>: Deleting a record from{' '}@@ -25,7 +25,7 @@ export const generateDeletionActionDescription = (deletionAction: string, refereit in this table</>)- case FOREIGN_KEY_DELETION_ACTION.RESTRICT:+ case FOREIGN_KEY_CASCADE_ACTION.RESTRICT:return (<><span className="text-scale-1100">{actionName}</span>@@ -55,7 +55,7 @@ export const generateDeletionActionDescription = (deletionAction: string, referereferencing rows from this table.</>)- case FOREIGN_KEY_DELETION_ACTION.SET_DEFAULT:+ case FOREIGN_KEY_CASCADE_ACTION.SET_DEFAULT:return (<><span className="text-scale-1100">{actionName}</span>: Deleting a record from{' '}@@ -64,7 +64,7 @@ export const generateDeletionActionDescription = (deletionAction: string, refere<span className="text-amber-900 opacity-75">default value</span></>)- case FOREIGN_KEY_DELETION_ACTION.SET_NULL:+ case FOREIGN_KEY_CASCADE_ACTION.SET_NULL:return (<><span className="text-scale-1100">{actionName}</span>: Deleting a record from{' '}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsxindex bce6adb9488..cf1a706457f 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx@@ -12,7 +12,7 @@ import {Popover,} from 'ui'-import { FOREIGN_KEY_DELETION_ACTION } from 'data/database/database-query-constants'+import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'import { noop } from 'lodash'import { typeExpressionSuggestions } from '../ColumnEditor/ColumnEditor.constants'import { Suggestion } from '../ColumnEditor/ColumnEditor.types'@@ -127,8 +127,7 @@ const Column = ({{column.foreignKey.target_table_name}.{column.foreignKey.target_column_name}</p></div>- {column.foreignKey.deletion_action !==- FOREIGN_KEY_DELETION_ACTION.NO_ACTION && (+ {column.foreignKey.deletion_action !== FOREIGN_KEY_CASCADE_ACTION.NO_ACTION && (<p className="text-xs text-scale-1200 mt-1">On delete: {getForeignKeyDeletionAction(column.foreignKey.deletion_action)}</p>diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsxindex 3f73c419617..70f71cbb0ab 100644--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx@@ -17,7 +17,7 @@ import {import { ERROR_PRIMARY_KEY_NOTFOUND } from 'components/grid/constants'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'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,@@ -225,7 +225,7 @@ const TableGridEditor = ({)return {...relationship,- deletion_action: relationshipMeta?.deletion_action ?? FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletion_action: relationshipMeta?.deletion_action ?? FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,}})diff --git a/studio/data/database/database-query-constants.ts b/studio/data/database/database-query-constants.tsindex 2a98e85be0e..31b677d87d9 100644--- a/studio/data/database/database-query-constants.ts+++ b/studio/data/database/database-query-constants.ts@@ -2,7 +2,7 @@ import minify from 'pg-minify'// https://www.postgresql.org/docs/current/catalog-pg-constraint.html-export enum FOREIGN_KEY_DELETION_ACTION {+export enum FOREIGN_KEY_CASCADE_ACTION {NO_ACTION = 'a',RESTRICT = 'r',CASCADE = 'c',diff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.tsindex 38bef8423ea..b859c06d116 100644--- a/studio/stores/pgmeta/MetaStore.ts+++ b/studio/stores/pgmeta/MetaStore.ts@@ -45,7 +45,7 @@ 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 { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'const BATCH_SIZE = 1000const CHUNK_SIZE = 1024 * 1024 * 0.1 // 0.1MB@@ -304,13 +304,13 @@ export default class MetaStore implements IMetaStore {async addForeignKey(relationship: ExtendedPostgresRelationship) {const { deletion_action } = relationshipconst deletionAction =- deletion_action === FOREIGN_KEY_DELETION_ACTION.CASCADE+ deletion_action === FOREIGN_KEY_CASCADE_ACTION.CASCADE? 'ON DELETE CASCADE'- : deletion_action === FOREIGN_KEY_DELETION_ACTION.RESTRICT+ : deletion_action === FOREIGN_KEY_CASCADE_ACTION.RESTRICT? 'ON DELETE RESTRICT'- : deletion_action === FOREIGN_KEY_DELETION_ACTION.SET_DEFAULT+ : deletion_action === FOREIGN_KEY_CASCADE_ACTION.SET_DEFAULT? 'ON DELETE SET DEFAULT'- : deletion_action === FOREIGN_KEY_DELETION_ACTION.SET_NULL+ : deletion_action === FOREIGN_KEY_CASCADE_ACTION.SET_NULL? 'ON DELETE SET NULL': ''@@ -562,7 +562,7 @@ export default class MetaStore implements IMetaStore {const relation = await this.rootStore.meta.addForeignKey({...relationship,source_table_name: duplicatedTableName,- deletion_action: FOREIGN_KEY_DELETION_ACTION.NO_ACTION,+ deletion_action: FOREIGN_KEY_CASCADE_ACTION.NO_ACTION,})if (relation.error) throw relation.error})