New role system: - owner: full access + financials - admin: full access + financials (except org deletion) - executive: read-only + full financial visibility (MRR, revenue) - technician: field ops (devices, sites, alerts) without financials - member: legacy alias for technician (migrated) - viewer: read-only, no financials Financial data (MRR, revenue, billing) gated behind can_view_financials assign in all LiveView templates: dashboard, alerts, trace, site show. Includes migration to rename existing member roles to technician.
30 lines
1.2 KiB
Elixir
30 lines
1.2 KiB
Elixir
defmodule Towerops.Repo.Migrations.AddExecutiveAndTechnicianRoles do
|
|
use Ecto.Migration
|
|
|
|
@moduledoc """
|
|
Migrates existing 'member' roles to 'technician'.
|
|
|
|
The role column is a varchar (Ecto.Enum handles validation in app code),
|
|
so no DDL changes needed — just data migration.
|
|
|
|
New roles added:
|
|
- 'executive' — read-only with full financial visibility
|
|
- 'technician' — replaces 'member', field ops without financial access
|
|
"""
|
|
|
|
def up do
|
|
# Migrate existing 'member' memberships to 'technician'
|
|
execute "UPDATE organization_memberships SET role = 'technician' WHERE role = 'member'"
|
|
execute "UPDATE organization_invitations SET role = 'technician' WHERE role = 'member'"
|
|
end
|
|
|
|
def down do
|
|
# Revert technician back to member
|
|
execute "UPDATE organization_memberships SET role = 'member' WHERE role = 'technician'"
|
|
execute "UPDATE organization_invitations SET role = 'member' WHERE role = 'technician'"
|
|
|
|
# Revert executive to admin (closest equivalent)
|
|
execute "UPDATE organization_memberships SET role = 'admin' WHERE role = 'executive'"
|
|
execute "UPDATE organization_invitations SET role = 'admin' WHERE role = 'executive'"
|
|
end
|
|
end
|