This directory contains various scripts for managing FlexPrice data and operations.
Assigns a specific plan to all customers who don't already have a subscription for it.
Usage:
go run scripts/main.go -cmd assign-plan -tenant-id <tenant_id> -environment-id <environment_id> -plan-id <plan_id>Example:
go run scripts/main.go -cmd assign-plan -tenant-id "tenant_123" -environment-id "env_456" -plan-id "plan_01JV2ZF6B57XZ7MRW72Q2QWQ98"What it does:
- Lists all customers in the specified tenant/environment
- Checks which customers already have an active subscription for the specified plan
- Creates new subscriptions for customers who don't have the plan
- Uses the following default subscription settings:
- Currency: USD
- Billing Cadence: RECURRING
- Billing Period: MONTHLY
- Billing Period Count: 1
- Billing Cycle: CALENDAR
- Start Date: Current time
Output: The script provides detailed logging including:
- Number of customers processed
- Number of subscriptions created
- Number of customers skipped (already have plan, inactive, etc.)
- Any errors encountered
Synchronizes all prices from a plan to existing subscriptions.
Usage:
go run scripts/main.go -cmd sync-plan-prices -tenant-id <tenant_id> -environment-id <environment_id> -plan-id <plan_id>seed-events: Seed events data into Clickhousegenerate-apikey: Generate a new API keyassign-tenant: Assign tenant to useronboard-tenant: Onboard a new tenantmigrate-subscription-line-items: Migrate subscription line itemsimport-pricing: Import pricing datareprocess-events: Reprocess events
- List all available commands:
go run scripts/main.go -list- Run a specific command:
go run scripts/main.go -cmd <command-name> [flags...]Scripts typically require these environment variables (set via command flags):
TENANT_ID: The tenant identifierENVIRONMENT_ID: The environment identifierPLAN_ID: The plan identifier (for plan-related scripts)
When adding new scripts:
- Create the script function in
scripts/internal/ - Add the command to the
commandsslice inscripts/main.go - Update this README with usage instructions