You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: migrate.rs
    path of file: ./repos/crates.io/src/admin
    
    the code of the file until where you have to start completion: use anyhow::{anyhow, Error};
use diesel_migrations::{
    embed_migrations, EmbeddedMigrations, HarnessWithOutput, MigrationHarness,
};

static CATEGORIES_TOML: &str = include_
    
pub fn run(_opts: Opts) -> Result<(), Error> {
    let config = crate::config::DatabasePools::full_from_environment(
        &crate::config::Base::from_environment()?,
    )?;

    // TODO: Refactor logic so that we can also check things from App::new() here.
    // If the app will panic due to bad configuration, it is better to error in the release phase
    // to avoid launching dynos that will fail.

    if config.are_all_read_only() {
        // TODO: Check `any_pending_migrations()` with a read-only connection and error if true.
        // It looks like this requires changes upstream to make this pub in `migration_macros`.

        warn!("Skipping migrations and category sync (read-only mode)");

        // The service is undergoing maintenance or mitigating an outage.
        // Exit with success to ensure configuration changes can be made.
        // Heroku will not launch new dynos if the release phase fails.
        return Ok(());
    }

    // The primary is online, access directly via `DATABASE_URL`.
    let conn = &mut crate::db::oneoff_connection_with_config(&config)?;

    info!("Migrating the database");
    let mut stdout = std::io::stdout();
    let mut harness = HarnessWithOutput::new(conn, &mut stdout);
    harness
        .run_pending_migrations(MIGRATIONS)
        .map_err(|err| anyhow!("Failed to run migrations: {err}"))?;

    info!("Synchronizing crate categories");
    crate::boot::categories::sync_with_connection(CATEGORIES_TOML, conn)?;

    Ok(())
}