DidactMacros
The --no-migration flag, does not prevent the generation of mirgrations when used with phx.gen.context
It is stated that the default gen settings can be overridden with use of appropriate options,
Default options
This generator uses default options provided in the :generators configuration
of your application. These are the defaults:
config :your_app, :generators,
migration: true,
binary_id: false,
timestamp_type: :naive_datetime,
sample_binary_id: "11111111-1111-1111-1111-111111111111"
You can override those options per invocation by providing corresponding
switches, e.g. --no-binary-id to use normal ids despite the default
configuration or --migration to force generation of the migration.
however preventing the generation of a migration using the --no-migration key does not seem to work.
mix phx.gen.context Testex Testa testas --no-migration
* creating lib/schem_exp/testex/testa.ex
* creating priv/repo/migrations/20250210111130_create_testas.exs
* creating lib/schem_exp/testex.ex
* injecting lib/schem_exp/testex.ex
* creating test/schem_exp/testex_test.exs
* injecting test/schem_exp/testex_test.exs
* creating test/support/fixtures/testex_fixtures.ex
* injecting test/support/fixtures/testex_fixtures.ex
Remember to update your repository by running migrations:
$ mix ecto.migrate
Then I discard the generated files via version control and run again with phx.gen.context, get the same result. Do the discard again and this time run with phx.gen.schema:
mix phx.gen.schema Testa testas --no-migration
* creating lib/schem_exp/testa.ex
No migration generated.
Is it the case that migration generation with contexts can only be prevented by amending the defaults ? (doing does indeed actually prevent migration generation)
Marked As Solved
DidactMacros
Also Liked
garrison
It doesn’t look like phx.gen.context has a migration flag. But phx.gen.schema does.
Couldn’t tell you why.
garrison
I think it parses the opts using the phx.gen.context switches before passing the parsed opts to phx.gen.schema.
But since the phx.gen.context switches don’t include a migration flag it gets removed before the schema is generated (with the migration).
That should probably be considered a bug. Maybe open an issue?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









