Adds a boolean is_admin column (default false) and has the registration changeset auto-set it to true when the email matches graham@mcintire.me (case-insensitive). The migration also backfills the flag for an existing row with that email.
17 lines
361 B
Elixir
17 lines
361 B
Elixir
defmodule Microwaveprop.Repo.Migrations.AddIsAdminToUsers do
|
|
use Ecto.Migration
|
|
|
|
def up do
|
|
alter table(:users) do
|
|
add :is_admin, :boolean, null: false, default: false
|
|
end
|
|
|
|
execute "UPDATE users SET is_admin = true WHERE email = 'graham@mcintire.me'"
|
|
end
|
|
|
|
def down do
|
|
alter table(:users) do
|
|
remove :is_admin
|
|
end
|
|
end
|
|
end
|