@@ -2,7 +2,7 @@ use std::path::Path;
2
2
3
3
#[ derive( Debug ) ]
4
4
pub ( crate ) struct Migration {
5
- pub ( crate ) timestamp : u64 ,
5
+ pub ( crate ) sequence_number : u64 ,
6
6
#[ allow( unused) ]
7
7
pub ( crate ) name : String ,
8
8
}
@@ -50,13 +50,16 @@ pub(crate) fn get_migration(path: &Path, migrations_dir: &Path) -> Option<Migrat
50
50
fn parse_migration_name ( name : & str ) -> Option < Migration > {
51
51
let mut parts = name. splitn ( 2 , '_' ) ;
52
52
// remove leading zeros to support numeric
53
- let timestamp : u64 = parts. next ( ) ?. trim_start_matches ( '0' ) . parse ( ) . ok ( ) ?;
53
+ let sequence_number : u64 = parts. next ( ) ?. trim_start_matches ( '0' ) . parse ( ) . ok ( ) ?;
54
54
let full_name = parts. next ( ) ?;
55
55
let name = full_name
56
56
. strip_suffix ( ".sql" )
57
57
. unwrap_or ( full_name)
58
58
. to_string ( ) ;
59
- Some ( Migration { timestamp, name } )
59
+ Some ( Migration {
60
+ sequence_number,
61
+ name,
62
+ } )
60
63
}
61
64
62
65
#[ cfg( test) ]
@@ -81,7 +84,7 @@ mod tests {
81
84
82
85
assert ! ( migration. is_some( ) ) ;
83
86
let migration = migration. unwrap ( ) ;
84
- assert_eq ! ( migration. timestamp , 1234567890 ) ;
87
+ assert_eq ! ( migration. sequence_number , 1234567890 ) ;
85
88
assert_eq ! ( migration. name, "create_users" ) ;
86
89
}
87
90
@@ -98,7 +101,7 @@ mod tests {
98
101
99
102
assert ! ( migration. is_some( ) ) ;
100
103
let migration = migration. unwrap ( ) ;
101
- assert_eq ! ( migration. timestamp , 1234567890 ) ;
104
+ assert_eq ! ( migration. sequence_number , 1234567890 ) ;
102
105
assert_eq ! ( migration. name, "create_users" ) ;
103
106
}
104
107
@@ -113,7 +116,7 @@ mod tests {
113
116
114
117
assert ! ( migration. is_some( ) ) ;
115
118
let migration = migration. unwrap ( ) ;
116
- assert_eq ! ( migration. timestamp , 201 ) ;
119
+ assert_eq ! ( migration. sequence_number , 201 ) ;
117
120
assert_eq ! ( migration. name, "a_migration" ) ;
118
121
}
119
122
0 commit comments