use sqlx::{Postgres, Transaction, query}; use super::authority::{MigrationDescriptor, MigrationError}; pub(super) const NAME: &str = "resource-drafts-v16"; pub(super) const SOURCE: &str = include_str!("resource_drafts_v16.sql"); pub(super) const SOURCE_SHA256: &str = "0ed07dabd37f97e212923650b80278898c4e9519cee0cda4170f6b2b2a3d92d7"; 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.resource_drafts", Some(16), "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(16), "restore_known_good_backup", ) })?; Ok(()) }