Phoenix(Elixir) graphql api undefined table

Hi, I am new to fly, and I am currently facing something that was unexpected.

My app gets deployed correctly and no errors are found during the deployment process.
The problem comes out when attempting to run a query of whatever type on graphql.
I have created some mutations and queries but when I run any of them i receive an “internal server error” on the interface.
So i checked the logs of my application through flyctl logs, and I noticed this error message:

Request: POST /graphiql
2021-06-26T15:20:36.935668655Z app[1ce47362] fra [info] ** (exit) an exception was raised:
2021-06-26T15:20:36.936744908Z app[1ce47362] fra [info] ** (Postgrex.Error) ERROR 42P01 (undefined_table) relation “articles” does not exist
2021-06-26T15:20:36.938079698Z app[1ce47362] fra [info] query: SELECT a0.“id”, a0.“content”, a0.“title”, a0.“user_id”, a0.“inserted_at”, a0.“updated_at” FROM “articles” AS a0
2021-06-26T15:20:36.939174110Z app[1ce47362] fra [info] (ecto_sql 3.6.2) lib/ecto/adapters/sql.ex:760: Ecto.Adapters.SQL.raise_sql_call_error/1
2021-06-26T15:20:36.940138114Z app[1ce47362] fra [info] (ecto_sql 3.6.2) lib/ecto/adapters/sql.ex:693: Ecto.Adapters.SQL.execute/5
2021-06-26T15:20:36.941112547Z app[1ce47362] fra [info] (ecto 3.6.2) lib/ecto/repo/queryable.ex:224: Ecto.Repo.Queryable.execute/4
2021-06-26T15:20:36.942074300Z app[1ce47362] fra [info] (ecto 3.6.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
2021-06-26T15:20:36.943200312Z app[1ce47362] fra [info] (skwerd_bits_api 0.1.0) lib/skwerd_bits_api_web/resolvers/articles.ex:10: SkwerdBitsApiWeb.Resolvers.Articles.get_articles/2
2021-06-26T15:20:36.943940577Z app[1ce47362] fra [info] (absinthe 1.6.4) lib/absinthe/resolution.ex:206: Absinthe.Resolution.call/2
2021-06-26T15:20:36.945222708Z app[1ce47362] fra [info] (absinthe 1.6.4) lib/absinthe/phase/document/execution/resolution.ex:230: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
2021-06-26T15:20:36.946523428Z app[1ce47362] fra [info] (absinthe 1.6.4) lib/absinthe/phase/document/execution/resolution.ex:185: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/3

Apparently the table I am referencing is not present in the database, from what I can understand.
I followed the elixir app deployment tutorial, and it also covers the migrations but from what I see, no migration has been executed.

Does anyone know how to solve this issue?
I tried to log into my postgres database but with no success. The documentation wasn’t really helpful to understand how to do it.
So I have no way to check the database status by myself.

If more info is needed please let me know

I had a couple of migration issues yesterday that I resolved by logging in with fly ssh console and then running path/to/app eval AppWeb.Release.migrate - assuming you have added release.ex.

Hi, thanks for your answer.
I tried to do as you suggested me, but the command returned:

/ # /app/bin/skwerd_bits_api eval ‘SkwerdBitsApi.Release.migrate’
SkwerdBitsApi.Repo
15:48:11.790 [info] Migrations already up

So apparently the migrations have already been executed. Is there a way to check the database tables?

I found the solution reading this post: https://elixirforum.com/t/migrations-not-being-run-detected-on-a-deployed-mix-release/38680/4

The problem I had was the same. I had dumbly commented out the line of the dockerfile that copies the priv folder containing all the migrations. (COPY priv priv)

2 Likes