Skip to content

Locally restore wagtail postgres database and fix Wagtail preview

Pat Phongsvirajati edited this page May 16, 2022 · 2 revisions

Locally restore wagtail postgres database

Get a copy of the dump file and place within fec-cms project root.

cd to project root folder

cd [fec-cms-project-root-dir]

Drop current cfdm database

dropdb cfdm_cms_test

Create new database

createdb cfdm_cms_test

Restore from dump file

pg_restore --dbname cfdm_cms_test --no-acl --no-owner <dump_file_name>

Go to fec directory (that's where the manage.py file is stored)

cd fec/

Run migrate for new database

./manage.py migrate

Create user

./manage.py createsuperuser

Start-up wagtail app

./manage.py runserver

Fix Wagtail preview functionality on your local environment

After restoring your Wagtail database on your local development environment, you may notice that your Wagtail page preview functionality is broken. You'll need to update your local Wagtail settings to fix it.

  1. Go into your local Wagtail admin
  2. In the left hand navigation, go to "Settings" --> "Sites"
  3. Click on the "fec.gov" site to edit
  4. Update hostname to either "localhost" or "127.0.0.1"
  5. Update the port to "8000"
  6. Save and test any page to preview, it should now work.