Crates.io | fimi |
lib.rs | fimi |
version | 0.1.3 |
source | src |
created_at | 2024-11-03 20:01:16.699775 |
updated_at | 2024-11-03 20:18:41.213831 |
description | A generic migration framework |
homepage | |
repository | https://github.com/aaronhallaert/fimi-rs |
max_upload_size | |
id | 1434155 |
size | 14,638 |
🚧 Disclaimer: work in progress 🚧
File migrations made easy.
The purpose of this repository is to offer a framework for configuration file migrations, akin to database migrations. Fimi
is designed to be generic, handling various file content types (e.g., JSON, YAML) without concern.
This crate does not impose any restrictions on the migration itself; it is entirely up to the programmer implementing the migration. The migration code should be able to run independently of this framework.
The fimi
crate delivers the core business logic for this framework, while fimi_magic
includes procedural macros to support this logic.
The crate tracks executed migrations by keeping record in a manifest file.
/// see `fimi_example` to explore the complete example
mod migrations {
/// the migration modules have a name convention of _*datetimeId*_*migration_name*
mod _20241021212814_init_migration {
use fimi::Migration;
pub struct InitMigration;
impl Migration for InitMigration {
fn up(&self) -> Result<(), Box<dyn std::error::Error>> {
// implement this
Ok(())
}
fn down(&self) -> Result<(), Box<dyn std::error::Error>> {
// implement this
Ok(())
}
}
}
use fimi_magic::migrations;
/// the arguments of this macro are modules
/// each module should have a public accessible struct with the same name as the migration
/// that implements the `fimi::Migration` trait.
/// (here: InitMigration & AddNewKeyToTestStructs)
migrations!(
_20241021212814_init_migration,
_20241022110124_add_new_key_to_test_structs
);
}
fn main() {
let executor = migrations::migrations();
executor.up();
}
cargo fimi
) in the project where the migrations exist 🤔fimi-rs
differs in the fact that the migrations are generic and are not tied to SQL / specific database connections.