mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 12:32:39 +00:00
Don't require Cargo.toml for all subcommands
This commit is contained in:
parent
1b217cfac4
commit
264cb09528
@ -1,8 +1,7 @@
|
||||
use crate::opt::{Command, DatabaseCommand, MigrateCommand};
|
||||
use anyhow::{anyhow, bail};
|
||||
use anyhow::anyhow;
|
||||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
mod database;
|
||||
// mod migration;
|
||||
@ -14,13 +13,6 @@ mod prepare;
|
||||
pub use crate::opt::Opt;
|
||||
|
||||
pub async fn run(opt: Opt) -> anyhow::Result<()> {
|
||||
if !Path::new("Cargo.toml").exists() {
|
||||
bail!(
|
||||
r#"Failed to read `Cargo.toml`.
|
||||
hint: This command only works in the manifest directory of a Cargo package."#
|
||||
);
|
||||
}
|
||||
|
||||
dotenv().ok();
|
||||
|
||||
let database_url = match opt.database_url {
|
||||
|
||||
@ -6,7 +6,7 @@ use sqlx::any::{AnyConnectOptions, AnyKind};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, BufWriter};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::str::FromStr;
|
||||
use std::time::SystemTime;
|
||||
@ -23,6 +23,12 @@ pub fn run(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<()
|
||||
data: QueryData,
|
||||
}
|
||||
|
||||
anyhow::ensure!(
|
||||
Path::new("Cargo.toml").exists(),
|
||||
r#"Failed to read `Cargo.toml`.
|
||||
hint: This command only works in the manifest directory of a Cargo package."#
|
||||
);
|
||||
|
||||
let db_kind = get_db_kind(url)?;
|
||||
let data = run_prepare_step(merge, cargo_args)?;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user