Skip to content

Commit 0773273

Browse files
committed
Document converting from SQLite to PostgreSQL
Fixes #638
1 parent 5f7615a commit 0773273

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

cmd/goatcounter/db.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,30 @@ PostgreSQL notes:
299299
300300
You may want to consider lowering the "seq_page_cost" parameter; the query
301301
planner tends to prefer seq scans instead of index scans for some operations
302-
with the default of 4, which is much slower. I found that 0.5 is a fairly
302+
with the default of 4, which is much slower. I found that 1.1 is a fairly
303303
good setting, you can set it in your postgresql.conf file, or just for one
304304
database with:
305305
306-
alter database goatcounter set seq_page_cost=.5
306+
alter database goatcounter set seq_page_cost=1.1
307+
308+
Converting from SQLite to PostgreSQL:
309+
310+
You can use pgloader (https://pgloader.io) to convert from a SQLite to
311+
PostgreSQL database; to do this you must first create the PostgreSQL schema
312+
manually (pgloader doesn't create it properly), remove the data from the
313+
locations and languages tables as they will conflict.
314+
315+
For example:
316+
317+
# Create new PostgreSQL database
318+
$ createdb --owner goatcounter
319+
$ goatcounter db migrate all -createdb -db postgresql+dbname=goatcounter
320+
321+
# Remove data from languages and locations tables
322+
$ psql goatcounter -c 'delete from locations; delete from languages;'
323+
324+
# Convert data with pgloader
325+
$ pgloader --with 'create no tables' ./db/goatcounter.sqlite3 postgresql:///goatcounter
307326
`
308327

309328
const helpDBCommands = `List of commands:

0 commit comments

Comments
 (0)