Re: PostgreSQL DB in prod, test, debug - Mailing list pgsql-general

From Daniel Gustafsson
Subject Re: PostgreSQL DB in prod, test, debug
Date
Msg-id 7304F877-D043-4395-867E-014F48EB71ED@yesql.se
Whole thread Raw
In response to PostgreSQL DB in prod, test, debug  (Simon Connah <simon.n.connah@protonmail.com>)
Responses Re: PostgreSQL DB in prod, test, debug  (Simon Connah <simon.n.connah@protonmail.com>)
Re: PostgreSQL DB in prod, test, debug  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
List pgsql-general
> On 14 Feb 2024, at 10:59, Simon Connah <simon.n.connah@protonmail.com> wrote:

> This is probably a stupid question so I apologies in advance.

There is no such thing.

> What I think is the best way to do this is to do a pg_dump of the database (using the --schema-only flag) and then
loadit into a test only database that gets created at the start of the unit tests and destroyed at the end. The
automatedtests will insert, update, delete and select data to test if it all still works. 

If the source of truth for your schema is the database, then sure.  If the
source of truth is a .sql file in your source code repository then you should
use that.  In essence, create the test database identically to how you create
the production database to ensure that you are testing what you will run in
production.

--
Daniel Gustafsson




pgsql-general by date:

Previous
From: Simon Connah
Date:
Subject: PostgreSQL DB in prod, test, debug
Next
From: arun chirappurath
Date:
Subject: Postgres pg_cron extension