Skip to content

Commit

Permalink
Implement check command
Browse files Browse the repository at this point in the history
  • Loading branch information
bikeshedder committed Sep 6, 2024
1 parent 29323fa commit 09631c2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/cli/schema/check.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use anyhow::Result;
use std::process::{exit, ExitCode};

use anyhow::{anyhow, Result};
use clap::Parser;

use crate::config::Config;
use crate::{config::Config, db::DiffDatabase};

use super::Backend;
use super::{diff::inspect_backend, Backend};

#[derive(Debug, Parser)]
pub struct CheckArgs {
Expand All @@ -25,5 +27,17 @@ pub struct CheckArgs {
}

pub async fn cmd(cfg: &Config, args: &CheckArgs) -> Result<()> {
unimplemented!()
let mut db = DiffDatabase::new(&cfg.database).await?;
db.create().await?;
let from = inspect_backend(cfg, &mut db, args.from).await?;
let to = inspect_backend(cfg, &mut db, args.to).await?;
db.drop().await?;
if from == to {
println!("Schemas are identical");
Ok(())
} else {
println!("Schemas differ: {} != {}", args.from, args.to);
println!("Run `tusker diff` to see the differences");
exit(1);
}
}

0 comments on commit 09631c2

Please sign in to comment.