Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
feat: add --skip-migrate flag to opengb deploy (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Jun 25, 2024
1 parent a3c4e10 commit 6255e07
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions cli/src/commands/backend/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub struct Opts {
/// The location of the OpenGB project.
#[clap(long)]
path: Option<std::path::PathBuf>,

/// Skip the migration step.
#[clap(long)]
skip_migrate: bool,
}

impl Opts {
Expand Down Expand Up @@ -60,7 +64,7 @@ impl Opts {
args: vec![
"build".into(),
"--runtime".into(),
"cloudflare-workers".into(),
"cloudflare-workers-platforms".into(),
],
env: HashMap::new(),
cwd: project_path.clone(),
Expand All @@ -78,23 +82,25 @@ impl Opts {
})
.await?;

eprintln!();
rivet_term::status::info("Migrating databases", "");

// Migrate
let mut migrate_env = HashMap::new();
migrate_env.insert(
"DATABASE_URL".to_string(),
unwrap!(db_url, "no db url for env"),
);

let migrate_cmd = run_opengb_command(OpenGbCommandOpts {
args: vec!["db".into(), "deploy".into()],
env: migrate_env,
cwd: project_path.clone(),
})
.await?;
ensure!(migrate_cmd.success(), "Failed to migrate OpenGB databases");
if !self.skip_migrate {
eprintln!();
rivet_term::status::info("Migrating databases", "");

// Migrate
let mut migrate_env = HashMap::new();
migrate_env.insert(
"DATABASE_URL".to_string(),
unwrap!(db_url, "no db url for env"),
);

let migrate_cmd = run_opengb_command(OpenGbCommandOpts {
args: vec!["db".into(), "deploy".into()],
env: migrate_env,
cwd: project_path.clone(),
})
.await?;
ensure!(migrate_cmd.success(), "Failed to migrate OpenGB databases");
}

// Read files for upload
let gen_manifest = read_generated_manifest(&project_path).await?;
Expand Down

0 comments on commit 6255e07

Please sign in to comment.