Skip to content

Commit 39bb8c8

Browse files
Create template.md
1 parent dac8810 commit 39bb8c8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Reset template database
2+
```
3+
UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0';
4+
\c template0
5+
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
6+
DROP DATABASE template1;
7+
CREATE DATABASE template1 WITH TEMPLATE = 'template0';
8+
\c template1
9+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
10+
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template0';
11+
```
12+
13+
14+
# the common technique for speeding postgres test
15+
- disable fsync
16+
- use transaction and rollback
17+
- template database (it is faster to drop and recreate database)
18+
19+
They are all outlined here https://www.maragu.dk/blog/speeding-up-postgres-integration-tests-in-go/

0 commit comments

Comments
 (0)