Skip to content

Migration Race Condition #16

Description

@nulldispatch

Due to the way tern manages its schema_versions table, it's relatively easy to create a situation where a slightly older migration will never get run on a developer or CI machine in a distributed team setting.

The scenario:

If two developers make separate migrations at roughly the same time and the first developer to push is also the one with the more recent migration timestamp, the migration from the second developer will not be run on their machine. This problem can promote to deployed environments where there is continuous deployment (we use Circle CI to push all passing commits to our staging env).

Potential solution:

Rather than using the current mechanism for determining if a migration has run or not:

https://github.com/bugsbio/lein-tern/blob/master/src/tern/migrate.clj#L27-L31

schema_versions could be treated as a set and when a migration's timestamp is not present, it is run.

Any thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions