cro
Newbie question here, I am experienced with Django. I create a model and associated migration and run the migration to create the tables. However, if I then refactor the model significantly (add a bunch of foreign keys, change field types) the Django migration manager is pretty good about figuring out what needs to be done to bring the database in line with the model. Sometimes the best thing to do is to remove all the interim migrations and allow Django to create the initial migration fresh, but in Phoenix I started with mix phx.gen.schema. What’s the right way to “start over” for a particular schema?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
There’s nothing comparable in elixir/ecto. The biggest reason for that being that ecto does not enforce the notion of a 1:1 mapping between schemas and db tables. There can be multiple schemas per table and neither schema holding all the columns on the table. The ecto schema in your codebase is in no way a source of truth to implicitly describe the (complete) db table. DB tables and schemas can evolve completely unrelated from each other.
This is a quite different mindset I’d imagine from what I read Django’s doing.
The other part is that generators in phoenix are just “generators”. They’re neither part of ecto (the db layer) nor actually meant to be used for more than giving you a starting boilerplate. So to start over you could run the generator again, but it’ll just generate from scratch.
cro
I agree, this represents a different approach philosophically between the two frameworks (neither good nor bad, just different).
So what would be the right approach if I decide that my first
mix phx.gen.schemawas a bust and I need to do it again? How do I tell Phoenix to throw out the old migrations and how do I know which files I need to delete before I try to run the schema gen again?kokolegorille
You can get help with…
You just need to delete the schema, and the migration file.
cro
OK
that was the only permutation of
helpI did not try, so TIL. Thank you for responding!dimitarvp
For future reference, you can just run
mix helpin your project and it will show you all tasks that are relevant to it (libraries included).