Documentation

Getting Started

Everything you need to design, build, and export database schemas with Hadio.

1

Installation & Setup

Install the Hadio CLI and authenticate with your account to get started.

Terminal
# Install the Hadio CLI globally
npm install -g @hadio/cli
 
# Authenticate with your account
hadio auth login
 
# Initialize a new project
hadio init my-database
You can also use Hadio directly in the browser at studio without installing the CLI.
2

Creating Your First Schema

Initialize a schema with a name, target database, and description.

TypeScript
// Create a new schema programmatically
import { Hadio } from "@hadio/sdk";
 
const hadio = new Hadio({ apiKey: process.env.HADIO_API_KEY });
 
const schema = await hadio.schemas.create({
name: "my-app-db",
database: "postgresql",
description: "Main application database",
});
3

Adding Tables & Attributes

Define tables with typed attributes, constraints, and default values.

TypeScript
// Add a users table
await hadio.tables.create(schema.id, {
name: "users",
attributes: [
{ name: "id", type: "uuid", primaryKey: true, default: "gen_random_uuid()" },
{ name: "email", type: "varchar(255)", unique: true, notNull: true },
{ name: "name", type: "varchar(255)", notNull: true },
{ name: "created_at", type: "timestamp", default: "now()" },
],
});
Attribute names must be unique within a table. Using duplicate names will throw a validation error.
4

Defining Relationships

Connect tables with foreign key relationships and cascade rules.

TypeScript
// Define a one-to-many relationship
await hadio.relationships.create(schema.id, {
from: { table: "users", attribute: "id" },
to: { table: "posts", attribute: "author_id" },
type: "one-to-many",
onDelete: "CASCADE",
});
5

Exporting Code

Export your schema to production-ready code in your preferred language and ORM.

Terminal
# Export to TypeScript (Drizzle ORM)
hadio export --schema my-app-db --lang typescript --orm drizzle
 
# Export to Python (SQLAlchemy)
hadio export --schema my-app-db --lang python --orm sqlalchemy
 
# Export raw SQL migrations
hadio export --schema my-app-db --format sql --output ./migrations

Key Concepts

Schema

A complete database design containing tables, relationships, and constraints.

Table

A data entity with named attributes, types, and constraints like PK/FK.

Attribute

A column in a table with a data type, default value, and optional constraints.

Relationship

A connection between tables — one-to-one, one-to-many, or many-to-many.

Migration

A versioned set of SQL statements that evolves your database schema.

Workspace

An isolated environment containing schemas, settings, and team members.

Canvas Controls

Input
Action
Scroll
Zoom in/out
Space + Drag
Pan canvas
Ctrl + Click
Multi-select tables
Ctrl + A
Select all
Ctrl + 0
Reset zoom
Ctrl + F
Fit to screen

API Reference

Method
Endpoint
Description
GET
/api/v1/schemas
List all schemas in your workspace
POST
/api/v1/schemas
Create a new schema
GET
/api/v1/schemas/:id
Get schema by ID with all tables
PUT
/api/v1/schemas/:id
Update an existing schema
POST
/api/v1/schemas/:id/export
Export schema to code