 final class P20170910: Preparation {
     
     static func prepare(_ database: Database) throws {
-        try prepareUser(database)
-        try prepareProblem(database)
-        try prepareProblemCase(database)
-        try prepareEvent(database)
-        try prepareEventProblem(database)
-        try prepareSubmission(database)
-        try prepareResultCase(database)
+        try database.prepare([
+            User.self,
+            Problem.self,
+            ProblemCase.self,
+            Event.self,
+            EventProblem.self,
+            Submission.self,
+            ResultCase.self
+            ])
     }
     
     static func revert(_ database: Database) throws {
-        try revertResultCase(database)
-        try revertSubmission(database)
-        try revertEventProblem(database)
-        try revertEvent(database)
-        try revertProblemCase(database)
-        try revertProblem(database)
-        try revertUser(database)
+        try database.revertAll([
+            ResultCase.self,
+            Submission.self,
+            EventProblem.self,
+            Event.self,
+            ProblemCase.self,
+            Problem.self,
+            User.self
+            ])
     }
     
-    static func prepareEvent(_ database: Database) throws {
-        try database.create(Event.self) { builder in
+}
+
+extension Event: Preparation {
+    
+    static func prepare(_ database: Database) throws {
+        try database.create(self) { builder in
             builder.id()
             builder.string("name")
             builder.parent(User.self, optional: false)

        }
    }
    
    static func revertEvent(_ database: Database) throws {
        try database.delete(Event.self)
    }
    
    static func prepareEventProblem(_ database: Database) throws {
        try database.create(EventProblem.self) { builder in
            builder.id()
            builder.parent(Event.self, optional: false)
            builder.parent(Problem.self, optional: false)

        }
    }
    
    static func revert(_ database: Database) throws {
        try database.delete(self)
    }
    
}


extension Submission: Preparation {
    
    static func prepare(_ database: Database) throws {
        try database.create(self) { builder in
            builder.id()
            builder.parent(EventProblem.self, optional: false)
            builder.parent(User.self, optional: false)
