pg-schema-diff icon indicating copy to clipboard operation
pg-schema-diff copied to clipboard

Question : Can we have tables in destination but delete from source

Open bheemvennapureddy opened this issue 1 year ago • 6 comments

Use case : we want to have an option to delete source presence for a table which is deprecated but wanna keep in the destination for compliance reason or data validation reasons in case if that comes across.

Can we support some thing like that ?

bheemvennapureddy avatar Aug 27 '24 15:08 bheemvennapureddy

I might be a bit confused with this one. Could you give an example of the diff of your schema, the hypothetical command to plan your migrations, and the expected generated SQL? Thanks!

Navbryce avatar Aug 27 '24 16:08 Navbryce

You can probably ignore this

Use case: Lets say there is a table identity and we move away from that table to the user table and we still wanna keep the identity table in the destination but remove from the source code we don't want that table to be dropped by pg-schema-diff

bheemvennapureddy avatar Aug 27 '24 20:08 bheemvennapureddy

I can see this was closed, but there is a real world scenario where we would need to ignore separate objects (tables, functions, sequences), not just whole schemas. Apart from the scenarios mentioned earlier in the thread, there are librarires that create their own database objects on application startup (Hangfire, MassTransit...), and pg-schema-diff fails because it wants to drop them as we don't have them in the source code (and we shouldn't really).

As you suggested in another issue, for now what we can do is:

  • pg-dump --schema-only, and put them in the source
  • put them in a separate schema and ignore that schema

But I think it would be really nice if I can tell pg-schema-diff: ignore these and these objects.

bokidonev avatar Sep 18 '24 07:09 bokidonev

@bokidonev It is totally possible to ignore schema-level objects. What are you trying to ignore (tables, indexes, triggers, etc)? We'd probably have to implement it an object-to-object basis

bplunkett-stripe avatar Sep 19 '24 06:09 bplunkett-stripe

Thanks for reopening this. For my scenario, I'm trying to ignore tables, sequences and functions.

bokidonev avatar Sep 20 '24 12:09 bokidonev

Okay cool, that makes sense. I'll see if I can make something moderately generic to do this across most schema objects

bplunkett-stripe avatar Sep 21 '24 19:09 bplunkett-stripe