feat(config): verify DB connection before saving set-db
Some checks failed
Secrets CLI - Build & Release / 版本 & Release (push) Successful in 2s
Secrets CLI - Build & Release / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Secrets CLI - Build & Release / Build (aarch64-apple-darwin) (push) Has been cancelled
Secrets CLI - Build & Release / Build (x86_64-pc-windows-msvc) (push) Has been cancelled
Secrets CLI - Build & Release / 发布草稿 Release (push) Has been cancelled
Secrets CLI - Build & Release / 质量检查 (fmt / clippy / test) (push) Has been cancelled
Some checks failed
Secrets CLI - Build & Release / 版本 & Release (push) Successful in 2s
Secrets CLI - Build & Release / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Secrets CLI - Build & Release / Build (aarch64-apple-darwin) (push) Has been cancelled
Secrets CLI - Build & Release / Build (x86_64-pc-windows-msvc) (push) Has been cancelled
Secrets CLI - Build & Release / 发布草稿 Release (push) Has been cancelled
Secrets CLI - Build & Release / 质量检查 (fmt / clippy / test) (push) Has been cancelled
- Check connection with create_pool before writing to config - Show 'Database connection failed' on error, do not overwrite config - Update AGENTS.md and README.md Made-with: Cursor
This commit is contained in:
@@ -4,6 +4,12 @@ use anyhow::Result;
|
||||
pub async fn run(action: crate::ConfigAction) -> Result<()> {
|
||||
match action {
|
||||
crate::ConfigAction::SetDb { url } => {
|
||||
// Verify connection before writing config
|
||||
let pool = crate::db::create_pool(&url)
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("Database connection failed: {}", e))?;
|
||||
drop(pool);
|
||||
|
||||
let cfg = Config {
|
||||
database_url: Some(url.clone()),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user