Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u8eHa-009MaZ-DG for pgsql-novice@arkaria.postgresql.org; Sat, 26 Apr 2025 12:05:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u8eHY-003c05-Lu for pgsql-novice@arkaria.postgresql.org; Sat, 26 Apr 2025 12:05:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u8eHY-003bzx-D3 for pgsql-novice@lists.postgresql.org; Sat, 26 Apr 2025 12:05:21 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u8eHW-0023Lm-2f for pgsql-novice@lists.postgresql.org; Sat, 26 Apr 2025 12:05:20 +0000 Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3d46ef71b6cso28570445ab.3 for ; Sat, 26 Apr 2025 05:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745669118; x=1746273918; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tBUkmnBPMwe4Z9JnVppUWpI7llfBtHtKi3s+jhfsjaU=; b=D0i/iWVnXOPRoX+0oBKJ1f1+SNkFUC0c6z3CdQHaFaTsoipINJP5l/ocMhpG8rMBRF Or31coybGsQU+HVH0iWPVjVFbynuDxcKkoYFdz0sM3m1x9ToTzyrDCr+XN6AC/2N8AKT Le1uOiqVH29jhLsiY7ModDoX4NPJ98VN0YE4LRMd8k8NgefwzbSrnPefmAF0CzJ/OT7Q MS+Pk+q6MdmCebS0qCF4+H671KvMsooEJJ4B0PoLKuwhpBeqn/jiRJM4vrAOjRDdV7u1 CYU4FUgd9c8CzmOE0TKZW0zzANsVbcNnYbCviANKBtub8n9yLGhA5rz1k072GRTPpWWO qZWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745669118; x=1746273918; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tBUkmnBPMwe4Z9JnVppUWpI7llfBtHtKi3s+jhfsjaU=; b=sg6e+m/9K6lUiXLQot2lCxIB9XQX7/mGvYMf+uKdgb3rsMu2/ZYuiAXvcbqhqV4l0E gS3bXI15bAAGYTBCcwSwcWXGu2p9n7IBpVbxJ7wMB+zxqABMKXgV7Ea5cZWrXMZ9dGfW F53ivg2MaM2HnyGT1EwQHtbCZLzGa3WO3nlxZ3W2fDZhQfRKXQ4mThhizBOnwjLMXErL A0LtdJwEfewSVB9tgKiEYKF3WgaP6+jd45gy1lM7grEsf0d5ZXRtXK8URUf9KqGch97L GSevZXuIZ63lL2NZsQR53HH+WxMba0bjbigr9y+HehOcbdb24qXajnVaq+ciGOjkdQDk QvTg== X-Forwarded-Encrypted: i=1; AJvYcCX7a5tBPUkfrbiKUIjsk7oai0+sVLuRikuiGKA9+9j394ue9KDIS3sDMUmHSOSw+Hn4OlbQE7Ckg1AEw94=@lists.postgresql.org X-Gm-Message-State: AOJu0YwMW/KEaCN14LdMdIFuT/YfSHheOuThOMHgRqYjt6HRWfNOWoy9 W3cWPK+k6UcerUPB022raGBjHKZ5TWICRCpx7UWMZQeK6rjJRgz3GyjMdLviD4XgDAILt/NMl// Pt87AzzOVPlSnlTg7DWvV67gOPbE= X-Gm-Gg: ASbGnctoii1A2b3dMLaT/WskALwThH5oQT5kcn22yYder6hBv6RK4Khj+1jSp53buR9 qcCheUbmehJxkHiAuexphGjbOup+pwQM06aDWI0FYY4Bp9yJHt+IqjULTJTlc+u8YlZWwczEWFi VY3dW73hTZyNGUb1lAHq7aYnx3p9LgTn4sP28NIJxI9xomNq78S/ZloVe4 X-Google-Smtp-Source: AGHT+IGHoM8GPP8N4VKwkHa4Ubo248jQTxf98PVF6mLwkwGX2nlBjTeai12LhZdSW2At9HY55hGD0vxfcKsRZGJ41OM= X-Received: by 2002:a05:6e02:3990:b0:3d4:6e2f:b487 with SMTP id e9e14a558f8ab-3d93b1bf8b6mr62099215ab.0.1745669118391; Sat, 26 Apr 2025 05:05:18 -0700 (PDT) MIME-Version: 1.0 References: <9b32b21c0b85692f99213a5adb4cf07dd43d3ad3.camel@cybertec.at> In-Reply-To: From: Greg Sabino Mullane Date: Sat, 26 Apr 2025 08:04:43 -0400 X-Gm-Features: ATxdqUE7yPHgx7hQPTFfMPZXD_WEkp_xgU0tbmnAyc2P8Z9NUJDgc6hPBFsyVzM Message-ID: Subject: Re: PGDump question/issue To: Ayden Gera Cc: Laurenz Albe , pgsql-novice@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000b2815f0633ad43c2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b2815f0633ad43c2 Content-Type: text/plain; charset="UTF-8" > > 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 --000000000000b2815f0633ad43c2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
SaaS provided PGDump

Is this a c= ustom dump, or just a bunch of ASCII ? Run "file" against it to f= ind out.

=C2=A0Im open to any other ideas on how to get around the drop table th= at comes in PG Dump from DB A.

Sounds like = these=C2=A0drop tables are a good thing. You asked about removing all the d= ata. DROP TABLE does that. Further, if the schema sent by the SaaS ever=C2= =A0changes, 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-exi= sts as part of that).

If your dumps are custom, th= e solution Laurenz provided is a good one.

If it i= s *only* RLS that needs to be recreated, that can be done. It's weird y= ou don't have a list somewhere of your=C2=A0current=C2=A0settings, 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=3Dpost-data | grep -E 'ROW LEVEL SECUR= ITY|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 fro= m SaaS

// Re-apply the RLS information:
= psql --single-transaction --set=3DON_ERROR_STOP=3Don -f mydb.rls.sql
<= div>
// Bonus step:
git commit mydb.rls.sql -m &quo= t;Latest RLS for my database"


--
Cheers,
Greg

--
Enter= prise Postgres Software Products & Tech Support

--000000000000b2815f0633ad43c2--