我想删除蒸气场,我的代码如下:
struct AddUserSomeFIeld: Migration {
typealias Database = MySQLDatabase
static func prepare(on conn: MySQLConnection) -> Future<Void> {
return Database.update(User.self, on: conn) { builder in
builder.field(for: \.someFIeld)
}
}
static func revert(on conn: MySQLConnection) -> Future<Void> {
return Database.update(User.self, on: conn) { builder in
builder.deleteField(for: \.someFIeld)
}
}
}
但是执行vapor build && vapor run revert
无效,因为如果我重写以下内容,则会显示用户表someFIeld
字段:
struct AddUserSomeFIeld: Migration {
typealias Database = MySQLDatabase
static func prepare(on conn: MySQLConnection) -> Future<Void> {
return Database.update(User.self, on: conn) { builder in
builder.field(for: \.someFIeld)
}
}
static func revert(on conn: MySQLConnection) -> Future<Void> {
return Database.delete(User.self, on: conn)
}
}
可以!用户表被删除。我想知道如何删除Vapor
中的字段。