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
Note
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):
./manage.py 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:
./manage.py add 123 diagram --tables-only
Then, update the How tables are related. For example:
java -jar schemaspy.jar -t pgsql -dp postgresql.jar -o schemaspy -norows -host localhost -db kingfisher_summarize -s summary_collection_1 -u MYUSER
mv schemaspy/diagrams/summary/relationships.real.compact.png docs/_static/