However, I need few additional fields into my users table apart from pow_user_fields(). I have updated schema and added additional fields. However, when I try to registration, only pow_user_fields are populated in the users table. Other fields are just populated with null, though I am passing all fields with registration api.
Okay, so a few things come to mind without seeing your code.
First you want to create a new migration file with the new fields you want to add mix ecto.gen.migration update_users_table. This sets up your actual database table
def change do
alter table(:users) do
add :field_name, :field_type
end
end
Update the schema “users.ex” with the same fields you added to your migration file. This file is just a data model to describe a user from your database.
Now in the same schema you want to update your changeset with cast(data, params, permitted, opts \\ []). You want to pass atoms of the new fields in as a list. For example:
Cervajz,
Here is my users module. I was just using pow_changeset.
schema "users" do
field :name, :string
field :mobile, :string
field :role, :string, default: "user"
pow_user_fields()
timestamps()
end
def changeset(user_or_changeset, attrs) do
pow_changeset(user_or_changeset, attrs)
end
Are you adding these new fields to the registration form? I added a new field to the table, but I want to have the user fill in the value in the form. Were you able to do this?