broken code
This commit is contained in:
parent
7aac7852fa
commit
c90e3b201c
|
@ -1,15 +1,16 @@
|
|||
use crate::Result;
|
||||
use async_trait::async_trait;
|
||||
use clickhouse::Client;
|
||||
use futures::Future;
|
||||
|
||||
#[async_trait]
|
||||
pub trait Migratable {
|
||||
async fn run(&self, db: &Client) -> anyhow::Result<()>;
|
||||
async fn run(&self, db: &Client) -> Result<()>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Migratable for &str {
|
||||
async fn run(&self, db: &Client) -> anyhow::Result<()> {
|
||||
async fn run(&self, db: &Client) -> Result<()> {
|
||||
db.query(self).execute().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -19,9 +20,9 @@ impl Migratable for &str {
|
|||
impl<F, O> Migratable for F
|
||||
where
|
||||
F: Fn(&Client) -> O + Sync + Send,
|
||||
O: Future<Output = anyhow::Result<()>> + Send,
|
||||
O: Future<Output = Result<()>> + Send,
|
||||
{
|
||||
async fn run(&self, db: &Client) -> anyhow::Result<()> {
|
||||
async fn run(&self, db: &Client) -> Result<()> {
|
||||
self(db).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,10 +45,12 @@ MATERIALIZE PROJECTION channel_log_dates",
|
|||
)
|
||||
.await?;
|
||||
|
||||
run_migration(db, "4_try_new_format", asd).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_migration(db: &Client, name: &str, migratable: impl Migratable) -> Result<()> {
|
||||
async fn run_migration<T: Migratable>(db: &Client, name: &str, migratable: T) -> Result<()> {
|
||||
let count = db
|
||||
.query("SELECT count(*) FROM __rustlog_migrations WHERE name = ?")
|
||||
.bind(name)
|
||||
|
@ -70,6 +72,10 @@ async fn run_migration(db: &Client, name: &str, migratable: impl Migratable) ->
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn asd(db: &Client) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn create_migrations_table(db: &Client) -> Result<()> {
|
||||
db.query(
|
||||
"
|
||||
|
|
Loading…
Reference in New Issue