Set up the database¶
To use the default settings, create a pelican_backend
database and use its public
schema.
To use another schema, you can set the PGOPTIONS
environment variable when running psql
commands, for example:
env PGOPTIONS=--search_path=development psql DATABASE -f FILE
Create the btree_gin extension:
psql pelican_backend -c "CREATE EXTENSION btree_gin";
Run migrations¶
Run the files in the pelican/migrations/
directory in numerical order. For example:
psql pelican_backend -f pelican/migrations/001_base.sql -f pelican/migrations/002_constraints.sql
Load exchange rates¶
Populating exchange rates from scratch will take a long time and use a lot of fixer.io’s quota.
Instead, load a file:
psql pelican_backend -c "\copy exchange_rates (valid_on, rates) from 'pelican/static/exchange_rates_dump.csv' delimiter ',' csv header;"
Note
The extract.kingfisher_process worker fetches missing exchange rates when it receives a message. To avoid duplication across processes and/or threads, you can run the update-exchange-rates command periodically.
Dump exchange rates¶
psql pelican_backend -c "\copy exchange_rates to '/path/to/exchange_rates_dump.csv' csv header;"
Reset the database¶
Truncate all tables in the database. For example:
psql pelican_backend -f pelican/static/truncate.sql