mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-01-04 07:41:21 +00:00
fix(cli): fix core usage in sqlx-cli
This commit is contained in:
parent
3fcd4cd80e
commit
990466ec02
@ -2,18 +2,18 @@
|
||||
name = "sqlx-cli"
|
||||
version = "0.0.1"
|
||||
description = "Command-line utility for SQLx, the Rust SQL toolkit."
|
||||
authors = [
|
||||
"Jesper Axelsson <jesperaxe@gmail.com>",
|
||||
"Austin Bonander <austin.bonander@gmail.com>" # austin@launchbadge.com
|
||||
]
|
||||
edition = "2018"
|
||||
readme = "README.md"
|
||||
homepage = "https://github.com/launchbadge/sqlx"
|
||||
repository = "https://github.com/launchbadge/sqlx"
|
||||
keywords = ["database", "postgres", "database-management", "migration"]
|
||||
categories = ["database", "command-line-utilities"]
|
||||
keywords = [ "database", "postgres", "database-management", "migration"]
|
||||
categories = [ "database", "command-line-utilities" ]
|
||||
license = "MIT OR Apache-2.0"
|
||||
default-run = "sqlx"
|
||||
authors = [
|
||||
"Jesper Axelsson <jesperaxe@gmail.com>",
|
||||
"Austin Bonander <austin.bonander@gmail.com>"
|
||||
]
|
||||
|
||||
[[bin]]
|
||||
name = "sqlx"
|
||||
|
||||
@ -3,10 +3,14 @@
|
||||
SQLx's associated command-line utility for managing databases, migrations, and enabling "offline"
|
||||
mode with `sqlx::query!()` and friends.
|
||||
|
||||
### Installation
|
||||
### Install
|
||||
|
||||
```bash
|
||||
# supports all databases supported by SQLx
|
||||
$ cargo install sqlx-cli
|
||||
|
||||
# only for postgres
|
||||
$ cargo install sqlx-cli --no-default-features --features postgres
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
@ -8,9 +8,7 @@ mod db;
|
||||
mod migration;
|
||||
mod prepare;
|
||||
|
||||
/// Sqlx commandline tool
|
||||
#[derive(StructOpt, Debug)]
|
||||
#[structopt(name = "Sqlx")]
|
||||
pub enum Command {
|
||||
#[structopt(alias = "mig")]
|
||||
Migrate(MigrationCommand),
|
||||
@ -44,23 +42,22 @@ pub enum Command {
|
||||
},
|
||||
}
|
||||
|
||||
/// Adds and runs migrations. Alias: mig
|
||||
/// Generate and run migrations
|
||||
#[derive(StructOpt, Debug)]
|
||||
#[structopt(name = "Sqlx migrator")]
|
||||
pub enum MigrationCommand {
|
||||
/// Add new migration with name <timestamp>_<migration_name>.sql
|
||||
/// Create a new migration with the given name,
|
||||
/// using the current time as the version
|
||||
Add { name: String },
|
||||
|
||||
/// Run all migrations
|
||||
/// Run all pending migrations
|
||||
Run,
|
||||
|
||||
/// List all migrations
|
||||
List,
|
||||
}
|
||||
|
||||
/// Create or drops database depending on your connection string. Alias: db
|
||||
/// Create or drops database depending on your connection string
|
||||
#[derive(StructOpt, Debug)]
|
||||
#[structopt(name = "Sqlx migrator")]
|
||||
pub enum DatabaseCommand {
|
||||
/// Create database in url
|
||||
Create,
|
||||
@ -78,14 +75,17 @@ pub async fn run(cmd: Command) -> anyhow::Result<()> {
|
||||
MigrationCommand::Run => migration::run().await?,
|
||||
MigrationCommand::List => migration::list().await?,
|
||||
},
|
||||
|
||||
Command::Database(database) => match database {
|
||||
DatabaseCommand::Create => db::run_create().await?,
|
||||
DatabaseCommand::Drop => db::run_drop().await?,
|
||||
},
|
||||
|
||||
Command::Prepare {
|
||||
check: false,
|
||||
cargo_args,
|
||||
} => prepare::run(cargo_args)?,
|
||||
|
||||
Command::Prepare {
|
||||
check: true,
|
||||
cargo_args,
|
||||
|
||||
@ -160,7 +160,7 @@ impl DatabaseMigrator for MySql {
|
||||
}
|
||||
|
||||
pub struct MySqlMigration {
|
||||
transaction: sqlx::Transaction<PoolConnection<MySqlConnection>>,
|
||||
transaction: sqlx::Transaction<'static, sqlx::MySql, PoolConnection<sqlx::MySql>>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@ -165,7 +165,7 @@ impl DatabaseMigrator for Postgres {
|
||||
}
|
||||
|
||||
pub struct PostgresMigration {
|
||||
transaction: sqlx::Transaction<PoolConnection<PgConnection>>,
|
||||
transaction: sqlx::Transaction<'static, sqlx::Postgres, PoolConnection<sqlx::Postgres>>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@ -132,7 +132,7 @@ impl DatabaseMigrator for Sqlite {
|
||||
|
||||
pub struct SqliteMigration {
|
||||
db_url: String,
|
||||
// pub transaction: sqlx::Transaction<PoolConnection<SqliteConnection>>,
|
||||
// pub transaction: sqlx::Transaction<'static, sqlx::Sqlite, PoolConnection<sqlx::Sqlite>>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@ -10,7 +10,7 @@ pub use sqlx_core::query::{query, query_with};
|
||||
pub use sqlx_core::query_as::{query_as, query_as_with};
|
||||
pub use sqlx_core::query_scalar::{query_scalar, query_scalar_with};
|
||||
pub use sqlx_core::row::{ColumnIndex, Row};
|
||||
// pub use sqlx_core::transaction::Transaction;
|
||||
pub use sqlx_core::transaction::{Transaction, TransactionManager};
|
||||
pub use sqlx_core::value::{Value, ValueRef};
|
||||
|
||||
#[doc(hidden)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user