IHP 1.1 is out now!

Any way to import fixtures/tables from production DB to dev DB?

Lillo PRO

Happy New Year everyone!

I think I have overheard some different techniques for DB diffing to the IHP fixtures on Slack, so hope someone has some input.

Does anyone know of a good way to import the database in production and hydrate the local dev environment with this data?

The usecase is more specifically that I have some items from a table that I need to have synced locally to test certain things locally without having to manually consolidating the data all the time.

Lillo PRO

I found a half-decent way

Just opened the IHP Cloud database via the Beekeeper Studio client, exported a SQL dump of that table, inserted into Fixtures.sql file and ran make db in nix-shell.

Works well enough for my usecase 👍


Cool, thanks for sharing!

Daniel Sokil PRO

I have a script named sync-prod-db.sh And inside the script:

#!/usr/bin/env bash


pg_dump "$DATABASE_URL" -a --inserts --column-inserts --disable-triggers | sed -e '/^--/d' >Application/Fixtures.sql

# Import Fixtures
make db

# Dump Fixtures
make dump_db

Notice that the DATABASE_URL variable should have your database URL with user and password.

Lillo PRO

Nice! That's perfect!