DidactMacros

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

DidactMacros

Also Liked

garrison

garrison

It doesn’t look like phx.gen.context has a migration flag. But phx.gen.schema does.

Couldn’t tell you why.

garrison

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?

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New

We're in Beta

About us Mission Statement