#[derive(Debug, Clone)]
pub struct Migration {
pub version: u32,
pub name: String,
pub sql: &'static str,
}
impl Migration {
#[must_use]
pub fn new(version: u32, name: impl Into<String>, sql: &'static str) -> Self {
Self {
version,
name: name.into(),
sql,
}
}
#[must_use]
pub fn checksum(&self) -> String {
use std::hash::{Hash, Hasher};
let mut hasher = std::collections::hash_map::DefaultHasher::new();
self.sql.hash(&mut hasher);
format!("{:x}", hasher.finish())
}
}