Repository navigation
feat(connections): create and edit a PostgreSQL schema, with owner and privileges - #2917
Conversation
… revoke means what it says
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Signed-off-by: Ngô Quốc Đạt <[email protected]>
…e privileges table and a pinned footer
UI revamp of the schema sheetThe first cut of the sheet was wrong in a way a diff cannot show, so here is what changed and why. The defect behind the dead checkboxes
granted.contains(privilege) ? revocable.contains(privilege) : trueTicking an empty box moved the privilege into Editability is a fact about the server's ACL, so it is now read once at load into LayoutThe old sheet was a fixed 520x620 with three sections that each stretched, so the fields clustered at the top and left two dead zones. Now:
The privileges control
That API is macOS 14.4, so this raises the app's minimum from macOS 14.0 to 14.4 ( Verified on the rebased treeBuild PASS ( Not verifiedNo screenshots. I stood up a throwaway PostgreSQL 17 cluster with roles, grants and a commented schema, launched the Debug build against a sandboxed store, and did get one clean capture confirming the new sheet renders correctly: native blue checkboxes, real A reliable light/dark pair was not possible. Another process on this machine repeatedly launched its own TablePro copy and fired One thing that needs a second look when the shots are taken: in that single capture a brand-new schema showed two grantee rows with every box ticked. |
Fixes #2908
What was wrong
TablePro's container lifecycle is complete for databases and half-built for schemas, and the half that exists is reachable from one of its three surfaces.
PluginDatabaseDriver.createSchemaStatement(name:)existed but was an object-copy helper with a single caller (ObjectCopyPlanner.swift:136), took no owner, and no UI reached it. There was nocreateSchemaFormSpec/createSchemapair mirroring the database ones.PluginPrivilegeScope.schemaandPluginPrivilegeCatalog.schemaPrivilegesalready modelled schema grants and PostgreSQL already emittedGRANT … ON SCHEMA, but only through Users & Roles: there was no "who has what on this schema" read.DatabaseSwitcherPopoverhardcodedshowsCreateRow = supportsCreateDatabase && switchTarget == .database, so schema mode could never create, and the.flatsidebar shape has no schema row at all.authorizeRenamecalledExecutionGateProvider. Drop and Create Database called the driver directly, so Safe Mode's Alert and Touch ID tiers never fired and no audit record was written for the two operations that destroy the most.The fix
Container DDL gets one owner,
DatabaseManager+ContainerDDL, in the shapeDatabaseManager+Principals.executePrincipalChangesalready uses: generate statements, derive the operation kind from those statements, authorize throughExecutionGateProvider, execute on the schema-change route, record query history, post theCatalogEvent. Create-schema, edit-schema, create-database and drop-container all route through it.The driver side moves from opaque execute to statement generation, which is what makes the sheet's preview byte-for-byte what runs and is the genre convention (DataGrip, pgAdmin and TablePlus all show generated SQL before a structure change).
Four additive
PluginDatabaseDriverrequirements, threeDriverPlugincapability statics, and three new transfer types. The ABI diff is additive: zero symbols removed, every addition carries a default.currentPluginKitVersionstays at the pending 31.git show v0.74.0:…/PluginManager.swiftreports 30 and HEAD reports 31, so this cycle's bump already landed and CLAUDE.md's once-per-cycle rule says to reuse it. All 40 bundled plists already carry 31. No registry re-release needed.Native design
New %@…/Edit %@…, nouns fromschemaEntityName, so BigQuery reads "New Dataset…". Ellipses because both open a sheet that needs more before it can complete, which is the HIG's rule.SQLReviewSheetwas out; its renderer is now the sharedSQLStatementPreviewso the two cannot drift.Grid, not aTable: the privilege set is the engine's andTableColumnForEachis macOS 14.4, past our 14.0 target.DatabaseType.Engine coverage
Create + owner + privileges on PostgreSQL and PGlite; create + owner on Redshift and CockroachDB, which change an owner but cannot introspect a schema ACL (
aclexplodeis 8.4 and Redshift forked at 8.0.2). Oracle, SQL Server, Snowflake, Trino, DuckDB, BigQuery, Spanner and SurrealDB declare nothing and offer nothing: a schema on Oracle is a user, and T-SQL'sALTER SCHEMAis a transfer, not a rename.Also fixed, because the primary change is unsafe without them
confirmationPreClearedso the sidebar's own dialog is not doubled.supportsDropSchemawith nothing behind it.dropSchemasat onPostgreSQLPluginDriver, a sibling of those classes rather than their superclass, so the menu item threw a raw EnglishNSError.LibPQDriverCore.swift:223already documents this exact rule forrenameTable. MovingdropSchemaandcreateSchemaStatementto the protocol extension also restores theCREATE SCHEMAsteps that Duplicate Database silently dropped on those engines.CASCADE.dropsDependentObjectswasisSchema; SQL Server and BigQuery refuse a non-empty schema outright, so the confirmation stated something the engine could not do. It now readssupportsCascadeDrop.CatalogEditAdoption.adoptContainerDropreturned before the recents cleanup for anything but a database.Review
Two Codex passes read the diff cold and found fifteen findings between them. Every one was verified against the source and fixed; the ones worth naming, because they are the traps in this area:
REVOKEremoves only what the executing role granted. Two roles grantingUSAGEto the same grantee produce two ACL entries, so unchecking one box removed one entry, left the other in force, and reported success.PluginSchemaGrantnow carries the grantor, a cell is editable only where the connected role is the sole grantor, and the rest show checked and dimmed.public. Deciding the pseudo-group by string comparison rendered a grant to that role asTO PUBLICand handed it to every user on the server. Grantee kind is now a@frozen PluginSchemaGranteederived from the ACL's grantee id, which is zero only for the group.REVOKEthe preview never showed. Dirtiness is now derived by comparing against the loaded baseline.BEGINon a shared session driver joins the user's open transaction. PostgreSQL has no nested transaction, so theCOMMITwould have taken a query tab's uncommitted writes with it and a rollback would have discarded them. PGlite is non-poolable and always lands there. The plan is now wrapped only on a pooled lease.CREATEorRENAMEcan land before a later statement fails; a retry reissued it. The service reports the committed count and the editor rebases onto what committed.LATERALis PostgreSQL 9.3. The ACL read now uses the set-returning-function-in-subquery formPostgreSQLPrincipalQueries.schemaGrantsalready uses, which older servers accept.Verified
build.analysis/feat-schema-management/logs/build-TablePro-134250.logtest(16 suites)logs/test-SchemaEditEligibilityTests-134347.logPostgreSQLDriverschemeabivs merge baselint --strictdocsplugins(AllPlugins)unknown attribute 'usableFromInlinenonisolated'in a@TaskLocalmacro expansion inside the vendoredoracle-niocheckout. Unrelated to this change; the PostgreSQL target builds clean.New tests:
PostgreSQLSchemaStatementPlannerTests(statement text, quoting ofmy"schemaanda; DROP SCHEMA public, the grantor gate, PUBLIC vs a role namedpublic, the pgAdmin #5926 untouched-grantee guard),SchemaFormRulesTests,SchemaEditEligibilityTests,RecentTablesStoreSchemaClearTests, six newDatabaseTreeMenuSpecTestscases, and the cascade-promise case inDatabaseDropRequestTests.Not verified
TableProUITests/SchemaManagementMenuUITestsdid not execute locally. The runner fails to initialize withTimed out while enabling automation mode.before any test code runs. This is environmental, not this change: a pre-existing suite (AuxiliaryWindowCloseUITests) fails identically on this machine, across three attempts and after clearingtestmanagerd. The suite asserts the negative half of the capability contract on SQLite, where no schema exists; it will run in CI.The positive UI path needs a live PostgreSQL and does not run deterministically, so it is covered by the unit suites above rather than by automation.
No screenshots. The sheet needs a live PostgreSQL connection to render with roles and privileges, and this machine's UI automation is not initializing, so a driven capture was not possible. The two new sheets and the menu items are unphotographed and the
docs/pages describing them carry no<Frame>yet; both need a capture pass on a machine with a working runner.