1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
use std::borrow::Cow; use sha2::{Digest, Sha384}; use super::MigrationType; #[derive(Debug, Clone)] pub struct Migration { pub version: i64, pub description: Cow<'static, str>, pub migration_type: MigrationType, pub sql: Cow<'static, str>, pub checksum: Cow<'static, [u8]>, } impl Migration { pub fn new( version: i64, description: Cow<'static, str>, migration_type: MigrationType, sql: Cow<'static, str>, ) -> Self { let checksum = Cow::Owned(Vec::from(Sha384::digest(sql.as_bytes()).as_slice())); Migration { version, description, migration_type, sql, checksum, } } }