Pretty straight forward situation. I added a field in a new migration and added the field to the User module’s schema.
Now a previous migration fails to run saying:
** (Postgrex.Error) ERROR 42703 (undefined_column): column u0.is_bot does not exist (db_connection) lib/db_connection.ex:1406: DBConnection.prepare_declare/4 (elixir) lib/stream.ex:1270: anonymous fn/5 in Stream.resource/3 (elixir) lib/stream.ex:1433: Enumerable.Stream.do_each/4 (elixir) lib/stream.ex:806: Stream.do_transform/8 (elixir) lib/stream.ex:1433: Enumerable.Stream.do_each/4 (elixir) lib/stream.ex:591: Stream.run/1 (ecto) lib/ecto/adapters/sql.ex:576: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3 (db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4
The migration code that can’t run looks like:
def up do Repo.transaction( fn -> User |> Repo.stream() |> Stream.each(fn user -> # Do something with `user`. end) |> Stream.run() end, timeout: :infinity ) end
Any suggestions on how to fix this situation? Locally, I can comment out the
is_bot field declaration and run the migrations, but this has broken CI completely for me.
What do you guys think of modifying my migration script to only select the fields it needs, thus preventing
is_bot from being attempted?