mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-23 10:38:57 +00:00
fix(cli): fix core usage in sqlx-cli
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user