prop/priv/repo/migrations/20260408163732_add_is_admin_to_users.exs
Graham McIntire eaef5b0178 Add is_admin flag, auto-grant to graham@mcintire.me
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.
2026-04-08 11:43:52 -05:00

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