Skip to content

How-To Create New Tenants for a New Account

This guide walks you through the process of creating a new tenant for a new account in our multi-tenant system. Follow these steps to set up a new tenant successfully.

Prerequisites

  • Necessary permissions to create databases and users
  • The following environment variables set:

  • POSTGRES_HOST

  • POSTGRES_USER
  • POSTGRES_PASSWORD

Step-by-Step Guide

1. Prepare the Account Information

Gather the following information for the new account:

  • Account name
  • Tenant ID (usually the same as the account name)
  • Admin email
  • Connection provider (either "microsoft" or "google")

2. Run the Create New Account Command

Use the create_new_account command to set up the new account and tenant. Open your terminal and run:

python -m scripts.manage_db create_new_account

You will be prompted to enter the following information:

  • New account name
  • Tenant ID
  • Admin email
  • Connection provider

Example:

New account name: NewCompany
Tenant ID: new-company
Admin email: admin@newcompany.com
Connection provider: google

3. Behind the Scenes

The create_new_account command performs the following actions:

a. Generates a tenant lookup identifier from the admin email domain. b. Calls the _create_new_account function, which:

- Connects to the admin database
- Creates a new account entry
- Calls `_create_tenant_db` to set up the tenant's database

4. Verify Tenant Creation

After the command completes, verify that:

  • The new account appears in the admin database
  • A new database for the tenant has been created

You can check this by connecting to your PostgreSQL instance and listing the databases.