Skip to content

Added Copy Structure Buttons to DB page and Table Structure Page.#20277

Open
imlolman wants to merge 10 commits into
phpmyadmin:masterfrom
imlolman:master
Open

Added Copy Structure Buttons to DB page and Table Structure Page.#20277
imlolman wants to merge 10 commits into
phpmyadmin:masterfrom
imlolman:master

Conversation

@imlolman

@imlolman imlolman commented Apr 10, 2026

Copy link
Copy Markdown

Problem

Getting a database or table definition for AI, review, docs or other tools meant using Export or Show create for many objects. That’s slow and easy to get wrong when you only need readable DDL (including FKs), not data.

Why / approach

Add two one-click actions that call SHOW CREATE TABLE / SHOW CREATE VIEW on the server and copy the result to the clipboard, same information as “show create”, fewer steps.

This also makes it easy to share database structure with AI tools (for code generation, review, or debugging) without exposing any actual data, since only DDL is copied.

What’s in the PR

  • Database Structure: “Copy DB Structure” → all tables + views in the current DB as SQL text.
  • Table Structure: “Copy Table Structure” → current table/view DDL.
  • New POST routes, Twig buttons, TS handlers (clipboard API + fallback), routing test + service wiring.

Screenshots

Screenshot 2026-04-10 at 1 39 51 PM Screenshot 2026-04-10 at 1 40 15 PM

Fixes #

Signed-off-by: Satyam <satyam.gupta756@gmail.com>
Signed-off-by: Satyam <satyam.gupta756@gmail.com>
Signed-off-by: Satyam <satyam.gupta756@gmail.com>
Signed-off-by: Satyam <satyam.gupta756@gmail.com>
@codacy-production

codacy-production Bot commented Apr 10, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 60 complexity · 4 duplication

Metric Results
Complexity 60
Duplication 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes. Give us feedback

@williamdes williamdes added the Enhancement A feature request for improving phpMyAdmin label Apr 10, 2026
@williamdes

Copy link
Copy Markdown
Member

Hi @imlolman

I think this feature, thank you

Could you write tests for the two controllers please ?
There is quite some examples of tests for other controllers

Signed-off-by: Satyam <satyam.gupta756@gmail.com>
@imlolman

Copy link
Copy Markdown
Author

Hi @imlolman

I think this feature, thank you

Could you write tests for the two controllers please ? There is quite some examples of tests for other controllers

I've added tests and fixed the test error aswell.

@imlolman

Copy link
Copy Markdown
Author

Hey 👋, @williamdes Workflows pending approval, can you please approve.

Stop relying on Current::$database for copy-structure SQL; use validated
DatabaseName. Remove redundant selectDb from table copy controller and
align unit tests with response handling and DBI expectations.

Signed-off-by: Satyam <satyam.gupta756@gmail.com>
Remove redundant Response assertions; narrow JSON values with PHPUnit
assertions instead of casting mixed to string.

Signed-off-by: Satyam <satyam.gupta756@gmail.com>
Record PossiblyUnusedReturnValue for Response on both copy-structure
controllers, consistent with other InvocableController routes.

Signed-off-by: Satyam <satyam.gupta756@gmail.com>
@imlolman

Copy link
Copy Markdown
Author

Hey @williamdes lets merge this. Just curious, anything pending from my side?

@williamdes

Copy link
Copy Markdown
Member

Hey @williamdes lets merge this. Just curious, anything pending from my side?

Hi
It needs more eyes to review this
@MauricioFauth could you have a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement A feature request for improving phpMyAdmin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants