public inbox for [email protected]  
help / color / mirror / Atom feed
From: Greg Sabino Mullane <[email protected]>
To: Ayden Gera <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: [email protected]
Subject: Re: PGDump question/issue
Date: Sat, 26 Apr 2025 08:04:43 -0400
Message-ID: <CAKAnmm+BKpMQXiL2ZdXMMf_xg97o_iY0WigFBe2nQ=yU=q++0w@mail.gmail.com> (raw)
In-Reply-To: <CANYJdWKsznOaaka97FRwHgDFJBTJ2YU9g_S-S5xC_rh+T1Vb0Q@mail.gmail.com>
References: <CANYJdW+Zq=CUbyMLiVqQ3nipS4S=W_Jn6J_bY=49qw1EDbBwyg@mail.gmail.com>
	<[email protected]>
	<CANYJdWKsznOaaka97FRwHgDFJBTJ2YU9g_S-S5xC_rh+T1Vb0Q@mail.gmail.com>

>
> SaaS provided PGDump


Is this a custom dump, or just a bunch of ASCII ? Run "file" against it to
find out.

 Im open to any other ideas on how to get around the drop table that comes
> in PG Dump from DB A.


Sounds like these drop tables are a good thing. You asked about removing
all the data. DROP TABLE does that. Further, if the schema sent by the SaaS
ever changes, you would want to know that, so it's in your best interest to
keep it's schema-creation commands around (which has the drop-if-exists as
part of that).

If your dumps are custom, the solution Laurenz provided is a good one.

If it is *only* RLS that needs to be recreated, that can be done. It's
weird you don't have a list somewhere of your current settings, but here's
another workaround to create the list on the fly and apply it:

// Save the existing RLS information to a file:
pg_dump -d mydb --section=post-data | grep -E 'ROW LEVEL SECURITY|CREATE
POLICY' > mydb.rls.sql
// Eyeball mydb.rls.pg to make sure it look sane; that's not a 100%
bulletproof regex

// Import the schema from SaaS

// Re-apply the RLS information:
psql --single-transaction --set=ON_ERROR_STOP=on -f mydb.rls.sql

// Bonus step:
git commit mydb.rls.sql -m "Latest RLS for my database"


-- 
Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support


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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: PGDump question/issue
  In-Reply-To: <CAKAnmm+BKpMQXiL2ZdXMMf_xg97o_iY0WigFBe2nQ=yU=q++0w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox