feat(sidebar): copy objects and duplicate a database across connections - #2567
Merged
Conversation
Base automatically changed from
refactor/share-database-endpoint-and-create-database-form
to
main
August 28, 2026 15:59
datlechin
force-pushed
the
feat/copy-objects-across-connections
branch
from
August 29, 2026 02:24
1fd2ef9 to
37e67d1
Compare
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
datlechin
marked this pull request as ready for review
August 29, 2026 02:30
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft for #2487. Do not merge yet: two independent Codex reviews returned no-ship verdicts, most
of what they found is fixed, and the list of what is not is at the bottom.
Stacked on #2566, which carries the shared
DatabaseEndpointand create-database-form refactorsthis needs. Review that one first.
What it does
Right-click a table, a view, a schema or a database in the sidebar and choose Copy To…, or
Duplicate Database… on a database row. Both are also in the Database menu. Choose structure,
data or both, read the script, then copy.
Rows stream: the source's
streamRowsfeeds batches straight into multi-row parameterized INSERTssized against the engine's bind-parameter ceiling, so the write side of a ten-million-row table
costs the same as a ten-row one.
Design
New
TablePro/Core/ObjectCopy/, reusing rather than duplicating:DatabaseEndpoint,DatabaseEndpointPickerCompareMetadataServiceSchemaSyncScriptBuilder,SourceObjectSyncBuilderForeignKeyTopologicalSortSQLStatementGeneratorExecutionGateThe piece both reviews said was missing is
ObjectCopyNamespace: the name an engine qualifies itsobjects with. It is the schema where the engine has schemas and the database where it does not,
because MySQL reports the database in
information_schema's schema column, so its foreign keys androutines come back qualified by it. Getting that wrong is what silently dropped every dependency
edge on MySQL and PostgreSQL and what made the same-namespace test that guards definition copying
compare nil against nil across two different databases.
The run is: create the database, tear down children-first and build parents-first in one pass, empty
what a data-only replace will append to, copy rows, then install triggers and materialized views.
Fixed after review 1 (30 findings, 21 P1)
The three destructive ones:
before the per-table transaction, so a failure rolled back only the inserts. It is now inside the
transaction, and it is a
DELETEwhenever rollback is promised, because TRUNCATE commitsimplicitly on engines without transactional DDL.
namespace.
Plus: FK dependency edges, cleanup ordering, triggers after data, Add-rows no longer replacing
definitions, foreign keys repointed at the copy, one-engine-only copies, routine signatures and
trigger owners in object identity, target column and table spellings, Duplicate gated on the
driver's create-database form, Oracle's one-row batches, rolled-back rows excluded from counts,
cancellation read as cancellation, the injected
DatabaseManagerused on both sides.Fixed after review 2 (29 findings, 14 P1)
database-level copy that named no schema, and the sidebar passes none. A database copy now
enumerates every schema and reads, orders and writes each in its own scope.
ObjectCopyNamespaceis theanswer.
dropObjectStatementreturns nil on the rawplugin for MySQL, PostgreSQL, SQL Server, SQLite, Oracle, DuckDB and Trino, so the CREATE ran
against the table still there. There is a quoted fallback now.
and with foreign key checks relaxed where it is not, so a stop between them cannot leave objects
dropped with nothing put back.
SELECTrather than itsCREATEhas that view left outrather than executed as a read and reported as copied.
PluginColumnInfo, which thesnapshot conversion drops.
counts survive a non-transactional stop,
selectAllunions rather than replaces, Duplicate in themenu bar keys on database switching rather than container switching, Copy To reaches hierarchical
schema rows, materialized views map to the right kind, structure-only plans skip row preparation.
Still open
These are why this is a draft:
SERIALsequences are not copied.fetchDependentSequencesexists and is notcalled, so a copied table's default names a sequence the target does not have.
streamRowsdefault, so a large table ismaterialised before the first batch. Gating properly needs a capability all 32 plugins declare.
Export has the same property today.
ON <table>, so replacing an overloadedPostgreSQL routine fails.
becomes an empty list, and the copy reports success having carried only tables.
them rather than publish them.
CopyObjectsUITestshas never run here. Both attempts died onTimed out while enabling automation mode, an unanswered macOS automation prompt. CI has to be the first real run.What I built and tested
verify.sh buildverify.sh test(12 suites)verify.sh lint TablePro TableProTests TableProUITestsdocs/scripts/check-writing-style.shdocs/scripts/check-docs-against-source.pyverify.sh uitest CopyObjectsUITestsverify.sh pluginsandverify.sh abiwere not run and are not needed: nothing underPlugins/changed.