sir-eel

Crates.iosir-eel
lib.rssir-eel
version0.1.0
created_at2025-07-04 17:05:30.46935+00
updated_at2025-07-04 17:05:30.46935+00
descriptionA SurrealDB migration tool
homepagehttps://github.com/DanOlson/sir-eel
repositoryhttps://github.com/DanOlson/sir-eel
max_upload_size
id1738222
size2,705,094
(DanOlson)

documentation

README

Sir Eel

Sir Eel is a lightweight and easy-to-use database migration tool for SurrealDB. It provides a simple CLI and programmatic API to help you manage your database schema changes.

Sir Eel

Features

  • Simple, file-based migrations
  • CLI for generating and running migrations
  • Programmatic API for more complex workflows
  • Lightweight and easy to integrate

CLI

Installation

Install the CLI using cargo:

cargo install sir-eel

Usage

init

Initialize a sir-eel.toml configuration file in your project root.

sir-eel init

This will create a sir-eel.toml file with the following contents:

[sir-eel]
db_url = "rocksdb://data"
database = "mydatabase"
namespace = "mynamespace"
migrations_dir = "migrations"

Update the values in this file to reflect your needs. Note that the default persistence layer for SurrealDB supported by the CLI is RocksDB.

generate

Generate a new migration file.

sir-eel generate "create users table"

This will create a new file in the migrations_dir with a timestamp and the provided name, e.g., migrations/20231027123456_create_users_table.surql.

migrate

Apply all pending migrations.

sir-eel migrate

You can also perform a dry run to see which migrations would be applied without actually running them:

sir-eel migrate --dry-run

Programmatic API

Sir Eel can also be used programmatically in your Rust applications.

Example

use sir_eel::{Config, Migrator};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::builder()
        .db_url("memory")
        .database("test")
        .namespace("test")
        .migration_dir("migrations")
        .build()?;

    let migrator = Migrator::new(config).await?;

    // Generate a new migration
    migrator.generate("create_users")?;

    // Run pending migrations
    migrator.run().await?;

    Ok(())
}

API

  • Migrator::new(config: Config): Creates a new Migrator instance.
  • migrator.generate(name: &str): Generates a new migration file.
  • migrator.run(): Runs all pending migrations.
  • migrator.pending_migrations(): Returns a list of pending migrations.
Commit count: 0

cargo fmt