45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
use sqlx::{Postgres, Transaction, query};
|
|
|
|
use super::authority::{MigrationDescriptor, MigrationError};
|
|
|
|
pub(super) const SOURCE: &str = include_str!("import_plan_v14.sql");
|
|
pub(super) const SOURCE_SHA256: &str =
|
|
"176c5b3cd12ddaf78dd0d312626a0c387f9c240a765194b34e88f7e0d3b4ca2a";
|
|
|
|
pub(super) async fn apply(
|
|
transaction: &mut Transaction<'_, Postgres>,
|
|
descriptor: &MigrationDescriptor,
|
|
) -> Result<(), MigrationError> {
|
|
sqlx::raw_sql(SOURCE)
|
|
.execute(&mut **transaction)
|
|
.await
|
|
.map_err(|_| {
|
|
MigrationError::new(
|
|
"apply_failed",
|
|
"apply.import_plan",
|
|
Some(14),
|
|
"restore_known_good_backup",
|
|
)
|
|
})?;
|
|
query(
|
|
"insert into __crank_migrations (version, name, checksum, phase, compatibility)
|
|
values ($1, $2, $3, $4, $5)",
|
|
)
|
|
.bind(descriptor.version)
|
|
.bind(descriptor.name)
|
|
.bind(&descriptor.checksum)
|
|
.bind(descriptor.phase)
|
|
.bind(descriptor.compatibility)
|
|
.execute(&mut **transaction)
|
|
.await
|
|
.map_err(|_| {
|
|
MigrationError::new(
|
|
"apply_failed",
|
|
"apply.canonical_ledger",
|
|
Some(14),
|
|
"restore_known_good_backup",
|
|
)
|
|
})?;
|
|
Ok(())
|
|
}
|