romenigld
Ecto generate migration with references with mix on the terminal command
I was trying this command for generate a migration for many to many:
mix ecto.gen.migration create_albums_genre album_id:references:albums:unique genre_id:references:genres:unique
but I receive an error:
** (Mix) expected ecto.gen.migration to receive the migration file name, got: "create_albums_genre album_id:references:albums:unique genre_id:references:genres:unique"
I know is possible to use this references command because I used before. But for the generate not works!
Which kind of ecto commands it will be useful using this references by the mix terminal command?
Marked As Solved
germsvel
I’m not a 100% sure, but I think you might be thinking of mix phx.gen.schema. That one allows you to use things like name:string album_id:references:albums, etc.
I always get those confused too. I find mix help ecto.gen.migration and mix help phx.gen.schema help me figure out what I can and cannot pass as options.
Also Liked
romenigld
joey_the_snake
Generating a schema and generating a migration are 2 very different things. When you generate a schema you know you are doing a single create action. Migrations can be many different actions, with multiple actions in the same migration.
For instance, you could create 5 tables. Should all of them have the same reference? Or you can be altering an index. Or modifying a column name.
Last Post!
joey_the_snake
Generating a schema and generating a migration are 2 very different things. When you generate a schema you know you are doing a single create action. Migrations can be many different actions, with multiple actions in the same migration.
For instance, you could create 5 tables. Should all of them have the same reference? Or you can be altering an index. Or modifying a column name.
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex










