Ecto migration to Rails database

Hi everyone,

I have a Rails 5 application that I am trying to write part of it with elixir.

When I generated the ecto migration and tried to migrate, I got the following error.

** (Postgrex.Error) ERROR 42703 (undefined_column) column “inserted_at” of relation “schema_migrations” does not exist

The schema_migrations currently in the database was generated my rails activerecord.
Is there a way to make both activerecord and ecto use the same schema_migrations table ?

Yes it’s possible…

timestamps inserted_at: :created_at


I mean… it’s possible to use the same timestamp fields, but for the schema migration I don’t know.

1 Like

Thanks for the reply.

But still get same error
** (Postgrex.Error) ERROR 42703 (undefined_column) column “inserted_at” of relation “schema_migrations” does not exist

I’m not sure if it is possible to re-use the rails migrations table, though I wouldn’t even want to try it.

The schema_migrations table of both “migration” entities might change their structure into different directions in the future, or might already have done so, beyond the already mentioned column name.

Anyway, there should never be more than a single entity responsible for the database schema.

You will run into problems if you try to manage the DB schema from both worlds.


It is not. @clem what we did for a while when moving a database from a rails app to an elixir app is that while we still ran the rails app, it did all the migrations. Then once we eventually could turn off the rails app, we nuked the schema_migrations table and started doing migrations in Elixir.


As mentioned by @benwilson512, you can’t run migrations from rails and Ecto in the same database. They use the same table name but with a slightly different schema.

1 Like

I have a rails/phoenix app running on same db, you absolutely need ONE app responsible for migrations…

However I have used migration_source: "ecto_schema_migrations", and then the phoenix/ecto is responsible for all future migrations - so that is also a possibility…


Thank you all