Getting Started
Everything you need to design, build, and export database schemas with Hadio.
On This Page
Installation & Setup
Install the Hadio CLI and authenticate with your account to get started.
# Install the Hadio CLI globallynpm install -g @hadio/cli # Authenticate with your accounthadio auth login # Initialize a new projecthadio init my-databaseCreating Your First Schema
Initialize a schema with a name, target database, and description.
// Create a new schema programmaticallyimport { 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",});Adding Tables & Attributes
Define tables with typed attributes, constraints, and default values.
// Add a users tableawait 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()" }, ],});Defining Relationships
Connect tables with foreign key relationships and cascade rules.
// Define a one-to-many relationshipawait hadio.relationships.create(schema.id, { from: { table: "users", attribute: "id" }, to: { table: "posts", attribute: "author_id" }, type: "one-to-many", onDelete: "CASCADE",});Exporting Code
Export your schema to production-ready code in your preferred language and ORM.
# 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 migrationshadio export --schema my-app-db --format sql --output ./migrationsKey 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.