Hello, on any app I have been working on the last couple of days it has been giving me this error when I go to run an app with a module.
# there are pending migrations for repo: LiveViewTodos.Repo. Try running `mix ecto.migrate` in the command line to migrate it
running the mix ecto.migrate does not do anything. Here is an example of something simple that I have done in my todo_live.ex file.
defmodule LiveViewTodosWeb.TodoLive do
use LiveViewTodosWeb, :live_view
def mount(_params, _session, socket) do
{:ok, socket}
end
def render(assigns) do
~L"Rendering LiveView"
end
end
There is a table created automatically by Ecto called schema_migrations. This table contains a list of all the migrations that are already applied to the database. Each row corresponds to a migration file that starts with a timestamp.
In your case, it seems that you have one entry in your schema_migrations table:
20210714024300
However, in the corresponding folder at priv/repo/migrations you have this file:
20210720024531_create_todos
As you can realize, the timestamps in the table and in the files do not correspond.
20210714024300 != 20210720024531
Somehow, the file that starts with 20210714024300 is missing in your folder.
Warning, the following solution is not common, and it should not be used unless you know the risks. Normally, data in schema_migrations table is handled automatically by Ecto.
If you are sure that you do not need the missing migration file, you can remove by hand the corresponding entry in the schema_migrations table. After that, running mix ecto.migrations should not show any messages.
As it seems that you are running some experiments, another option is delete the database, recreate it and run the migrations again with the following command.
mix ecto.drop
mix ecto.create
mix ecto.migrate
Warningmix ecto.drop destroys your development database.