Running migrations for existing postgres table

I created an app earlier and ran mix phx.gen.context Dashboards Order orders orderid:string progress_status:integer
and then mix ecto.migrate

then, I deleted that old project and gave it a fresh start by starting from scratch. and ran mix phx.gen.context Dashboards Order orders orderid:string progress_status:integer again.(after basic setup)
mix ecto.migrate – throws an error saying db is already made.

I want to use existing table. How do I?

You can take a look a this comment from Jose Valim

Phoenix keeps control of the migrations using a table named schema_migrations. This table contains the list of the already applied migrations.

Running mix ecto.migrations shows the status of the migrations. In this case you have to manually synchronize the table’s content with your migrations files.

Manually add the corresponding entry to the schema_migrations table and remove previous entries if necessary.

1 Like

If the previous migration exists. Then add the column you want to change in the new migration. Create a new migration basically and recover the previous migration.

1 Like

if this is totally local you can do a mix ecto.drop to remove the old database and start it fresh with mix ecto.create.

2 Likes