Hi Tom,

This is certainly interesting, but even more heavyweight than I was looking for ;-) I love the idea of really making sure the schema that results from running all the migrations is the same as the one from doing a create_all with your metadata.
Does alembic have anything like django's squashmigrations command yet?

Anyway, what I'm interested in is testing migrations in the presence of data, particularly migrations that have to do "fun stuff" with existing rows to create new rows. Those feel more like unit tests to me - "run a bunch of individual scenarios", rather than your excellent but integration-y "run them all and make sure they build the expected schema".

Thoughts?

Chris

On 23/11/2016 09:20, Tom Lazar wrote:
hi chris,

here’s how we do it in all our projects:

https://github.com/pyfidelity/rest-seed/blob/master/backend/backrest/tests/test_migrations.py

basically, our migrations start with an empty database, so we run them, dump 
the resulting SQL, then create a new database using the `metadata.create_all` 
feature and then normalize the results and compare. if there is a mismatch the 
test fails.

if you want to write more elaborate tests involving actual data, this should be 
a good starting point, though

HTH,

tom


On 23 Nov 2016, at 10:15, Chris Withers <ch...@simplistix.co.uk> wrote:

Hi All,

How do you go about writing automated tests for a migration?

I don't often do this, but when migrations involve data, I prefer to but now I 
don't know how ;-)
There's nothing in the docs, right? (or am I missing something obvious)

cheers,

Chris

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to