From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Lorusso Domenico <domenico.l76@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Composite type: Primary Key and validation
Date: Mon, 5 Jun 2023 08:17:19 -0700
Message-ID: <fc3a361a-c63d-fce6-7aa8-34576fa2326d@aklaver.com> (raw)
In-Reply-To: <CAJMpnG4T+=bMg7hv=8JYqRHJC1qBNcGKoGhnjK19VK8cKE0wYA@mail.gmail.com>
References: <CAJMpnG44dti-iEai5d3=XUt=eV27dgBeZd2AhKvisMXR33HWYg@mail.gmail.com>
<ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at>
<CAJMpnG4T+=bMg7hv=8JYqRHJC1qBNcGKoGhnjK19VK8cKE0wYA@mail.gmail.com>
On 6/5/23 08:06, Lorusso Domenico wrote:
> Thank's, you are right, I've the same doubts.
> A composite type is useful because I've to add all these information on
> many tables and because it more easy to pass all these informations to
> functions that have to ensure the right format and evaluation.
I do that with a Sqitch(https://sqitch.org/) template, the relevant part
being:
...
CREATE TABLE [% IF schema %][% schema %][% ELSE %]schema_name[% END
%].[% IF table %][% table %][% ELSE %]table_name[% END %](
line_id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
ts_insert timestamptz NOT NULL DEFAULT now(),
ts_update timestamptz,
user_insert varchar(20) NOT NULL DEFAULT "session_user"(),
user_update varchar(20)
);
...
I then add the table specific fields after Sqitch creates the deploy
script from the template.
>
> Talking about first point I could use the "table inheritance", but I've
> to reset all constraints for each table :-(
>
> --
> Domenico L.
>
> per stupire mezz'ora basta un libro di storia,
> io cercai di imparare la Treccani a memoria... [F.d.A.]
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, domenico.l76@gmail.com, laurenz.albe@cybertec.at
Subject: Re: Composite type: Primary Key and validation
In-Reply-To: <fc3a361a-c63d-fce6-7aa8-34576fa2326d@aklaver.com>
References: <CAJMpnG44dti-iEai5d3=XUt=eV27dgBeZd2AhKvisMXR33HWYg@mail.gmail.com> <ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at> <CAJMpnG4T+=bMg7hv=8JYqRHJC1qBNcGKoGhnjK19VK8cKE0wYA@mail.gmail.com> <fc3a361a-c63d-fce6-7aa8-34576fa2326d@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox