Print some Entity Generate messages (#1787)
This commit is contained in:
parent
ae8dcceb43
commit
cc677e37d5
@ -110,7 +110,9 @@ pub async fn run_generate_command(
|
|||||||
use sea_schema::mysql::discovery::SchemaDiscovery;
|
use sea_schema::mysql::discovery::SchemaDiscovery;
|
||||||
use sqlx::MySql;
|
use sqlx::MySql;
|
||||||
|
|
||||||
|
println!("Connecting to MySQL ...");
|
||||||
let connection = connect::<MySql>(max_connections, url.as_str(), None).await?;
|
let connection = connect::<MySql>(max_connections, url.as_str(), None).await?;
|
||||||
|
println!("Discovering schema ...");
|
||||||
let schema_discovery = SchemaDiscovery::new(connection, database_name);
|
let schema_discovery = SchemaDiscovery::new(connection, database_name);
|
||||||
let schema = schema_discovery.discover().await?;
|
let schema = schema_discovery.discover().await?;
|
||||||
let table_stmts = schema
|
let table_stmts = schema
|
||||||
@ -127,7 +129,9 @@ pub async fn run_generate_command(
|
|||||||
use sea_schema::sqlite::discovery::SchemaDiscovery;
|
use sea_schema::sqlite::discovery::SchemaDiscovery;
|
||||||
use sqlx::Sqlite;
|
use sqlx::Sqlite;
|
||||||
|
|
||||||
|
println!("Connecting to SQLite ...");
|
||||||
let connection = connect::<Sqlite>(max_connections, url.as_str(), None).await?;
|
let connection = connect::<Sqlite>(max_connections, url.as_str(), None).await?;
|
||||||
|
println!("Discovering schema ...");
|
||||||
let schema_discovery = SchemaDiscovery::new(connection);
|
let schema_discovery = SchemaDiscovery::new(connection);
|
||||||
let schema = schema_discovery.discover().await?;
|
let schema = schema_discovery.discover().await?;
|
||||||
let table_stmts = schema
|
let table_stmts = schema
|
||||||
@ -144,9 +148,11 @@ pub async fn run_generate_command(
|
|||||||
use sea_schema::postgres::discovery::SchemaDiscovery;
|
use sea_schema::postgres::discovery::SchemaDiscovery;
|
||||||
use sqlx::Postgres;
|
use sqlx::Postgres;
|
||||||
|
|
||||||
|
println!("Connecting to Postgres ...");
|
||||||
let schema = &database_schema;
|
let schema = &database_schema;
|
||||||
let connection =
|
let connection =
|
||||||
connect::<Postgres>(max_connections, url.as_str(), Some(schema)).await?;
|
connect::<Postgres>(max_connections, url.as_str(), Some(schema)).await?;
|
||||||
|
println!("Discovering schema ...");
|
||||||
let schema_discovery = SchemaDiscovery::new(connection, schema);
|
let schema_discovery = SchemaDiscovery::new(connection, schema);
|
||||||
let schema = schema_discovery.discover().await?;
|
let schema = schema_discovery.discover().await?;
|
||||||
let table_stmts = schema
|
let table_stmts = schema
|
||||||
@ -161,6 +167,7 @@ pub async fn run_generate_command(
|
|||||||
}
|
}
|
||||||
_ => unimplemented!("{} is not supported", url.scheme()),
|
_ => unimplemented!("{} is not supported", url.scheme()),
|
||||||
};
|
};
|
||||||
|
println!("... discovered.");
|
||||||
|
|
||||||
let writer_context = EntityWriterContext::new(
|
let writer_context = EntityWriterContext::new(
|
||||||
expanded_format,
|
expanded_format,
|
||||||
@ -182,6 +189,7 @@ pub async fn run_generate_command(
|
|||||||
|
|
||||||
for OutputFile { name, content } in output.files.iter() {
|
for OutputFile { name, content } in output.files.iter() {
|
||||||
let file_path = dir.join(name);
|
let file_path = dir.join(name);
|
||||||
|
println!("Writing {file_path}");
|
||||||
let mut file = fs::File::create(file_path)?;
|
let mut file = fs::File::create(file_path)?;
|
||||||
file.write_all(content.as_bytes())?;
|
file.write_all(content.as_bytes())?;
|
||||||
}
|
}
|
||||||
@ -194,6 +202,8 @@ pub async fn run_generate_command(
|
|||||||
return Err(format!("Fail to format file `{name}`").into());
|
return Err(format!("Fail to format file `{name}`").into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("... Done.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user