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