Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Users using the Alog approach #56

Open
RobStallion opened this issue Mar 29, 2019 · 4 comments
Open

Updating Users using the Alog approach #56

RobStallion opened this issue Mar 29, 2019 · 4 comments
Labels
bug Something isn't working question Further information is requested

Comments

@RobStallion
Copy link
Member

I am currently in the process of trying to update all the users in my database to add new columns to the table.

I tried using the Alog update function which inserts a new row with the updated information but this is giving me an error because it is changing my email_hash and password values. (Also using dwyl fields)

This is an issue because it means that if I update the user that user can no longer log into the application.

If I change the Alog update function to Repo.update(User, params) it works fine but we have no record of the change.

@nelsonic do you have any thoughts on this?

@RobStallion RobStallion added question Further information is requested bug Something isn't working labels Mar 29, 2019
@RobStallion
Copy link
Member Author

User.all()
  |> Enum.map(fn(user) ->
  params =
    case user.admin do
      true ->
        %{
          role: "site_admin",
          verified: user.inserted_at
        }

      _ ->
        %{role: "venue_admin"}
    end

  user
  |> Ecto.Changeset.cast(params, [
  :email, :password, :admin, :role, :verified, :password_reset_token,
  :password_reset_token_sent_at
  ])
|> User.update()

This is the type of function that I have written

@nelsonic
Copy link
Member

@RobStallion why is adding a couple of new fields changing the email_hash and password values?

@RobStallion
Copy link
Member Author

@nelsonic It's not the addition of the new fields that is changing the email_hash and password. It's the User.update (Alog.update) function which appears to be changing the values.

@nelsonic
Copy link
Member

@RobStallion That shouldn't happen ... 😕
If you have time to screen-share (remote pair) on this, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants