The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(pg-meta): require replica_identity_index when replica_identity is INDEX (#45019)
Akash Santraa8de56aec262
diff --git a/packages/pg-meta/src/pg-meta-tables.ts b/packages/pg-meta/src/pg-meta-tables.tsindex c6616ea54d4..407003ee0d8 100644--- a/packages/pg-meta/src/pg-meta-tables.ts+++ b/packages/pg-meta/src/pg-meta-tables.ts@@ -216,6 +216,9 @@ function update(if (replica_identity === undefined) {// skip} else if (replica_identity === 'INDEX') {+ if (!replica_identity_index) {+ throw new Error('replica_identity_index is required when replica_identity is INDEX')+ }replicaSql = safeSql`${alter} REPLICA IDENTITY USING INDEX ${ident(replica_identity_index)};`} else {replicaSql = safeSql`${alter} REPLICA IDENTITY ${keyword(replica_identity)};`diff --git a/packages/pg-meta/test/tables.test.ts b/packages/pg-meta/test/tables.test.tsindex 0f1868195eb..9f13f67cb9c 100644--- a/packages/pg-meta/test/tables.test.ts+++ b/packages/pg-meta/test/tables.test.ts@@ -1079,6 +1079,12 @@ withTestDatabase('update table - replica identity', async ({ executeQuery }) =>expect(res!.replica_identity).toBe('NOTHING')})+withTestDatabase('update table - replica identity INDEX requires index name', async () => {+ expect(() =>+ pgMeta.tables.update({ id: 1, name: 'test', schema: 'public' }, { replica_identity: 'INDEX' })+ ).toThrow('replica_identity_index is required')+})+withTestDatabase('update table - primary keys', async ({ executeQuery }) => {// Create test table with a columnconst { sql: createSql } = await pgMeta.tables.create({ name: 'test_pk' })