I’m reading Programming Phoenix LiveView and in one chapter they create a User table using the CLI
$ mix phx.gen.auth Accounts User users
This generate the following schema
// lib/pento/accounts/user.ex
schema "users" do
field :email, :string
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, :naive_datetime
timestamps()
end
I want to add a new field to this schema and to my database. I added field :username, :string to the schema
schema "users" do
field :email, :string
field :username, :string, null: false
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, :naive_datetime
timestamps()
end
And ran ecto migrate again
$ mix ecto.migrate
00:02:35.628 [info] Migrations already up
$ mix ecto.create
The database for Pento.Repo has already been created
But when I check my database the field isn’t there.
Whats the proper way to add fields and modify an schema?






















