How to test migration

I have a complex migration to transform some data and then to remove N columns.
Currently I use

|> Stream.each(fn struct ->
  # some logic here


alter table(:foobar) do
  remove :barfoo

The problem is once I run mix test it applies all new migrations and my code in test folder tries to test already missing columns. The current solution is to stop manually before this migration. Run single test. Continue on migrations and remaining tests. But it is done manually which is annoying. Is there any approach to cover this case with the same single mix test command comfort?

1 Like

So you changed your data with a migration, now your tests are failing.

I think the first thing it’s to be sure if it’s just some tests assertions that are expecting data that it’s not there anymore, or if it’s actually some code that’s not working properly.

Then fix whatever is wrong :+1: