Re: Postgresql upgrade to 9.5.12/10.3 changes pg_dump format forcloning schemas - Mailing list pgsql-general

From Andre Oliveira Freitas
Subject Re: Postgresql upgrade to 9.5.12/10.3 changes pg_dump format forcloning schemas
Date
Msg-id CAN6ijTAhW9f08z6GkASVKMWV-FmwFbfYALyZVmGzCL_fzD18-g@mail.gmail.com
Whole thread Raw
In response to Postgresql upgrade to 9.5.12/10.3 changes pg_dump format for cloningschemas  (Aldrin Martoq Ahumada <aldrin.martoq@gmail.com>)
Responses Re: Postgresql upgrade to 9.5.12/10.3 changes pg_dump format forcloning schemas
List pgsql-general
Hello Aldrin,

I'm also using apartment with postgresql 9.6.6, and I don't see any
issue with it. Are you using Apartment::Tenant.create?

2018-03-09 10:26 GMT-03:00 Aldrin Martoq Ahumada <aldrin.martoq@gmail.com>:
> Hi,
>
> For a multi tenant system, we are using the following command to blindly
> clone a schema into another:
> pg_dump -s -x -O -n #{default_tenant} #{dbname}
>
>
> This is done for us by a rails gem, which then feeds that script into the
> new created schema for the new tenant.
>
https://github.com/influitive/apartment/blob/80a21f2e1cdcbe5b0bd976f88c14332657804536/lib/apartment/adapters/postgresql_adapter.rb#L150
>
>
>
>
> When we upgraded from 9.5.11 to 9.5.12, the format of the dump changed (it
> now always appends the schema name), so this is broken. We could patch the
> SQL generated, but that’s not a generic/robust solution.
>
> # pg_dump postgresql 9.5.11
> SET search_path = public, pg_catalog;
> CREATE TABLE ahoy_events (
>     id bigint NOT NULL,
>     visit_id integer,
>     user_id integer,
>     name character varying,
>     properties jsonb,
>     "time" timestamp without time zone
> );
>
> # pg_dump postgresql 9.5.12
> CREATE TABLE public.ahoy_events (
>     id bigint NOT NULL,
>     visit_id integer,
>     user_id integer,
>     name character varying,
>     properties jsonb,
>     "time" timestamp without time zone
> );
>
>
>
> Thinking in the long term, how could be the best way to clone a schema into
> another?
>
>
>
>
> —
> Aldrin
>



--

André Luis O. Freitas
System Architect

Rua do Rócio, 220 - Cj. 72
São Paulo - SP - 04552-000
55 11 4063 4222

afreitas@callix.com.br
www.callix.com.br


pgsql-general by date:

Previous
From: Herwin Weststrate
Date:
Subject: Feature request: min/max for macaddr type
Next
From: David Steele
Date:
Subject: Re: Barman versus pgBackRest