I am moving my app from Rails to Phoenix and as part of this I have to move my database from being managed by Rails migrations to Phoenix migrations. Here is how I did it:
- Rename the
schema_migrations
table. Phoenix uses Ecto for managing the database. Ecto and Rails use a table calledschema_migrations
to store the database migration info. So, you’ll have to rename it to avoid errors when you run Ecto migrations.1
2psql db
ALTER TABLE schema_migrations RENAME TO rails_schema_migrations - After this, you’ll need to create the schema_migrations table for ecto, you
can do it by running the
mix ecto.create
command. This will set up theschema_migrations
table in the existing database.
Now, you’ve successfully migrated your database. And, you can run your Phoenix/Ecto migrations like you would in a normal phoenix app.
I am currently working on LiveForm which makes
setting up contact forms on your website a breeze.