File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,22 @@ extension Application {
3838 )
3939 }
4040
41+ /// Automatically runs forward migrations without confirmation.
42+ /// This can be triggered by passing `--auto-migrate` flag.
43+ public func autoMigrate( ) -> EventLoopFuture < Void > {
44+ self . migrator. setupIfNeeded ( ) . flatMap {
45+ self . migrator. prepareBatch ( )
46+ }
47+ }
48+
49+ /// Automatically runs reverse migrations without confirmation.
50+ /// This can be triggered by passing `--auto-revert` during boot.
51+ public func autoRevert( ) -> EventLoopFuture < Void > {
52+ self . migrator. setupIfNeeded ( ) . flatMap {
53+ self . migrator. revertAllBatches ( )
54+ }
55+ }
56+
4157 public struct Fluent {
4258 final class Storage {
4359 let databases : Databases
@@ -70,12 +86,10 @@ extension Application {
7086
7187 let signature = try Signature ( from: & application. environment. commandInput)
7288 if signature. autoRevert {
73- try application. migrator. setupIfNeeded ( ) . wait ( )
74- try application. migrator. revertAllBatches ( ) . wait ( )
89+ try application. autoRevert ( ) . wait ( )
7590 }
7691 if signature. autoMigrate {
77- try application. migrator. setupIfNeeded ( ) . wait ( )
78- try application. migrator. prepareBatch ( ) . wait ( )
92+ try application. autoMigrate ( ) . wait ( )
7993 }
8094 }
8195
You can’t perform that action at this time.
0 commit comments