如何删除蒸气场?

时间:2019-05-03 17:07:23

标签: vapor

我想删除蒸气场,我的代码如下:

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中的字段。

0 个答案:

没有答案