feat(wizard): add Postgres backend question to setup wizard
setup_wizard.py 在 Step 3 (Execution) 之后新增一个 Database 问答: "Use Postgres? (y = postgres, n = sqlite)",默认 y(Stage 0+ 推荐 PG)。 选 y 时引导填 DATABASE_URL(可留空稍后写 .env);DATABASE_URL 进 .env, config.yaml 写入 database.backend=postgres + postgres_url=\$DATABASE_URL。 writer.py build_minimal_config 加 database_backend 参数,postgres 时 覆盖 base_config 的 database 段;默认 sqlite 时沿用 base_config 行为 (继承 config.example.yaml 的 sqlite_dir 等)。 minimal pattern:不新建 wizard/steps/database.py,inline 在 main 里加 1 问答 + writer 加 1 参数。后续如果需要更复杂数据库选项再升为完整 step 模块。 Stage 0 PR1 T1.8. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,33 @@ def main() -> int:
|
||||
|
||||
execution = run_execution_step(f"Step 3/{total_steps}")
|
||||
|
||||
# Database backend (Stage 0+ recommends Postgres; SQLite kept as
|
||||
# offline dev fallback). Inline question rather than a separate
|
||||
# wizard step — minimal addition, full step module can come later.
|
||||
print()
|
||||
print_header("Database backend")
|
||||
print("Stage 0+ recommends Postgres for parity with production.")
|
||||
print("SQLite is kept as an offline dev fallback.")
|
||||
print()
|
||||
use_postgres = ask_yes_no("Use Postgres? (y = postgres, n = sqlite)", default=True)
|
||||
database_backend = "postgres" if use_postgres else "sqlite"
|
||||
database_url: str | None = None
|
||||
if use_postgres:
|
||||
print()
|
||||
print_info(
|
||||
"Set DATABASE_URL in your .env file. Example:\n"
|
||||
" postgresql+asyncpg://deerflow:deerflow_dev@localhost:5432/deerflow\n"
|
||||
"Or for a remote RDS:\n"
|
||||
" postgresql+asyncpg://USER:PASS@HOST:5432/DB"
|
||||
)
|
||||
print()
|
||||
try:
|
||||
raw = input("DATABASE_URL (leave blank to set later in .env): ").strip()
|
||||
except EOFError:
|
||||
raw = ""
|
||||
if raw:
|
||||
database_url = raw
|
||||
|
||||
print_header(f"Step {total_steps}/{total_steps} · Writing configuration")
|
||||
|
||||
write_config_yaml(
|
||||
@@ -97,6 +124,7 @@ def main() -> int:
|
||||
allow_host_bash=execution.allow_host_bash,
|
||||
include_bash_tool=execution.include_bash_tool,
|
||||
include_write_tools=execution.include_write_tools,
|
||||
database_backend=database_backend,
|
||||
)
|
||||
print_success(f"Config written to: {config_path.relative_to(project_root)}")
|
||||
|
||||
@@ -113,6 +141,8 @@ def main() -> int:
|
||||
env_pairs[search_provider.env_var] = search_api_key
|
||||
if fetch_api_key and fetch_provider and fetch_provider.env_var:
|
||||
env_pairs[fetch_provider.env_var] = fetch_api_key
|
||||
if database_url:
|
||||
env_pairs["DATABASE_URL"] = database_url
|
||||
|
||||
if env_pairs:
|
||||
write_env_file(env_path, env_pairs)
|
||||
|
||||
Reference in New Issue
Block a user