Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fHvtn-0007jQ-BF for pgsql-general@arkaria.postgresql.org; Sun, 13 May 2018 18:39:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fHvti-0005hT-OB for pgsql-general@arkaria.postgresql.org; Sun, 13 May 2018 18:39:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fHtKt-0004vN-4Q for pgsql-general@lists.postgresql.org; Sun, 13 May 2018 15:54:59 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.122]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fHtKl-0000fP-Ef for pgsql-general@postgresql.org; Sun, 13 May 2018 15:54:57 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id C84491659 for ; Sun, 13 May 2018 18:54:47 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9TRammHYarYo for ; Sun, 13 May 2018 18:54:45 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost1.estpak.ee [213.180.2.79]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id B772A1690 for ; Sun, 13 May 2018 18:54:45 +0300 (EEST) Received: from dell2 (66.63.196.88.sta.estpak.ee [88.196.63.66]) (Authenticated sender: kobruleht2) by HOT-Relayhost1.estpak.ee (Postfix) with ESMTPSA id A8A7E157 for ; Sun, 13 May 2018 18:54:44 +0300 (EEST) Message-ID: <0B65DCA2835A4244B432B4AA48B6BDEE@dell2> From: "Andrus" To: "pgsql-general" Subject: How to migrate database from 10.1 to 9.1 Date: Sun, 13 May 2018 18:54:37 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="windows-1257"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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.