stripe / pg-schema-diff

Go library for diffing Postgres schemas and generating SQL migrations
MIT License
355 stars 25 forks source link

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

Open bheemvennapureddy opened 1 month ago

bheemvennapureddy commented 1 month ago

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 ?

Navbryce commented 1 month ago

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!

bheemvennapureddy commented 1 month ago

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

bokidonev commented 3 weeks ago

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:

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

bplunkett-stripe commented 3 weeks ago

@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

bokidonev commented 3 weeks ago

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

bplunkett-stripe commented 2 weeks ago

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