Re: Schemas and serials

From: marcelo <marcelo(dot)nicolet(at)gmail(dot)com>
To: Melvin Davidson <melvin6925(at)gmail(dot)com>, tel medola <tel(dot)medola(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Schemas and serials
Date: 2017-07-30 17:58:15
Message-ID: b379a376-eded-2336-be3a-a393598a502a@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Addendum:

Some minutes ago, using EMS SQL Manager Lite, I tried what I was asking.
First, I created a new schema. Then, I duplicated some of the
transactional tables from the public schema, which is acting as a
definition repository for those tables, to the new "transactional"
schema. After that, the serial sequence was created in the test schema.
The only caution is to inspect the sql to be executed, checking to which
schema points every foreign key; the default, obviously, is public. That
is OK when the FK goes to one of the reference tables; but must be
changed when it must go to another transactional one. The example would
be "order" and "order_detail": customer, product, etc must be referenced
from public, but the FK from order_detail must point to season.order.

So, the question is solved, at least using some "postgresql complaint" tool.

Marcelo

On 29/07/17 17:17, Melvin Davidson wrote:
>
> On Sat, Jul 29, 2017 at 3:38 PM, tel medola <tel(dot)medola(at)gmail(dot)com
> <mailto:tel(dot)medola(at)gmail(dot)com>> wrote:
>
> Depends.
> When you create your tables in new schema, the script was the same
> from "qa"?
> Sequences, tables, etc.. belong to the schema where was created.
>
> Roberto.
>
> Em sáb, 29 de jul de 2017 às 16:17, marcelo
> <marcelo(dot)nicolet(at)gmail(dot)com <mailto:marcelo(dot)nicolet(at)gmail(dot)com>>
> escreveu:
>
> Some days ago I asked regarding tables located in different
> schemas.
> Now, my question is
> Suppose I have two schemas (other than public): "qa" and
> "production".
> Initially I create all my tables in "qa". All of them have a
> primary key
> of type serial.
> Later, I will copy the tables definitions to production.
> It will automatically create the sequences in the new schema,
> starting
> at zero?
> TIA
> Marcelo
>
>
> --
> Sent via pgsql-general mailing list
> (pgsql-general(at)postgresql(dot)org
> <mailto:pgsql-general(at)postgresql(dot)org>)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
> <http://www.postgresql.org/mailpref/pgsql-general>
>
>
> *Marcelo,
> >Initially I create all my tables in "qa". All of them have a primary
> key of type serial.
> >Later, I will copy the tables definitions to production.
>
> *
> *A word of caution, creating tables in a qa "schema" and then
> transferring to production is not the normal/correct (or safe) way to
> do development.
> *
> *The standard procedure is to create a seperate "qa" database (and/or
> server) with the exact same schema(s) as production. Then, after testing
> *
> *is completed, the schemas/tables are copied to production.
> *
>
> --
> *Melvin Davidson*
> I reserve the right to fantasize. Whether or not you
> wish to share my fantasy is entirely up to you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2017-07-30 20:19:18 Invalid byte sequence for encoding UTF-8 0xc3\n
Previous Message Vincenzo Romano 2017-07-30 16:53:25 Re: RETURNS SETOF RECORD with 1 column