The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: replace publication recreate with update
Wen Bo Xie0a4cb3b3b854
diff --git a/docker/docker-compose.yml b/docker/docker-compose.ymlindex 82e500c45ed..7d041164e75 100644--- a/docker/docker-compose.yml+++ b/docker/docker-compose.yml@@ -155,7 +155,7 @@ services:meta:container_name: supabase-meta- image: supabase/postgres-meta:v0.50.2+ image: supabase/postgres-meta:v0.52.1depends_on:db: # Disable this if you are using an external Postgres databasecondition: service_healthydiff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.tsindex 62beb243a10..0e3e1bc3057 100644--- a/studio/stores/pgmeta/MetaStore.ts+++ b/studio/stores/pgmeta/MetaStore.ts@@ -35,7 +35,7 @@ import { ImportContent } from 'components/interfaces/TableGridEditor/SidePanelEdimport RolesStore, { IRolesStore } from './RolesStore'import PoliciesStore from './PoliciesStore'import TriggersStore from './TriggersStore'-import PublicationStore, { IPublicationStore } from './PublicationStore'+import PublicationStore from './PublicationStore'import FunctionsStore from './FunctionsStore'import HooksStore from './HooksStore'import ExtensionsStore from './ExtensionsStore'@@ -58,7 +58,7 @@ export interface IMetaStore {triggers: IPostgresMetaInterface<any>functions: IPostgresMetaInterface<any>extensions: IPostgresMetaInterface<any>- publications: IPublicationStore+ publications: IPostgresMetaInterface<any>types: IPostgresMetaInterface<any>projectRef?: string@@ -288,15 +288,21 @@ export default class MetaStore implements IMetaStore {}async updateTableRealtime(table: PostgresTable, enable: boolean) {+ let publicationUpdateErrorconst publications = this.publications.list()const publicTables = this.tables.list((table: PostgresTable) => table.schema === 'public')- const realtimePublication = publications.find((pub) => pub.name === 'supabase_realtime')+ let realtimePublication = publications.find((pub) => pub.name === 'supabase_realtime')if (realtimePublication === undefined) {- return this.rootStore.ui.setNotification({- category: 'error',- message: `Unable to update realtime for ${table.name}: Missing publication`,+ const { data: publication, error: publicationCreateError } = await this.publications.create({+ name: 'supabase_realtime',+ publish_insert: true,+ publish_update: true,+ publish_delete: true,+ tables: []})+ if (publicationCreateError) throw publicationCreateError+ realtimePublication = publication}const { id, tables: publicationTables } = realtimePublication@@ -309,7 +315,8 @@ export default class MetaStore implements IMetaStore {: publicTables.filter((t: any) => t.id !== table.id).map((t: any) => `${t.schema}.${t.name}`)- await this.publications.recreate(id, realtimeTables)+ const { error } = await this.publications.update(id, { tables: realtimeTables })+ publicationUpdateError = error} else {const isAlreadyEnabled = publicationTables.some((x: any) => x.id == table.id)@@ -329,9 +336,11 @@ export default class MetaStore implements IMetaStore {if (realtimeTables === null) returnconst payload = { id, tables: realtimeTables }- const { error: publicationsUpdateError } = await this.publications.update(id, payload)- if (publicationsUpdateError) throw publicationsUpdateError+ const { error } = await this.publications.update(id, payload)+ publicationUpdateError = error}++ if (publicationUpdateError) throw publicationUpdateError}async createColumn(diff --git a/studio/stores/pgmeta/PublicationStore.ts b/studio/stores/pgmeta/PublicationStore.tsindex c5c23b49004..b892d15057d 100644--- a/studio/stores/pgmeta/PublicationStore.ts+++ b/studio/stores/pgmeta/PublicationStore.ts@@ -1,11 +1,6 @@-import { ResponseError } from 'types'-import PostgresMetaInterface, { IPostgresMetaInterface } from '../common/PostgresMetaInterface'+import PostgresMetaInterface from '../common/PostgresMetaInterface'import { IRootStore } from '../RootStore'-export interface IPublicationStore extends IPostgresMetaInterface<any> {- recreate: (id: any) => Promise<Partial<any> | { error: ResponseError }>-}-export default class PublicationStore extends PostgresMetaInterface<any> {constructor(rootStore: IRootStore,@@ -17,28 +12,4 @@ export default class PublicationStore extends PostgresMetaInterface<any> {) {super(rootStore, dataUrl, headers, options)}-- /**- * Will recreate a publication.- * This is required if switching from "ALL TABLES" to individual tables.- */- async recreate(id: any, tables: string[] = []) {- let currentPublication = this.byId(id)- let payload: any = {- name: currentPublication.name,- publish_insert: currentPublication.publish_insert,- publish_update: currentPublication.publish_update,- publish_delete: currentPublication.publish_delete,- publish_truncate: currentPublication.publish_truncate,- }- if (currentPublication.tables === null) {- // Previously was "ALL TABLES"- payload.tables = tables- }- const deleted: any = await this.del(id)- if (deleted.error) {- return deleted // return error- }- return await this.create(payload)- }}