tor-metrics-datamodel

Crates.iotor-metrics-datamodel
lib.rstor-metrics-datamodel
version0.1.19-rc
created_at2025-08-07 06:48:14.45196+00
updated_at2025-09-24 09:09:59.080543+00
descriptionShared data model with entities and migrations
homepage
repository
max_upload_size
id1784759
size672,542
Sarthik Gupta (sarthikg)

documentation

README

DataModel

Library

The DataModel library provides a set of Rust structs that represent database table entities. These structs can be used to interact with the database in a type-safe and convenient way.

Usage

To use the DataModel library in your own Rust project, add the following dependency to your Cargo.toml file:

[dependencies]
data_model = { path = "/path/to/data_model" }

Then, import the library in your Rust code and use the provided structs to interact with the database:

use data_model::{BandwidthFile, BandwidthRecord, /* other entities */};

// Use the entities to interact with the database
let bandwidth_file = BandwidthFile::find(1).unwrap();

Binary

The DataModel library also provides a CLI for creating & running migrations.

Usage

  • Generate a new migration file
    cargo run -- generate MIGRATION_NAME
    
  • Apply all pending migrations
    cargo run
    
    cargo run -- up
    
  • Apply first 10 pending migrations
    cargo run -- up -n 10
    
  • Rollback last applied migrations
    cargo run -- down
    
  • Rollback last 10 applied migrations
    cargo run -- down -n 10
    
  • Drop all tables from the database, then reapply all migrations
    cargo run -- fresh
    
  • Rollback all applied migrations, then reapply all migrations
    cargo run -- refresh
    
  • Rollback all applied migrations
    cargo run -- reset
    
  • Check the status of all migrations
    cargo run -- status
    
Commit count: 0

cargo fmt