Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/onesoft-sudo/sudobot/llms.txt

Use this file to discover all available pages before exploring further.

SudoBot uses Drizzle ORM for database schema management. Migration files live in the drizzle/ directory and are applied using BlazeBuild’s migrate task or a manual script when BlazeBuild is not available (e.g. on Windows).

Running migrations with BlazeBuild

This is the recommended approach on Linux and macOS:
./blazew migrate
This command connects to the database specified in DB_URL, applies any pending migrations from the drizzle/ directory, and creates or updates the required tables.
Always back up your PostgreSQL database before running migrations on a production instance.

Running migrations manually

If BlazeBuild is unavailable or you are on Windows, you can run migrations with a small script.
Create migrate.ts in the project root:
migrate.ts
import "dotenv/config";

const { drizzle } = await import(String("drizzle-orm/node-postgres"));
const { migrate } = await import(String("drizzle-orm/node-postgres/migrator"));
const { Pool } = await import(String("pg"));

const pool = new Pool({ connectionString: process.env.DB_URL });
const db = drizzle(pool);
await migrate(db, { migrationsFolder: "drizzle" });
await pool.end();
Run it:
bun migrate.ts

Docker automatic migrations

When running via Docker Compose, SudoBot checks the .migration_status file on startup. If it is empty, migrations run automatically before the bot starts. You do not need to run migrations manually for Docker deployments on first start.

Verifying migration status

Connect to your PostgreSQL database and check the __drizzle_migrations table to see which migrations have been applied:
SELECT * FROM __drizzle_migrations ORDER BY created_at DESC;

Prerequisites

Make sure DB_URL is set in your .env file before running migrations:
.env
DB_URL=postgresql://username:password@hostname:5432/sudobot

Build docs developers (and LLMs) love