Files
dimgigov 4a83eb6783 docs: update distributed/backup/schema/storage for multi-database
- Add multi-database limitations to distributed docs
- Fix backup commands and add multi-database backup guidance
- Add SQL migration section to schema docs
- Update storage examples to use per-database paths
2026-05-21 09:44:25 +03:00

1.6 KiB

Schema System

BaraDB uses a schema-first design with type inheritance and automatic migrations.

Defining Types

import barabadb/schema/schema

var s = newSchema()

let person = newType("Person")
person.addProperty("name", "str", required = true)
person.addProperty("age", "int32")
s.addType("default", person)

Type Inheritance

let employee = newType("Employee")
employee.setBases(@["Person"])
employee.addProperty("department", "str")
s.addType("default", employee)

# Resolve inheritance — Employee gets name, age, department
let resolved = s.resolveInheritance(employee)

Schema Operations

Diff

Compare two schemas:

let diff = s.diff(oldSchema, newSchema)

Migrations

Schema changes are tracked and can generate migration scripts.

SQL Migrations

BaraDB supports SQL-level migrations executed through BaraQL:

-- Create a migration table
CREATE MIGRATION TABLE my_migration;

-- Apply pending migrations
MIGRATION UP;

-- Rollback last migration
MIGRATION DOWN;

-- Apply all pending migrations in batch
MIGRATION UP BATCH;

-- Dry-run to preview changes
MIGRATION DRYRUN;

-- Check migration status
MIGRATION STATUS;

Migration scripts are stored inside each database's LSMTree and are isolated per database. When using multiple databases, run USE DATABASE <name> before executing migration commands.

Property Types

Type Description
str String
int32 32-bit integer
int64 64-bit integer
float32 32-bit float
float64 64-bit float
bool Boolean
datetime Date/time value
bytes Binary data