@@ -39,6 +39,9 @@ public final class Provider: Vapor.Provider {
3939 /// ex: user_pet vs. user+pet vs. user^pet
4040 /// default is _
4141 public let pivotNameConnector : String ?
42+
43+ /// If true, preparations will not be run.
44+ public let skipPreparations : Bool ?
4245
4346 /// If true, foreign keys will automatically
4447 /// be added by Fluent
@@ -56,6 +59,7 @@ public final class Provider: Vapor.Provider {
5659 migrationEntityName: String ? = nil ,
5760 pivotNameConnector: String ? = nil ,
5861 autoForeignKeys: Bool ? = nil ,
62+ skipPreparations: Bool ? = nil ,
5963 log: Bool ? = nil
6064 ) {
6165 self . idKey = idKey
@@ -66,6 +70,7 @@ public final class Provider: Vapor.Provider {
6670 self . migrationEntityName = migrationEntityName
6771 self . pivotNameConnector = pivotNameConnector
6872 self . autoForeignKeys = autoForeignKeys
73+ self . skipPreparations = skipPreparations
6974 self . log = log
7075 }
7176
@@ -117,7 +122,18 @@ public final class Provider: Vapor.Provider {
117122
118123 self . defaultPageKey = fluent [ " defaultPageKey " ] ? . string
119124 self . defaultPageSize = fluent [ " defaultPageSize " ] ? . int
120- self . migrationEntityName = fluent [ " migrationEntityName " ] ? . string
125+ if let name = fluent [ " migrationEntityName " ] {
126+ if name. isNull {
127+ self . migrationEntityName = nil
128+ self . skipPreparations = true
129+ } else {
130+ self . migrationEntityName = name. string
131+ self . skipPreparations = false
132+ }
133+ } else {
134+ self . migrationEntityName = nil
135+ self . skipPreparations = false
136+ }
121137 self . pivotNameConnector = fluent [ " pivotNameConnector " ] ? . string
122138 self . autoForeignKeys = fluent [ " autoForeignKeys " ] ? . bool
123139 self . log = fluent [ " log " ] ? . bool
@@ -191,8 +207,10 @@ public final class Provider: Vapor.Provider {
191207 if let keyNamingConvention = self . keyNamingConvention {
192208 database. keyNamingConvention = keyNamingConvention
193209 }
194-
195- try drop. prepare ( )
210+
211+ if skipPreparations != true {
212+ try drop. prepare ( )
213+ }
196214 }
197215
198216 public func beforeRun( _ drop: Droplet ) throws { }
0 commit comments