How-to guides

SQL files

The examples below use the summary_NAME schema and the default database connection settings. Change these as needed.

Run a specific file

To run, for example, the planning_tmp.sql file:

psql 'dbname=ocdskingfisher user=ocdskingfisher options=--search-path=summary_NAME' -f planning_tmp.sql


See issue #167 about developer tools.

Time SQL statements

Add the -c '\timing' option to a psql command, before any -f options. For example:

psql 'dbname=ocdskingfisher user=ocdskingfisher options=--search-path=summary_NAME' -c '\timing' -f planning_tmp.sql

Drop tables and views

To undo a SQL file, drop the tables and views that it creates.

To undo the field_counts routine, run:

DROP TABLE field_counts;

Documentation files

Update the Database tables page

Database tables displays the CSV files in the docs/definitions/ directory. To create and/or update the CSV files, run (replacing NAME below):

./ dev docs-table-ref NAME

Then, for any new CSV file, manually add a new sub-section to docs/database.rst under an appropriate section.

Update the Entity Relationship Diagram

Add a schema with the --tables-only option:

./ add 123 diagram --tables-only

Use SchemaSpy to generate a diagram, copying the output to docs/_static/erd.png.