Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 1.25 KB

create-new-db.md

File metadata and controls

30 lines (23 loc) · 1.25 KB

Creating a new PyCDS database

To create a new PyCDS database at the latest revision:

  1. On the server or in the container of your choice:

    1. Create a new database with the desired database name, <db-name>
    2. Install extensions PL/Postgres, PL/Python, and PostGIS
    3. Create an empty schema with the desired name, <schema-name>
    4. Grant the desired user (name <user-name>) write permission to the schema. (You may need to create the desired user first.)
    5. For an example of such an arrangement, run the shell script alembic/development/init_test_db/common/create_scripts.sh and examine the SQL scripts it writes to alembic/development/init_test_db/common.
  2. Add a new DSN for the database, including the appropriate username, to alembic.ini. Choose a name by which to refer to it in the Alembic CLI, <db-label>.

    [<db-label>]
    sqlalchemy.url = postgresql://<user-name>@<server-name>/<db-name>
  3. Initialize the new schema by upgrading it to head:

    [PYCDS_SCHEMA_NAME=<schema name>] [PYCDS_SU_ROLE_NAME=<role name>] alembic -x db=<db-label> upgrade head

If you wish to create the database at a different revision, replace head above with the desired revision id.