Skip to content
المشاريع

حول

SQLX migration using Rust insted of SQL

البيانات والتحليلات

كيف تُقاس هذه الأرقام

ما يمكنك فعله

  • Migrations as Rust values with parents, replaces and run_before.
  • Operations as code, SQL strings or embedded SQL files.
  • CLI (apply, revert, redo, list, repair, prune) and RunReport.
  • Locking, failed migration tracking and hooks.

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

SQLX migrator

A Rust library for writing SQLX migrations using Rust instead of SQL.

License Crates Version Docs
License: MIT Crate Docs

Supported databases: PostgreSQL, SQLite and MySQL.

Features

  • Migrations as Rust values with parents, replaces and run_before.
  • Operations as code, SQL strings or embedded SQL files.
  • CLI (apply, revert, redo, list, repair, prune) and RunReport.
  • Locking, failed migration tracking and hooks.
  • Sync from other migration tools.

Installation

Enable postgres, mysql or sqlite (and json for CLI JSON output):

sqlx_migrator = { version = "0.21.0", features = ["postgres"] }

Quick start

use sqlx_migrator::migrator::{Migrator, Plan};
use sqlx_migrator::vec_box;

struct CreateSample;

// an operation is a `(up, down)` pair of SQL strings, or implement `Operation`
// for code
sqlx_migrator::postgres_migration!(
    CreateSample,
    "main",
    "create_sample",
    vec_box![],
    vec_box![(
        "CREATE TABLE sample (id INTEGER PRIMARY KEY, name TEXT)",
        "DROP TABLE sample"
    )]
);

#[tokio::main]
async fn main() {
    let pool = sqlx::PgPool::connect(&std::env::var("DATABASE_URL").unwrap())
        .await
        .unwrap();
    let mut conn = pool.acquire().await.unwrap();

    let mut migrator = Migrator::default();
    migrator.add_migration(Box::new(CreateSample)).unwrap();
    migrator.run(&mut *conn, &Plan::apply_all()).await.unwrap();
}

Documentation

See the crate docs for the guide, locking, CLI, hooks and sync.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…