feat: add schema dump command for AI database discovery#28
Merged
Conversation
- Add {"ok":false,"schema_version":1,"error":{"code":"XSQL_INTERNAL","message":"unknown command \"schema\" for \"xsql\""}} command to export database structure
- Support MySQL and PostgreSQL schema extraction
- Output includes tables, columns, indexes, and foreign keys
- Support table name filtering with wildcards
- Add JSON/YAML/Table output formats
- Add unit tests and E2E tests
- Update documentation (cli-spec.md, ai.md)
- Add RFC 0005 for design documentation
This allows AI agents to automatically discover database schema
without manual intervention.
- Add schema dump to README command list - Add schema discovery section with examples - Update AI skill prompt to include schema dump - Add schema dump to tool spec export
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
==========================================
+ Coverage 79.02% 80.76% +1.74%
==========================================
Files 32 36 +4
Lines 1864 2392 +528
==========================================
+ Hits 1473 1932 +459
- Misses 326 357 +31
- Partials 65 103 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
- Run goimports on schema files - Remove unused matchPattern functions
|
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.


概述
新增
xsql schema dump命令,导出数据库结构信息(表、列、类型、约束、索引),供 AI/agent 自动理解数据库 schema。变更内容
新增功能
xsql schema dump命令,支持导出数据库结构*和?)文件变更
internal/db/schema.gointernal/db/mysql/schema.gointernal/db/pg/schema.gocmd/xsql/schema.gointernal/output/writer.gointernal/app/app.godocs/rfcs/0005-schema-dump.mddocs/cli-spec.mddocs/ai.mdREADME.md测试
internal/db/schema_test.gotests/e2e/schema_test.go(8 个测试用例)使用示例
输出示例
{ "ok": true, "schema_version": 1, "data": { "database": "mydb", "tables": [ { "schema": "public", "name": "users", "columns": [ {"name": "id", "type": "bigint", "primary_key": true}, {"name": "email", "type": "varchar(255)", "nullable": false} ] } ] } }相关文档
docs/rfcs/0005-schema-dump.mddocs/cli-spec.mddocs/ai.md