Generate migrations and add fields on a command line

I am writing a library for which I need migrations to run on the user’s system who is using the library and I will keep the schema inside the library. I have found mix phx.gen.schema but it creates schemas with migrations. In mix ecto.gen.migration we couldn’t pass fields names, just the migration name.
I also looked at the mix generators but they create boilerplate code that I don’t need.
Is there any way we can create just migrations with fields names on a command line.
Thanks.

I think, there’s no existed command like what you said. But you can write you own by referencing code provided by Phoenix:

Strip contents related to schema. The rest part is what you need.

1 Like

You can set --change option, but it looks like it’s not documented, so it may be considered as a private API which may change.

3 Likes