backfill-customer-role

command
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Command backfill-customer-role provisions the global "Customer" role in the database and assigns it to customer-portal account users.

It is idempotent (fixed IDs; syncs to an exact state) and safe to re-run. It:

  1. creates the global Customer role (role_type "user", account_id NULL) if absent,
  2. syncs its role_permission rows to EXACTLY customerRolePermissions (adds missing, removes stale),
  3. backfills account_user.role_id = <Customer role> for every ACTIVE account_user of a customer (counterparty) account,
  4. migrates any lingering references off the legacy role id and removes it.

Usage:

DB_URL=<dsn-or-mysql-url> go run ./cmd/backfill-customer-role --dry-run
DB_URL=<dsn-or-mysql-url> go run ./cmd/backfill-customer-role

Flags:

--dry-run          report what would change; make no writes.
--skip-subscribed  also skip accounts that have their own active/trialing
                   subscription (real merchants who are also someone's customer).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL