Crates.io | cqlmig-cdrs-tokio |
lib.rs | cqlmig-cdrs-tokio |
version | 0.0.1 |
source | src |
created_at | 2023-02-09 11:25:44.425456 |
updated_at | 2023-02-09 11:25:44.425456 |
description | CDRS Tokio client implementation of cqlmig. |
homepage | https://github.com/rm3dom/cqlmig |
repository | https://github.com/rm3dom/cqlmig |
max_upload_size | |
id | 780668 |
size | 10,322 |
Run migrations on a CQL database (Casandra or ScyllaDB).
This crate is alpha! Use with caution!
cqlmig simply runs a list of migrations on a database with the following caveats / guarantees:
migrate
multiple times with out-of-order versions will not produce an error unless the database produces one.
In other words cqlmig does not error if a previous version is run after a more recent version.
This scenario normally happens when an older branch was merged with older migrations.
Ideally you want to catch this scenario in your PR's, or better have your pipelines fail, rather than panicking at runtime.
Not trying to justify it ;) happy to add an option flag in for it if your requirements are different.extern crate core;
use std::borrow::Borrow;
use std::error::Error;
use std::path::Path;
use cdrs_tokio::cluster::NodeTcpConfigBuilder;
use cdrs_tokio::cluster::session::{SessionBuilder, TcpSessionBuilder};
use cdrs_tokio::load_balancing::RoundRobinLoadBalancingStrategy;
use cqlmig_cdrs_tokio::{CdrsDbSession, CqlMigrator, DbSession, Migration};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let cluster_config = NodeTcpConfigBuilder::new()
.with_contact_point(String::from("localhost:9042").into())
.build()
.await
.unwrap();
let db = TcpSessionBuilder::new(
RoundRobinLoadBalancingStrategy::new(),
cluster_config)
.build()
.unwrap()
.borrow()
.into();
CqlMigrator::default()
.with_logger(|s| println!("{}", s))
.migrate(&db, Migration::from_path(Path::new("/migrations").into()).unwrap())
.await?;
Ok(())
}
This project is licensed under either of
at your option.