The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix delete cascade setting in create table
Joshen Lim6084e0d39bfe
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsxindex 99cd71e1ff0..442fbc72dfe 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx@@ -181,10 +181,6 @@ const SidePanelEditor: FC<Props> = ({if (response?.error) {ui.setNotification({ category: 'error', message: response.error.message })} else {- ui.setNotification({- category: 'success',- message: isNewRecord ? `Successfully created column` : `Successfully updated column`,- })await meta.tables.loadById(selectedTable!.id)queryClient.invalidateQueries(sqlKeys.query(project?.ref, ['foreignKeyConstraints']))onColumnSaved(configuration.isEncrypted)diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsxindex a834c258255..86793b12e67 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/ColumnManagement.tsx@@ -23,12 +23,11 @@ import InformationBox from 'components/ui/InformationBox'import ForeignKeySelector from '../ForeignKeySelector/ForeignKeySelector'import { ImportContent } from './TableEditor.types'import { generateColumnField } from '../ColumnEditor/ColumnEditor.utils'-import { ColumnField } from '../SidePanelEditor.types'+import { ColumnField, ExtendedPostgresRelationship } from '../SidePanelEditor.types'import { TEXT_TYPES } from '../SidePanelEditor.constants'interface Props {table?: Partial<PostgresTable>- tables: PostgresTable[]columns?: ColumnField[]enumTypes: PostgresType[]importContent?: ImportContent@@ -40,7 +39,6 @@ interface Props {const ColumnManagement: FC<Props> = ({table,- tables = [],columns = [],enumTypes = [],importContent,@@ -57,24 +55,28 @@ const ColumnManagement: FC<Props> = ({(column: ColumnField) => column.isPrimaryKey)- const saveColumnForeignKey = (- foreignKeyConfiguration: { table: PostgresTable; column: PostgresColumn } | undefined- ) => {+ const saveColumnForeignKey = (foreignKeyConfiguration?: {+ table: PostgresTable+ column: PostgresColumn+ deletionAction: string+ }) => {if (!isUndefined(selectedColumnToEditRelation)) {onUpdateColumn(selectedColumnToEditRelation, {- foreignKey: !isUndefined(foreignKeyConfiguration)- ? {- id: 0,- constraint_name: '',- source_schema: table?.schema ?? '',- source_table_name: table?.name ?? '',- source_column_name: selectedColumnToEditRelation?.name,- target_table_schema: foreignKeyConfiguration.table.schema,- target_table_name: foreignKeyConfiguration.table.name,- target_column_name: foreignKeyConfiguration.column.name,- }- : undefined,- ...(!isUndefined(foreignKeyConfiguration) && {+ foreignKey:+ foreignKeyConfiguration !== undefined+ ? {+ id: 0,+ constraint_name: '',+ source_schema: table?.schema ?? '',+ source_table_name: table?.name ?? '',+ source_column_name: selectedColumnToEditRelation?.name,+ target_table_schema: foreignKeyConfiguration.table.schema,+ target_table_name: foreignKeyConfiguration.table.name,+ target_column_name: foreignKeyConfiguration.column.name,+ deletion_action: foreignKeyConfiguration.deletionAction,+ }+ : undefined,+ ...(foreignKeyConfiguration !== undefined && {format: foreignKeyConfiguration.column.format,defaultValue: null,}),@@ -91,8 +93,8 @@ const ColumnManagement: FC<Props> = ({changes.defaultValue = null}- if ('name' in changes && !isUndefined(column.foreignKey)) {- const foreignKey: PostgresRelationship = {+ if ('name' in changes && column.foreignKey !== undefined) {+ const foreignKey: ExtendedPostgresRelationship = {...column.foreignKey,source_column_name: changes?.name ?? '',}diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsxindex 5cd081391fe..175125e3588 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx@@ -263,7 +263,6 @@ const TableEditor: FC<Props> = ({{!isDuplicating && (<ColumnManagementtable={{ name: tableFields.name, schema: selectedSchema }}- tables={tables}columns={tableFields?.columns}enumTypes={enumTypes}isNewRecord={isNewRecord}diff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.tsindex 3a2ee0709ea..eb83b2367a8 100644--- a/studio/stores/pgmeta/MetaStore.ts+++ b/studio/stores/pgmeta/MetaStore.ts@@ -498,6 +498,10 @@ export default class MetaStore implements IMetaStore {const relation: any = await this.addForeignKey(foreignKey)if (relation.error) throw relation.error}+ this.rootStore.ui.setNotification({+ category: 'success',+ message: `Successfully updated column "${column.name}"`,+ })} catch (error: any) {return { error }}@@ -631,6 +635,7 @@ export default class MetaStore implements IMetaStore {// Then add the foreign key constraints herefor (const column of columns) {if (!isUndefined(column.foreignKey)) {+ console.log('Add foreign key', column)const relationship = await this.addForeignKey(column.foreignKey)if (relationship.error) throw relationship.error}