switched to 'native' Ecto.Enum for user week_starts_at field
This commit is contained in:
parent
4c673508b5
commit
aabcd9e029
6 changed files with 15 additions and 16 deletions
priv/repo
|
@ -8,7 +8,7 @@ defmodule Shift73k.Repo.Migrations.CreateUsersAuthTables do
|
|||
add(:id, :binary_id, primary_key: true)
|
||||
add(:email, :citext, null: false)
|
||||
add(:hashed_password, :string, null: false)
|
||||
add(:week_start_at, :integer, null: false)
|
||||
add(:week_start_at, :string, null: false)
|
||||
add(:confirmed_at, :naive_datetime)
|
||||
timestamps()
|
||||
end
|
||||
|
|
|
@ -55,6 +55,10 @@ extra_mock_users = ~s([
|
|||
{"email":"kat@73k.us","password":"katkatA1","role":"manager","inserted_at":"2018-12-14T01:06:01Z","confirmed_at":true}
|
||||
])
|
||||
|
||||
# for random week_start_at values
|
||||
[head | tail] = Shift73k.Util.Dt.weekdays()
|
||||
week_starts = [head | Enum.drop(tail, 4)]
|
||||
|
||||
mock_users =
|
||||
extra_mock_users
|
||||
|> Jason.decode!()
|
||||
|
@ -66,7 +70,7 @@ mock_users =
|
|||
email: e["email"],
|
||||
role: String.to_existing_atom(e["role"]),
|
||||
hashed_password: Bcrypt.hash_pwd_salt(e["password"]),
|
||||
week_start_at: :rand.uniform(2),
|
||||
week_start_at: Enum.at(week_starts, Enum.random(0..2)),
|
||||
inserted_at: add_dt,
|
||||
updated_at: add_dt,
|
||||
confirmed_at: (e["confirmed_at"] && NaiveDateTime.add(add_dt, 300, :second)) || nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue