Re: How to migrate database from 10.1 to 9.1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrus" <kobruleht2(at)hot(dot)ee>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to migrate database from 10.1 to 9.1
Date: 2018-05-13 19:03:40
Message-ID: 32257.1526238220@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Andrus" <kobruleht2(at)hot(dot)ee> writes:
> 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
> ...
> if this database is restored to Postgres 9.1 from custom backup using
> ...
> automatic primary key generation stops working.

This is a bit unfortunate, because it's not obvious to the naked eye that
a SERIAL column (I assume you actually defined the column as SERIAL?) is
using any new-in-v10 syntax. But it is. If you'd looked at the error
output you'd have noticed that the CREATE SEQUENCE command is getting a
syntax error:

psql:testv10.dump:58: ERROR: syntax error at or near "AS"
LINE 2: AS integer
^

You'd need to edit the dump output to remove the "AS integer" clause
in order to get this dump to load into a pre-v10 server.

Alternatively, I believe creating the column as BIGSERIAL would result in
dump files that would reload into older servers without adjustments.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-05-13 19:46:42 Re: Domain based on TIMEZONE WITH TIME ZONE
Previous Message Andrus 2018-05-13 15:54:37 How to migrate database from 10.1 to 9.1