jackc / tern

The SQL Fan's Migrator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dependency-based or git-based conflict resolution

NanoBjorn opened this issue Β· comments

Became a bit annoyed with constant conflicts in a relatively big project πŸ˜„

I have a proposal to cover some cases, share your thoughts on it.

In sql it is pretty easy to understand dependent tables from parsing the query (I am sure there are some golang parsers for postgres sql), so maybe tern can auto-resolve conflicts when migrations do not intersect over table? Or this may have dangerous hidden mistakes? For sure it is not covering all the cases, but just a thought.

Another thing is it may be useful to have a separate command with conflict resolution and different strategy. Another strategy that I came up with is git-based β€” if there are duplicates and one file is already committed, then let's automatically increase the number for the second one? you still check what is being committed before commit so it should not be dangerous

In sql it is pretty easy to understand dependent tables from parsing the query (I am sure there are some golang parsers for postgres sql), so maybe tern can auto-resolve conflicts when migrations do not intersect over table? Or this may have dangerous hidden mistakes? For sure it is not covering all the cases, but just a thought.

I think there would be too many edge cases for this to be handled automatically.

Another thing is it may be useful to have a separate command with conflict resolution and different strategy. Another strategy that I came up with is git-based β€” if there are duplicates and one file is already committed, then let's automatically increase the number for the second one? you still check what is being committed before commit so it should not be dangerous

It's not automatic but there already is a command to do something like this. See https://github.com/jackc/tern#renumbering-conflicting-migrations.

Got it, thansk!