AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Table Editor Non-Atomic Schema Mutations Cause Partial Application On Failure

Multiple schema changes in Table Editor actions are executed as independent awaited calls without a surrounding transaction, so if a later step fails, earlier changes remain committed, leaving the database in an inconsistent state. The issue also notes unawaited async operations in duplicateTable.

highConfidence 85%React

Origin Analysis

Functions like createColumn, updateColumn, updateTable, and duplicateTable perform multiple separate database mutations sequentially. Each mutation may commit its own transaction (due to pg-meta helper BEGIN/COMMIT), and there is no outer transaction to roll back all steps if one fails. Additionally, identityColumns.map(async ...) is not awaited, allowing async identity updates to continue after the function returns.
1. In Studio Table Editor, create a new column with primary key and foreign key constraints. 2. Introduce an error in the foreign key definition (e.g., reference a non-existent table). 3. Observe that the column is created but the UI reports an error, leaving the column without the intended constraints. Similar failures occur when updating a table or duplicating a table with identity columns.

Fixing Code Block

Edge Case Audit

This hotfix only addresses the unawaited async in duplicateTable. The main atomicity issue for createColumn, updateColumn, and updateTable remains. If you only apply this hotfix, schema changes can still be partially applied. Test thoroughly before relying on this; a full transaction refactor is recommended. Rollback this patch if it causes performance issues with many identity columns, as Promise.all may increase concurrency.

Ecosystem Topology