Checking github actions workflow migrations

Is there a way to check if Github workflows (actions) actually runs migrations?
I am in the process of squashing migrations and ended up feeding the squashed .sql file generated through mix ecto.dump to my migration.
When running Github actions, i have a step that does the mix do ecto.create, ecto.migrate and i see the logs of the migration running however inside of my alias for test i have something like `mix do ecto.drop --quiet, ecto.create --quiet, ecto.migrate – quiet, run priv/repo/seeds.exs" which should bring up a database from scratch and run seeds however when running that command it seems to not migrate correctly as when seeding it is trying to insert into a table that is not there e.g.

** (Postgrex.Error) ERROR 42P01 (undefined_table) relation "" does not exist

    query: INSERT INTO "user"."post" ("id","content","created_at","updated_at") VALUES ($1,$2,$3,$4)
    (ecto_sql 3.9.1) lib/ecto/adapters/sql.ex:913: Ecto.Adapters.SQL.raise_sql_call_error/1

This is working locally so this im puzzled how this translates onto github actions.

Thanks in advance!

A few possible ideas:

  1. Are you setting MIX_ENV=test in GitHub Actions? Maybe mix do ecto.create, ecto.migrate is running in the dev Mix env, which might create different conditions than what you’re doing locally?
  2. Can you remove the --quiet flag from the test alias as a test, and let CI run? That way you’ll have logs of what’s happening.
1 Like

yep! i was setting MIX_ENV=test inside of the github actions.

The problem was running mix ecto.migrate did not do what i thought it was doing. After running the migrations i checked my db to see if the migrations made it in and it was a completely blank db. The dump was not loading the way it should’ve for reasons i don’t know but after squashing migrations and adding them again as if they were fresh everything worked as it should

Did you add a step in your test alias to load the squashed sql between running create and migrate? i.e. something like

  defp aliases do
      test: [
        "ecto.create --quiet",
        "ecto.load -d priv/repo/schema-squash-dump.sql -f --skip-if-loaded --quiet",

You’d likely want something similar in your setup alias, i.e.

"ecto.setup": ["ecto.create", "ecto.load -d priv/repo/schema-squash-dump.sql -f --skip-if-loaded", "ecto.migrate"],