How to apply programatically only change sets which wasn't run?

It is probably an issue with the changeset “path” being different. Part of unique identifier of each changeset is the path, and is stored in databasechangelog. If the way you reference the changeSet changes, the path can be different and so seem to be a new changeset.

If you “select * from databasechangelog” how does the path compare to the output that lists the current path?