Changing a database

My question is, and excuse me if I haven’t found it in the documentation, but, what is the preferred way of swapping out a database or rewriting its structure wholesale?

We have a Phoenix / Elixir application very happily deployed. It’s very alpha, and we’ve reached a point where we want to make big changes to some tables in the db. We can lose what’s already in there as we have a seeder to bring us back to a starting point.

Changes are substantial enough that we are going to rewrite a lot of the migrations. We understand we could write more migrations to alter, but we’re at the stage where rewriting is simpler and we can still get away with it.

I guess I’m looking for the equivalent to mix ecto.fresh that I can run from a release.ex file?

Thanks in advance.

https://hexdocs.pm/ecto/Mix.Tasks.Ecto.Drop.html
drop locally, change your migrations to what you want the new schema to be

Then on prod drop and create (mix ecto.create — Ecto v3.7.1)

Alex,

Thanks for the response, but, I was under the impression we don’t have access to mix tasks when using releases?

My suspicion is that I’d need to write some functionality in release.ex to perform the tasks I need. It might be better to just fire up a new db, attach it to the app, drop the old then run my new migrations.

I’m not familiar with the fly mix setup, but it looks like it’s available in the docker image, and it’s not a multistage image:

It seems as though mix is available in the dockerfile.

How are you running migrations?

Can you try running fly ssh console and tell me if that gives you access to do what you’re trying to do?