Skip to content

Commit 30633ca

Browse files
committed
Use file_copy strategy when creating databases
1 parent 962fb7d commit 30633ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tests/AppTests/Helpers/DatabasePool.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ extension DatabasePool.Database {
209209
try await _withDatabase("postgres", details: connectionDetails, timeout: .seconds(10)) { // Connect to `postgres` db in order to reset the test db
210210
let databaseName = Environment.get("DATABASE_NAME")!
211211
try await $0.query(PostgresQuery(unsafeSQL: "DROP DATABASE IF EXISTS \(databaseName) WITH (FORCE)"))
212-
try await $0.query(PostgresQuery(unsafeSQL: "CREATE DATABASE \(databaseName)"))
212+
try await $0.query(PostgresQuery(unsafeSQL: "CREATE DATABASE \(databaseName) STRATEGY = file_copy"))
213213
}
214214

215215
do { // Use autoMigrate to spin up the schema
@@ -231,7 +231,7 @@ extension DatabasePool.Database {
231231
do {
232232
try await _withDatabase("postgres", details: connectionDetails, timeout: .seconds(10)) { client in
233233
try await client.query(PostgresQuery(unsafeSQL: "DROP DATABASE IF EXISTS \(snapshot) WITH (FORCE)"))
234-
try await client.query(PostgresQuery(unsafeSQL: "CREATE DATABASE \(snapshot) TEMPLATE \(original)"))
234+
try await client.query(PostgresQuery(unsafeSQL: "CREATE DATABASE \(snapshot) TEMPLATE \(original) STRATEGY = file_copy"))
235235
}
236236
} catch {
237237
print("Create snapshot failed with error: ", String(reflecting: error))
@@ -246,7 +246,7 @@ extension DatabasePool.Database {
246246
do {
247247
try await _withDatabase("postgres", details: details, timeout: .seconds(10)) { client in
248248
try await client.query(PostgresQuery(unsafeSQL: "DROP DATABASE IF EXISTS \(original) WITH (FORCE)"))
249-
try await client.query(PostgresQuery(unsafeSQL: "CREATE DATABASE \(original) TEMPLATE \(snapshot)"))
249+
try await client.query(PostgresQuery(unsafeSQL: "CREATE DATABASE \(original) TEMPLATE \(snapshot) STRATEGY = file_copy"))
250250
}
251251
} catch {
252252
print("Restore snapshot failed with error: ", String(reflecting: error))

0 commit comments

Comments
 (0)