Skip to content

Latest commit

 

History

History
71 lines (46 loc) · 1.24 KB

LOCAL_DB.MD

File metadata and controls

71 lines (46 loc) · 1.24 KB

Local Database

To access the local copy of the database, you can shell into it by opening a new terminal window and executing psql -h localhost -p 5432 -U <db-username> and enter the local database password when prompted.

Database Migrations

After making a change to a model, create migration script:

PYTHONPATH=. alembic revision --autogenerate -m "Comment relevant to change"

You may have to modify the generated code to import geoalchemy2

You may want to have a data import/modification step, where you're not actually changing the database, but want to manage new data. You can create an "empty" migration, and insert data as needed:

PYTHONPATH=. alembic revision -m "Comment relevant to change"

Then apply:

PYTHONPATH=. alembic upgrade head

You may need to enable postgis extension:

CREATE EXTENSION postgis;

Common Commands

Checking and starting postgres through brew:

brew services start postgresql
brew services list

Shell into local postgres server:

psql -d postgres

Show list of databases:

\l

Connect to 'wps' database:

\c wps

Show list of extensions:

\dx

Install postgis extension:

create extension postgis;