Re: Template for schema? (as opposed to databases) - Mailing list pgsql-general

From David G. Johnston
Subject Re: Template for schema? (as opposed to databases)
Date
Msg-id CAKFQuwZi4LnmC4XzABS7GiWkx-dVrNf=YzZiPwZq3gb_B1YGGQ@mail.gmail.com
Whole thread Raw
In response to Template for schema? (as opposed to databases)  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: Template for schema? (as opposed to databases)  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
On Tuesday, January 11, 2022, Dominique Devienne <ddevienne@gmail.com> wrote:
This means the template-schema name is part of the DDL for the schema, and a clone would need to use its own search-path, not the original.

This is your major limitation.  You are required to create new objects from code and cannot leverage any kind of copy of existing objects.  Unless the test database need only be three schemas always - then the schema can be identical because you can place them into different databases.
 
Please do note this needs to be done from a libpq client, which has no direct access to the server (i.e. cannot use dump/restore solutions).

PQexec and put the entire script into a single string.  That seems like the fastest possible way to create new objects (see the first point).

Beyond that there is too little detail to provide suggestions.  I would observe that for testing the meaningful values of N are 1 and 2.  Having a setup where N = 5 is not materially different than the N = 2 case (usually).

David J.

pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Template for schema? (as opposed to databases)
Next
From: Francisco Olarte
Date:
Subject: Re: Template for schema? (as opposed to databases)