cgrothaus
Mix/Ecto equivalent of `rails db:prepare`? (migrate db OR create and seed it)
Ruby on Rails has a rails db:prepare command. It migrates the database, if it exists, else it creates it, migrates it (or loads the schema, but that’s only a subtle difference) and seeds it. See Rails 6 adds rails db:prepare to migrate or setup a database | BigBinary Blog for more info.
I am wondering: does Phoenix have a similar command?
I know that a freshly generated Phoenix 1.7 app defines a mix alias ecto.setup in the mix.exs file, which does "ecto.create", "ecto.migrate", "run priv/repo/seeds.exs", that it is the latter part of what Rails does. But this is neither checking for db existence first, nor is it idempotent.
Marked As Solved
cgrothaus
Also Liked
hauleth
ecto.create is idempotent, ecto.migrate is also idempotent. To make seeding script idempotent you need to do it on your own, for Ecto it is just a simple script that you run within your application context, so it will be as idempotent as you write it to be.
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










