@@ -113,22 +113,22 @@ final class FluentPostgresDriverTests: XCTestCase {
113
113
}
114
114
115
115
func testBlob( ) throws {
116
- struct Foo : Model {
117
- static let shared = Foo ( )
118
- var id = Field < Int ? > ( " id " )
119
- var data = Field < [ UInt8 ] > ( " data " )
116
+ final class Foo : Model {
117
+ @ Field var id : Int ?
118
+ @ Field var data : [ UInt8 ]
119
+ init ( ) { }
120
120
}
121
121
122
122
struct CreateFoo : Migration {
123
123
func prepare( on database: Database ) -> EventLoopFuture < Void > {
124
- return database . schema ( Foo . self )
125
- . field ( \. id, . int, . identifier( auto: true ) )
126
- . field ( \. data, . data, . required)
124
+ return Foo . schema ( on : database )
125
+ . field ( \. $ id, . int, . identifier( auto: true ) )
126
+ . field ( \. $ data, . data, . required)
127
127
. create ( )
128
128
}
129
129
130
130
func revert( on database: Database ) -> EventLoopFuture < Void > {
131
- return database . schema ( Foo . self ) . delete ( )
131
+ return Foo . schema ( on : database ) . delete ( )
132
132
}
133
133
}
134
134
@@ -137,19 +137,31 @@ final class FluentPostgresDriverTests: XCTestCase {
137
137
}
138
138
139
139
func testSaveModelWithBool( ) throws {
140
- struct Organization : Model {
141
- static let shared = Organization ( )
142
- static let entity = " organizations "
143
- let id = Field < Int ? > ( " id " )
144
- let disabled = Field < Bool > ( " disabled " )
140
+ final class Organization : Model {
141
+ @Field var id : Int ?
142
+ @Field var disabled : Bool
143
+ init ( ) { }
145
144
}
146
145
147
- try Organization . autoMigration ( ) . prepare ( on: self . connectionPool) . wait ( )
146
+ struct CreateOrganization : Migration {
147
+ func prepare( on database: Database ) -> EventLoopFuture < Void > {
148
+ return Organization . schema ( on: database)
149
+ . field ( \. $id, . int, . identifier( auto: true ) )
150
+ . field ( \. $disabled, . bool, . required)
151
+ . create ( )
152
+ }
153
+
154
+ func revert( on database: Database ) -> EventLoopFuture < Void > {
155
+ return Organization . schema ( on: database) . delete ( )
156
+ }
157
+ }
158
+
159
+ try CreateOrganization ( ) . prepare ( on: self . connectionPool) . wait ( )
148
160
defer {
149
- try ! Organization . autoMigration ( ) . revert ( on: self . connectionPool) . wait ( )
161
+ try ! CreateOrganization ( ) . revert ( on: self . connectionPool) . wait ( )
150
162
}
151
163
152
- let new = Organization . row ( )
164
+ let new = Organization ( )
153
165
new. disabled = false
154
166
try new. save ( on: self . connectionPool) . wait ( )
155
167
}
0 commit comments