File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
migrations_no_tx_reversible Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,29 @@ async fn no_tx(mut conn: PoolConnection<Sqlite>) -> anyhow::Result<()> {
77
77
Ok ( ( ) )
78
78
}
79
79
80
+ #[ sqlx:: test( migrations = false ) ]
81
+ async fn no_tx_reversible ( mut conn : PoolConnection < Sqlite > ) -> anyhow:: Result < ( ) > {
82
+ clean_up ( & mut conn) . await ?;
83
+
84
+ let migrator = Migrator :: new ( Path :: new ( "tests/sqlite/migrations_no_tx_reversible" ) ) . await ?;
85
+
86
+ // run migration
87
+ migrator. run ( & mut conn) . await ?;
88
+
89
+ // check outcome
90
+ let res: String = conn. fetch_one ( "PRAGMA JOURNAL_MODE" ) . await ?. get ( 0 ) ;
91
+ assert_eq ! ( res, "wal" . to_string( ) ) ;
92
+
93
+ // roll back
94
+ migrator. undo ( & mut conn, -1 ) . await ?;
95
+
96
+ // check outcome
97
+ let res: String = conn. fetch_one ( "PRAGMA JOURNAL_MODE" ) . await ?. get ( 0 ) ;
98
+ assert_eq ! ( res, "delete" . to_string( ) ) ;
99
+
100
+ Ok ( ( ) )
101
+ }
102
+
80
103
/// Ensure that we have a clean initial state.
81
104
async fn clean_up ( conn : & mut SqliteConnection ) -> anyhow:: Result < ( ) > {
82
105
conn. execute ( "DROP TABLE migrations_simple_test" ) . await . ok ( ) ;
Original file line number Diff line number Diff line change
1
+ -- no-transaction
2
+
3
+ PRAGMA JOURNAL_MODE = DELETE ;
Original file line number Diff line number Diff line change
1
+ -- no-transaction
2
+
3
+ PRAGMA JOURNAL_MODE = WAL;
You can’t perform that action at this time.
0 commit comments