Skip to main content

Overview

MySQL 8 managed via Drizzle ORM. Schema is defined in shared/schema.ts — this is the single source of truth for all tables and types.

Local database (Docker)

# Start
docker-compose up mysql -d

# Connect via CLI
docker-compose exec mysql mysql -u dbuser -psin90is1 sahyogi

# Stop (keeps data)
docker-compose down

# Nuke everything (DELETES ALL DATA)
docker-compose down -v
Local credentials:
  • Host: localhost:3306
  • Database: sahyogi
  • User: dbuser
  • Password: sin90is1

Production database

Hosted on a managed MySQL instance (PlanetScale or equivalent — confirm with team lead for exact host). Connect with DATABASE_SSL=true.
Ask the team lead for prod DB credentials. Never commit credentials to git.

Migration commands

# Push schema changes directly to DB (dev — no migration files)
npm run db:push

# Generate SQL migration files
npm run db:migrate

# Seed the database with initial data
npm run db:seed

# Specific migration scripts
npm run db:setup-subscriptions
npm run db:add-user-fields
npm run db:create-access-control
npm run db:seed-access-control
npm run db:add-stripe-price-id
Drizzle config: drizzle.config.ts — outputs migrations to ./db/migrations/, reads schema from ./shared/schema.ts.

Key tables

TablePurpose
usersUser accounts, Stripe info, coin balance
botsAI bot configurations
channelsChannel integrations (whatsapp, telegram, gmail, web, twitter, linkedin)
gupshup_whatsapp_integrationsGupshup WhatsApp account config
whatsapp_accountsWhatsApp Business API accounts
conversationsConversation threads
messagesIndividual messages
whatsapp_message_infoDelivery/read receipts
campaignsCampaign templates and state
contactsCustomer contacts
contact_listsContact list groups
credentialsEncrypted API keys / OAuth tokens
integrationsThird-party integration records
toolsBot tools/extensions
webhooksUser-defined webhooks
training_filesUploaded PDFs for RAG
training_urlsURLs scraped for RAG
plansSubscription plan definitions
subscriptionsUser subscription state
teams / team_membersTeam management
roles / permissionsRBAC definitions