There are already multiple questions and answers touching this subject, How to use Flyway when working with feature branches for example, but none answers the question I have. It might even not be possible to solve.
Say I have a simple stored procedure:
CREATE PROCEDURE GetSomeData AS
SELECT Id, CreateDate, Stuff
FROM Data
Now two different feature branches are created, and both features needs to change the same SP. Feature A creates the first change-script, 20160414104532__limit_data.sql
:
ALTER PROCEDURE GetSomData
SELECT Id, CreateDate, Stuff
FROM Data
WHERE CreateDate > DATEADD(day,-7,GETDATE())
And feature B needs to add a column to the output. However the teams working with the different features are located in different parts of the world, and really doesn't know anything about each other. They create 20160413153225__add_column.sql
:
ALTER PROCEDURE GetSomData
SELECT Id, CreateDate, Stuff, Things
FROM Data
When one of the features are completed, it will be merged into the production branch. Three weeks later, the second feature is completed, and merged into production. Here is the dilemma, the second feature will overwrite the stored procedure that was changed by the first feature, and we will potentially have a bug in production.
The real solution here is of course to merge the procedure, but since the scripts are independent of each other, there is no indication of a conflict during the merge. The only way to find out that something bad has happened, is to run the code and find out at runtime.
Are there any simple solutions or workarounds to find these kinds of issues earlier in the process? Maybe flyway isn't the tool to use in these kinds of environments? If not, what are the alternatives?