gcb

gcb

(this is similar to Generate migrations from Ecto.Schemas or use those Ecto.Schemas to create tables in database but i still don’t have an application… so the proposed solution ecto.dump doesn’t really apply)

I’m just starting out an elixir application using the whole mix package (phx, ecto) for the first time.

The initial migration seems extremely backwards to me. But i’m not that versed on ORMs either. I can see why I wouldn’t want migrations after the DB exists to screw up tables and such. But for the initial one, I honestly cannot see any advantage.

What is bugging me most is, i will spend probably several days authoring a bunch of Schema in my repo. Then, i will have to repeat line by line all the tables/fields into my initial migration file. Not to mention that at this time, until I have anything in production, i want to collapse all my “migrations” into a initial one anyone.

Does this make sense? anyone have any work around to save the initial work on this? any workflow that is more practical not covered on the official guide?

Showing Posts 1 to 6

gcb

gcb OP

or, does everyone ignores all that and uses phx.gen.schema right away?

…it was kinda confusing as the phx guides makes me go trhu the ecto guides first.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

I’m a bit low on time so I can’t reply to your whole post but this part at least is pretty normal:

At least until my project is on some other developer’s computer, it’s perfectly fine to just edit your initial migrations and mix ecto.reset.

gcb

gcb OP

it’s perfectly fine to just edit your initial migrations and mix ecto.reset.

makes sense, but i would rather to “redo my initial-migration-from-schemas and mix ecto.reset” :wink:

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

If you’re at that point, the workflow I generally use is to write out the mix phx.gen commands I run, and then I just edit those as I want to tweak stuff and just keep deleting the lib / priv directories until things are the way I want. This also helps solve any html boilerplate (if applicable).

gcb

gcb OP

i see. so the usual process is to ignore echo.migration initial and never manually editing Schemas/Migrations.Create_xxx, and going straight to mix phx.gen?

edit: …and then manually tweaking the fields not present on the html/api endpoints? sigh…

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

@gcb I haven’t read the books you’re referring to in a long time, so I don’t know what you mean by ecto.migration initial. You asked about alternative work flows and I’m saying I jump straight in to phx.gen. This minimizes the tweaking.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
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
achenet
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
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
unaware8150
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
dillonoconnor
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
thiagogsr
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New

Other Trending Topics Top

GenericJam
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
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
KristerV
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews