diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..4ae4509 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: vporton # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 2508597..4e2f1a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use tokio_postgres::GenericClient; +use tokio_postgres::Client; pub struct Migration { tablename: String, @@ -9,19 +9,18 @@ impl Migration { Self { tablename } } - async fn execute_script( + async fn execute_script( &self, - client: &C, + client: &Client, content: &str, ) -> Result<(), tokio_postgres::Error> { - let stmt = client.prepare(content).await?; - client.execute(&stmt, &[]).await?; + client.batch_execute(content).await?; Ok(()) } - async fn insert_migration( + async fn insert_migration( &self, - client: &C, + client: &Client, name: &str, ) -> Result<(), tokio_postgres::Error> { let query = format!("INSERT INTO {} (name) VALUES ($1)", self.tablename); @@ -30,9 +29,9 @@ impl Migration { Ok(()) } - async fn delete_migration( + async fn delete_migration( &self, - client: &C, + client: &Client, name: &str, ) -> Result<(), tokio_postgres::Error> { let query = format!("DELETE FROM {} WHERE name = $1", self.tablename); @@ -41,9 +40,9 @@ impl Migration { Ok(()) } - async fn create_table( + async fn create_table( &self, - client: &C, + client: &Client, ) -> Result<(), tokio_postgres::Error> { log::debug!("creating migration table {}", self.tablename); let query = format!( @@ -54,9 +53,9 @@ impl Migration { Ok(()) } - async fn exists( + async fn exists( &self, - client: &C, + client: &Client, name: &str, ) -> Result { log::trace!("check if migration {} exists", name); @@ -69,9 +68,9 @@ impl Migration { } /// Migrate all scripts up - pub async fn up( + pub async fn up( &self, - client: &mut C, + client: &mut Client, scripts: &[(&str, &str)], ) -> Result<(), tokio_postgres::Error> { log::info!("migrating up to {}", self.tablename); @@ -87,9 +86,9 @@ impl Migration { } /// Migrate all scripts down - pub async fn down( + pub async fn down( &self, - client: &C, + client: &Client, scripts: &[(&str, &str)], ) -> Result<(), tokio_postgres::Error> { log::info!("migrating down to {}", self.tablename);