pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ken Lacrosse <klacrosse@pkwillis.com>
To: 'pgsql-general@lists.postgresql.org' <pgsql-general@lists.postgresql.org>
Subject: Re: Snippets?
Date: Fri, 24 May 2019 11:27:08 -0700
Message-ID: <f84f799c-6d8c-5ea2-0ac4-5be4a7646809@aklaver.com> (raw)
In-Reply-To: <f0bac938148e4f4f8fa69d65de427258@pkwillis.com>
References: <f0bac938148e4f4f8fa69d65de427258@pkwillis.com>

On 5/24/19 11:15 AM, Ken Lacrosse wrote:
> Is there any way in postgresql to have a "snippet" of SQL code which you 
> could apply to all tables.  Something you could add which would ensure 
> that every table always has a Created, Changed and Deleted column for 
> example.  Sort of like a C include I suppose.  Of course if I’m building 
> a DB schema by hand I could just copy and paste those columns but it 
> still seems a bit too, darn humans!, error prone.

Not that I know of.

Things I have done:
1) Template table that I includes those fields that I then add to.

FYI the Sqitch schema management system allows you to do the above:
https://sqitch.org/docs/manual/sqitch-add/#templates

2) A script that I run over table definition to add the fields.

> 
> Ken LaCrosse
> 
> Senior IT InfoSec and Infrastructure Monitoring Specialist
> 
> I.T. | American Recovery Service & Skipbusters
> 
> Phone: (800)398-6480 x3758
> 
> Email: KLacrosse@pkwillis.com <mailto:KLacrosse@pkwillis.com>
> 
> www.pkwillis.com <http://www.pkwillis.com/;
> 
> * Visibility is key. *
> 
> Without visibility you can't see.
> 
> What you can't see you can't measure.
> 
> What you can't measure you can’t planfully change.
> 
> What you can’t planfully change you can't manage.
> 
> And if we can’t manage then why are we here?
> 
> NOTICE: The information contained in this transmission, including 
> attachments, may contain confidential information that is privileged, 
> confidential and/or exempt from disclosure by applicable law. It is 
> intended only for the use of the person(s) or entity to which it is 
> addressed. If the reader of this transmission is not the intended 
> recipient, the reader is hereby notified that any review, use, 
> dissemination, distribution or duplication of this communication 
> (including any reliance thereon) is strictly prohibited. If you have 
> received this transmission in error, please contact the sender by reply 
> email, then delete and destroy the material in its entirety, whether in 
> electronic or hard copy format. WE SPECIFICALLY DISCLAIM RESPONSIBILITY 
> FOR ANY UNAUTHORIZED USE OF THIS COMMUNICATION OR ANY ATTACHMENTS TO IT. 
> Thank you.


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (7+ messages)  latest in thread

Message-ID: <f84f799c-6d8c-5ea2-0ac4-5be4a7646809@aklaver.com>
Permalink:  ../f84f799c-6d8c-5ea2-0ac4-5be4a7646809@aklaver.com/
Also on:    postgresql.org/message-id/f84f799c-6d8c-5ea2-0ac4-5be4a7646809@aklaver.com

 · 

reply

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, klacrosse@pkwillis.com
  Subject: Re: Snippets?
  In-Reply-To: <f84f799c-6d8c-5ea2-0ac4-5be4a7646809@aklaver.com>
  References: <f0bac938148e4f4f8fa69d65de427258@pkwillis.com> <f84f799c-6d8c-5ea2-0ac4-5be4a7646809@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