diff --git a/sea-orm-cli/src/cli.rs b/sea-orm-cli/src/cli.rs index 39a062ed9..df86fe68f 100644 --- a/sea-orm-cli/src/cli.rs +++ b/sea-orm-cli/src/cli.rs @@ -111,6 +111,16 @@ pub enum GenerateSubcommands { )] tables: Option, + #[clap( + value_parser, + long, + use_value_delimiter = true, + takes_value = true, + default_value = "seaql_migrations", + help = "Skip generating entity file for specified tables (comma separated)" + )] + ignore_tables: Vec, + #[clap( value_parser, long, diff --git a/sea-orm-cli/src/commands.rs b/sea-orm-cli/src/commands.rs index 983dcced8..7d37dc82b 100644 --- a/sea-orm-cli/src/commands.rs +++ b/sea-orm-cli/src/commands.rs @@ -17,6 +17,7 @@ pub async fn run_generate_command( expanded_format, include_hidden_tables, tables, + ignore_tables, max_connections, output_dir, database_schema, @@ -87,6 +88,10 @@ pub async fn run_generate_command( } }; + let filter_skip_tables = |table: &String| -> bool { + !ignore_tables.contains(table) + }; + let database_name = if !is_sqlite { // The database name should be the first element of the path string // @@ -130,6 +135,7 @@ pub async fn run_generate_command( .into_iter() .filter(|schema| filter_tables(&schema.info.name)) .filter(|schema| filter_hidden_tables(&schema.info.name)) + .filter(|schema| filter_skip_tables(&schema.info.name)) .map(|schema| schema.write()) .collect() } @@ -145,6 +151,7 @@ pub async fn run_generate_command( .into_iter() .filter(|schema| filter_tables(&schema.name)) .filter(|schema| filter_hidden_tables(&schema.name)) + .filter(|schema| filter_skip_tables(&schema.name)) .map(|schema| schema.write()) .collect() } @@ -161,6 +168,7 @@ pub async fn run_generate_command( .into_iter() .filter(|schema| filter_tables(&schema.info.name)) .filter(|schema| filter_hidden_tables(&schema.info.name)) + .filter(|schema| filter_skip_tables(&schema.info.name)) .map(|schema| schema.write()) .collect() }