(args: MigrateArgs)
| 21 | |
| 22 | #[tracing::instrument(level = "info", skip(args))] |
| 23 | pub async fn migrate(args: MigrateArgs) -> Result<(), Report<GraphError>> { |
| 24 | let pool = PostgresStorePool::new( |
| 25 | &args.db_info, |
| 26 | &args.pool_config, |
| 27 | NoTls, |
| 28 | PostgresStoreSettings::default(), |
| 29 | ) |
| 30 | .await |
| 31 | .change_context(GraphError) |
| 32 | .map_err(|report| { |
| 33 | tracing::error!(error = ?report, "Failed to connect to database"); |
| 34 | report |
| 35 | })?; |
| 36 | |
| 37 | let mut store = pool |
| 38 | .acquire(None) |
| 39 | .await |
| 40 | .change_context(GraphError) |
| 41 | .map_err(|report| { |
| 42 | tracing::error!(error = ?report, "Failed to acquire database connection"); |
| 43 | report |
| 44 | })?; |
| 45 | |
| 46 | store |
| 47 | .run_migrations() |
| 48 | .await |
| 49 | .change_context(GraphError) |
| 50 | .map_err(|report| { |
| 51 | tracing::error!(error = ?report, "Failed to run migrations"); |
| 52 | report |
| 53 | })?; |
| 54 | |
| 55 | store |
| 56 | .seed_system_policies() |
| 57 | .await |
| 58 | .change_context(GraphError) |
| 59 | .map_err(|report| { |
| 60 | tracing::error!(error = ?report, "Failed to seed system policies"); |
| 61 | report |
| 62 | })?; |
| 63 | |
| 64 | Ok(()) |
| 65 | } |
no test coverage detected