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

Avoid version collisions #58

Closed
wants to merge 11 commits into from

Conversation

gravis
Copy link
Contributor

@gravis gravis commented Oct 28, 2015

Don't use incremental integers, as it will fail with large teams. This PR is using timestamps instead of versions, like ruby on rails does since a few years now, the same reasons.

"Earlier" migrations will be processed when a branch is merged. ie: if 20060102150405 and 20060102150406 have been applied already, 20060102150403 can be applied afterwards.

The migration will fail if 2 versions have the same id, this was already the case.

Note that the schema changed for some DB, moving from int to bigint. I also have removed the counter column from cassandra (and a lot of code based on booleans).

@gravis
Copy link
Contributor Author

gravis commented Oct 28, 2015

closes #45

@gravis
Copy link
Contributor Author

gravis commented Oct 28, 2015

Cassandra is starting too slowly, and is not available when the tests are running, I'll figure out something. Ideas are welcome.

@gravis
Copy link
Contributor Author

gravis commented Oct 28, 2015

done

@fervic
Copy link

fervic commented Nov 2, 2015

Hi @gravis I was wondering why this used auto-incremented numbers when Rails' Activerecord migrations had moved to timestamps long ago.

👍 for this PR, hopefully it gets merged soon.

@mattes
Copy link
Owner

mattes commented Nov 11, 2015

Can we fix the tests? Happy to merge this.

@gravis
Copy link
Contributor Author

gravis commented Nov 11, 2015

I have no idea why Cassandra is failing with:

migrate_test.go:43: java.lang.IllegalArgumentException: Unknown keyspace/cf pair (migrate.schema_migrations)

I'll try to add more time to wait for startup

@AlekSi
Copy link

AlekSi commented Feb 1, 2016

👍

Philippe Lafoucrière added 10 commits March 22, 2016 17:48
This change insert a timestamped version into schema migration table,
instead of incrementing a field. That way, we have a history of passed
migrations.
Next step: Apply all pending migrations.
Pending migrations being the list of all migrations from files, except
the ones already applied (d.Versions())
sleeping is unrelevent here, the docker-compose command is launched
after the sleep
@gravis
Copy link
Contributor Author

gravis commented Mar 22, 2016

@mattes
All green now. I discovered why the tests where failing randomly: go test is actually running tests in parallel, which is not compatible with database acceptance tests.
It's probably worth rewriting the history of this commit into a single one.

Cheers,
Philippe

@gravis gravis mentioned this pull request Mar 24, 2016
@raphaeljlps
Copy link
Contributor

We really need this merged, please take a look @mattes

@gravis
Copy link
Contributor Author

gravis commented Apr 21, 2016

@raphaeljlps you can use our fork until that: https://github.com/gemnasium/migrate
It's rebased against master.

@raphaeljlps
Copy link
Contributor

@gravis thank you, thats just what I was going to do

@eolexe
Copy link

eolexe commented Apr 21, 2016

@gravis is there a way to migrate old migration files ?

@gravis
Copy link
Contributor Author

gravis commented Apr 21, 2016

Unfortunately, no :(
Your best option is probably to concat all of them in a brand new migration file (idem for all downs)
Sorry

@jmhodges
Copy link
Contributor

jmhodges commented May 1, 2016

Prompted by comments on #95, I've ported to gemnasium/migrate fork the ability to be backwards compatible with mattes/migrate. See gemnasium/migrate#3

@kenng
Copy link

kenng commented Jul 17, 2016

waiting for this to be merged, though already started using @gravis fork...

@VMitov
Copy link

VMitov commented Sep 10, 2016

Any updates on this?

@mattes mattes closed this Dec 22, 2016
@gravis gravis deleted the avoid-version-collisions branch January 24, 2017 20:31
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.

9 participants