pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrus <kobruleht2@hot.ee>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: How to migrate database from 10.1 to 9.1
Date: Sun, 13 May 2018 18:54:37 +0300
Message-ID: <0B65DCA2835A4244B432B4AA48B6BDEE@dell2> (raw)

Database is created in

    "PostgreSQL 10.1 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built 
by MSYS2 project) 4.9.2, 64-bit"

and contains tables with autogenerated primary keys like

    CREATE TABLE public.logifail
    (
      id integer NOT NULL DEFAULT nextval('logifail_id_seq'::regclass),
      ..
      CONSTRAINT logifail_pkey PRIMARY KEY (id),
      CONSTRAINT logifail_id_check CHECK (id > 0)
    )
    WITH (
      OIDS=FALSE
    );

if this database is restored to Postgres 9.1 from custom backup using


    pg_restore --role=$1_owner --no-owner --dbname=$1 --jobs=4 --verbose --username=postgres

automatic primary key generation stops working.

id column is restored without sequnece. Table becomes:

    CREATE TABLE logifail
    (
      id integer NOT NULL,
       ...
      CONSTRAINT logifail_pkey PRIMARY KEY (id),
      CONSTRAINT logifail_id_check CHECK (id > 0)
    )
    WITH (
      OIDS=FALSE
    );

How to fix this so that sequences are also restored ?
I tried to restore using both 10.1 and 9.1 pg_restore but autogenerated 
primary key columns are still lost.

Posted also in

https://stackoverflow.com/questions/50317935/how-to-ove-database-from-postgres-10-1-to-9-1

Andrus. 





view thread (2+ messages)  latest in thread

Message-ID: <0B65DCA2835A4244B432B4AA48B6BDEE@dell2>
Permalink:  ../0B65DCA2835A4244B432B4AA48B6BDEE@dell2/
Also on:    postgresql.org/message-id/0B65DCA2835A4244B432B4AA48B6BDEE@dell2

 · 

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: kobruleht2@hot.ee
  Subject: Re: How to migrate database from 10.1 to 9.1
  In-Reply-To: <0B65DCA2835A4244B432B4AA48B6BDEE@dell2>
  References: <0B65DCA2835A4244B432B4AA48B6BDEE@dell2>

* 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