Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

use timestamp (to seconds precision) for versions #95

Closed
wants to merge 5 commits into from

Conversation

jmhodges
Copy link
Contributor

@jmhodges jmhodges commented May 1, 2016

Depends on #94. That'll need to be reviewed and merged first.

This is backwards compatible with the current incrementing mechanism and won't cause issues for teams with differing versions of migrate.

Using timestamps instead of an incrementing counter reduces the chances of conflicts and invalid migrations states after merging in another branch of code. Since people tend to work on orthogonal parts of the codebase, having to coordinate over incrementing an integer tends to cause merge issues late in the process of putting their code all together.

Along the way, we have to handle the fact that the original MySQL and PostgreSQL tables for migration versions used 32-bit integers instead of 64-bit integers. We inspect the column types of their migration tables and upgrade them non-destructively to 64-integers at the same time we check that the migration table exists. The other databases seem to already have the correct table types.

We also have to introduce a Clock interface for testing the new code well. A Clock is just a handy way to control for time in tests. Since we're constrained by the public API, the Clock instance is a global we swap out during tests. This is not ideal, but usable.

Newer docker-composes (with newer YAML parsers) see the "yes" as a
boolean type and reject it. So, make it a string explicitly.
Depends on mattes#94. That'll need to be reviewed and merged first.

Using timestamps instead of an incrementing counter reduces the chances of conflicts and invalid migrations states after merging in another branch of code. Since people tend to work on orthogonal parts of the codebase, having to coordinate over incrementing an integer tends to cause merge issues late in the process of putting their code all together.

Along the way, we have to handle the fact that the original MySQL and PostgreSQL tables for migration versions used 32-bit integers instead of 64-bit integers. We inspect the column types of their migration tables and upgrade them non-destructively to 64-integers at the same time we check that the migration table exists. The other databases seem to already have the correct table types.

We also have to introduce a Clock interface for testing the new code
well. A Clock is just a handy way to control for time in tests. Since
we're constrained by the public API, the Clock instance is a global we
swap out during tests. This is not ideal, but usable.
@jmhodges
Copy link
Contributor Author

jmhodges commented May 1, 2016

(It'd probably be wise for me to point out that prior art for this exists in ActiveRecord migrations and other similar projects.)

@gravis
Copy link
Contributor

gravis commented May 1, 2016

Duplicate of #58 ?

@jmhodges
Copy link
Contributor Author

jmhodges commented May 1, 2016

Oh, hunh, didn't know that patch existed. If it picked up some of the stuff for backwards compatibility this patch has, it might be easier for folks to switch to.

@jmhodges
Copy link
Contributor Author

jmhodges commented May 1, 2016

Well, it strictly would be easier. Would be nice for that to happen!

@jmhodges jmhodges mentioned this pull request May 1, 2016
@dacamp
Copy link
Contributor

dacamp commented Oct 23, 2016

Dup of #73

@mattes mattes closed this Dec 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants