use klickhouse::*;
mod embedded {
use refinery::embed_migrations;
// 指定sql文件路径
embed_migrations!("./src/sql_migrations/");
}
#[tokio::main]
async fn main() -> Result<()> {
// 建立与 Klickhouse 的连接
let mut client = Client::connect("172.xx.xxx.xx:9000", ClientOptions{
default_database: "default".to_string(),
username: "default".to_string(),
password: String::new(),
}).await?;
// 运行嵌入的数据库迁移
embedded::migrations::runner().run_async(&mut client).await.unwrap();
Ok(())
}
[dependencies]
chrono = "0.4.34"
futures = "0.3.30"
# klickhouse = "0.11.0"
klickhouse = { version = "0.12.0", features = ["refinery"] }
rand = "0.8.4"
tokio = { version = "1.26.0", default-features = false, features = ["full"] }
uuid = "1.7.0"
refinery = { version = "0.8"}
rusqlite = "0.31.0"
每个库都会生成一张refinery_schema_history元数据表,所以建议各个业务方以自己project名建库名,示例如下
Project:bigdata
database:bigdata
元数据表:bigdata.refinery_schema_history
元数据表所在节点:172.xx.xxx.xx
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。