sqlx_core/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 pub no_tx: bool,
15}
16
17impl Migration {
18 pub fn new(
19 version: i64,
20 description: Cow<'static, str>,
21 migration_type: MigrationType,
22 sql: Cow<'static, str>,
23 no_tx: bool,
24 ) -> Self {
25 let checksum = Cow::Owned(Vec::from(Sha384::digest(sql.as_bytes()).as_slice()));
26
27 Migration {
28 version,
29 description,
30 migration_type,
31 sql,
32 checksum,
33 no_tx,
34 }
35 }
36}
37
38#[derive(Debug, Clone)]
39pub struct AppliedMigration {
40 pub version: i64,
41 pub checksum: Cow<'static, [u8]>,
42}