feat: add db-schema subcommand for exporting database schema SQL#26
feat: add db-schema subcommand for exporting database schema SQL#26cxhello wants to merge 8 commits intonacos-group:mainfrom
Conversation
Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Signed-off-by: cxhello <caixiaohuichn@gmail.com>
…dout/stderr separation Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Signed-off-by: cxhello <caixiaohuichn@gmail.com>
find_local_schema returns non-zero when no local schema file exists, which causes the script to abort under set -e before attempting the download fallback. Add || true to suppress the exit-on-error. Also register test_db_schema.sh in the test runner. Signed-off-by: cxhello <caixiaohuichn@gmail.com>
Nacos repository uses pg-schema.sql for PostgreSQL, not postgresql-schema.sql. Add _schema_filename() mapping function and update local/remote lookup to use actual filenames. Signed-off-by: cxhello <caixiaohuichn@gmail.com>
|
cool,is it compatible with Windows? Verify that full init SQL and incremental schema-change SQL can be output to a local temp folder, with the matching commands printed in the terminal; DBs: cover PostgreSQL and MySQL |
Port db-schema subcommand to Windows PowerShell, mirroring the bash implementation. Includes schema filename mapping (pg-schema.sql for PostgreSQL), local/cache/remote resolution, and interactive prompts. Tested with pwsh 7.6.0 on macOS. Signed-off-by: cxhello <caixiaohuichn@gmail.com>
|
Thanks for the review! Windows compatibility: Added in the latest commit ( Incremental schema-change SQL: Not included in this PR. Nacos upstream doesn't provide versioned migration SQL files — only full schema per release. Generating reliable ALTER statements from diffing two full schemas is error-prone (can't handle renames, data migrations, etc.). Happy to revisit if Nacos adds official migration scripts in the future. Output to temp folder with commands: Currently outputs to stdout for pipe-friendly usage ( |
Summary
nacos-setup db-schemasubcommand to export full database schema SQL for a given Nacos versionpg-schema.sqlfor PostgreSQL)[ -t 0 ]detection)Closes #25 (Part B)
Usage
Test plan
tests/test_db_schema.sh)