Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1euI2h-00019h-5h for pgsql-general@arkaria.postgresql.org; Fri, 09 Mar 2018 13:26:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1euI2g-000078-7H for pgsql-general@arkaria.postgresql.org; Fri, 09 Mar 2018 13:26:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1euI2f-00006z-So for pgsql-general@lists.postgresql.org; Fri, 09 Mar 2018 13:26:37 +0000 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1euI2d-0004jD-48 for pgsql-general@lists.postgresql.org; Fri, 09 Mar 2018 13:26:37 +0000 Received: by mail-qk0-x241.google.com with SMTP id s188so3579430qkb.2 for ; Fri, 09 Mar 2018 05:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:message-id:date:to; bh=yfI/4uXSBZi9moB992YOnL6kG3TufyVg6LWvM/NJNaM=; b=E8JSUFn24hK5TUaW7lpj+1TbqUsrJHrZ89BbpS9wMVai+Q9VvYHYlfrZBEnDTTdM29 uuAg5ngp0622Z8sZ2Ckp7QJQNRkAc8p7JAKFOMBHLniiYdOs0k7pHZ8hVSozBIo589Ks +O7ijCpfzNoTxxgP3jsUys+NZvUU+TXr7qGZcSTQ7llxbyDmFkz4wJNvdExccih0gQ6L kb5t/L68Mt01M+d8maFireoWjeJNo15jbvewXSVBebB9XNryoJnjrgAk14ZN+z6WJzXm fEuhnaXjoiSB3XETTkMlGoX2WB7hvIXJp3us3kjS+ySFlmI08td2BgixYRwMuwpLkENr CN6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=yfI/4uXSBZi9moB992YOnL6kG3TufyVg6LWvM/NJNaM=; b=LmwlLnpx0866F/A45bwQF5urjVN5RKK7+q50KSaRm4T3uj8Fnd2AWimwTR6/pazQKS CHDmciwM/GO8IOkYKwyBVCMsXb9XNbG6tEXxBnsXELumcMH+WU6K2oCLsl/D+cYMjxzo aXFP2YltcFUTQh1hiSODgN8Y0xlyRXTke3J9lKZtrS8q9z/E7XEq1tx32m8aD1oWihlf HFI2IxYjw57OeS3h7cPok/T0AnnSms9BEg2Nv0cuzaLjJP3pEMs60CJkEiRabsOgdLvd ZAV+Ke8mGZga5SUImLmW8e7iOWrgLe43nSDmScsdTzA4qjY/GWyCCfYPUf4L2MXaUC+o 2x5A== X-Gm-Message-State: AElRT7H+AR29k/qVpXZt8I/KUWw8vAd/yBEYSqyKilt6FtCM5peGCgpv x98xppkl6UHl0M2wiJxloDFeXxGs X-Google-Smtp-Source: AG47ELsMIXd+jkAofqAYTcKCTnHLhtuKW/Pf9/08vsXlNZiaqxA0+hWI14mmt5uma7rv+owFf4cshQ== X-Received: by 10.55.18.18 with SMTP id c18mr42580402qkh.207.1520601991901; Fri, 09 Mar 2018 05:26:31 -0800 (PST) Received: from [10.0.111.50] (pc-92-113-120-200.cm.vtr.net. [200.120.113.92]) by smtp.gmail.com with ESMTPSA id t24sm486907qtn.77.2018.03.09.05.26.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 05:26:31 -0800 (PST) From: Aldrin Martoq Ahumada Content-Type: multipart/alternative; boundary="Apple-Mail=_9ADC9E03-7DC2-4108-B104-3333542CAD6A" Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Postgresql upgrade to 9.5.12/10.3 changes pg_dump format for cloning schemas Message-Id: Date: Fri, 9 Mar 2018 10:26:28 -0300 To: pgsql-general@lists.postgresql.org X-Mailer: Apple Mail (2.3445.5.20) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_9ADC9E03-7DC2-4108-B104-3333542CAD6A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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/80a21f2e1cdcbe5b0bd976f88c143= 32657804536/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=E2=80=99s not a generic/robust = solution. # pg_dump postgresql 9.5.11 SET search_path =3D 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? =E2=80=94=20 Aldrin --Apple-Mail=_9ADC9E03-7DC2-4108-B104-3333542CAD6A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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.














= --Apple-Mail=_9ADC9E03-7DC2-4108-B104-3333542CAD6A--