Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splitting into multiple schema.rs #3796

Merged
merged 33 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f304b19
Support multiple schemas in diesel.toml
forest1102 Sep 17, 2023
7cda082
fix errors
forest1102 Sep 18, 2023
1fcd745
Merge branch 'master' into forest1102/issue1728
forest1102 Sep 19, 2023
5a9edd1
Merge branch 'master' into forest1102/issue1728
forest1102 Sep 19, 2023
fb2df8c
Merge branch 'master' into forest1102/issue1728
forest1102 Oct 6, 2023
55e308b
Merge branch 'master' into forest1102/issue1728
forest1102 Nov 17, 2023
f9fa6a5
Revert " Support multiple schemas in diesel.toml"
forest1102 Nov 17, 2023
d06b8aa
Merge branch 'master' into forest1102/issue1728
forest1102 Dec 4, 2023
89b46a5
Merge branch 'master' into forest1102/issue1728
forest1102 Dec 22, 2023
7308f79
enable to use multiple print_schema
forest1102 Dec 26, 2023
3ed6934
Merge branch 'master' into forest1102/issue1728
forest1102 Dec 26, 2023
18d77f1
delete unused package
forest1102 Dec 26, 2023
523cbe9
fix cli parameter error
forest1102 Jan 9, 2024
ff316f2
Merge branch 'diesel-rs:master' into forest1102/issue1728
forest1102 Jan 9, 2024
728c27a
add test for mysql/sqlite
forest1102 Jan 9, 2024
139ee48
fix sqlite snap
forest1102 Jan 9, 2024
cc724fd
update snapshot for mysql
forest1102 Jan 9, 2024
f067e96
Merge remote-tracking branch 'origin/master' into forest1102/issue1728
forest1102 Jan 12, 2024
e748bfe
changes after commit
forest1102 Jan 12, 2024
3044c21
change after commit
forest1102 Jan 12, 2024
15c8a24
fix clippy
forest1102 Jan 12, 2024
96a2d4d
Merge branch 'master' into forest1102/issue1728
forest1102 Jan 13, 2024
206f702
Merge branch 'master' into forest1102/issue1728
forest1102 Jan 17, 2024
a23b136
Merge branch 'master' into forest1102/issue1728
forest1102 Jan 30, 2024
f2fe4a2
Merge branch 'master' into forest1102/issue1728
forest1102 Feb 8, 2024
266a682
Merge branch 'master' into forest1102/issue1728
forest1102 Feb 9, 2024
57edc74
Merge branch 'master' into forest1102/issue1728
forest1102 Feb 25, 2024
2860749
reflect suggestion
forest1102 Feb 25, 2024
2c21c43
Merge remote-tracking branch 'origin/master' into uforest1102/issue1728
forest1102 Feb 28, 2024
5c2ae6d
Merge remote-tracking branch 'origin/master' into forest1102/issue1728
forest1102 Mar 1, 2024
6458a46
changes after merge and refactor generate_sql_based_on_diff_schema
forest1102 Mar 1, 2024
455e863
add changelog
forest1102 Mar 2, 2024
2343a5e
Merge branch 'master' into forest1102/issue1728
forest1102 Mar 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi
* Logging in diesel-cli
* Support for libsqlite3-sys 0.28
* Add `sqlite-integer-primary-key-is-bigint` configuration option, usable with SQLite 3.37 or above, allowing to use `BigInt` for `INTEGER PRIMARY KEY` columns in SQLite for tables without the `WITHOUT ROWID` attribute ([SQLite doc](https://www.sqlite.org/lang_createtable.html#rowid)).
* Support for multiple `print_schema` entry in `diesel.toml` (e.g. `[print_schema.user1]`), which allows generating multiple schema.rs files

### Changed

Expand Down
9 changes: 6 additions & 3 deletions diesel_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ path = "src/main.rs"
doc = false

[dependencies]
chrono = { version = "0.4.20", default-features = false, features = ["clock", "std"] }
clap = { version = "4.0.2", features = ["cargo", "string"] }
chrono = { version = "0.4.20", default-features = false, features = [
"clock",
"std",
] }
clap = { version = "4.4.14", features = ["cargo", "string"] }
clap_complete = "4"
dotenvy = "0.15"
heck = "0.4.0"
serde = { version = "1.0.0", features = ["derive"] }
serde = { version = "1.0.193", features = ["derive", "std"] }
toml = "0.8"
url = { version = "2.2.2" }
libsqlite3-sys = { version = ">=0.17.2, <0.29.0", optional = true }
Expand Down
59 changes: 39 additions & 20 deletions diesel_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ use clap_complete::Shell;

use crate::print_schema;

fn position_sensitive_flag(arg: Arg) -> Arg {
arg.num_args(0)
.value_parser(clap::value_parser!(bool))
.default_missing_value("true")
.default_value("false")
}

pub fn build_cli() -> Command {
let database_arg = Arg::new("DATABASE_URL")
.long("database-url")
Expand Down Expand Up @@ -168,20 +175,24 @@ pub fn build_cli() -> Command {
.help("Table names to filter."),
)
.arg(
Arg::new("only-tables")
position_sensitive_flag(Arg::new("only-tables"))
.short('o')
.long("only-tables")
.action(ArgAction::SetTrue)
.help("Only include tables from table-name that matches regexp.")
.conflicts_with("except-tables"),
.action(ArgAction::Append)
.help("Only include tables from table-name that matches regexp."),
)
.arg(
Arg::new("except-tables")
position_sensitive_flag(Arg::new("except-tables"))
.short('e')
.long("except-tables")
.action(ArgAction::SetTrue)
.help("Exclude tables from table-name that matches regex.")
.conflicts_with("only-tables"),
.action(ArgAction::Append)
.help("Exclude tables from table-name that matches regex."),
)
.arg(
Arg::new("schema-key")
.long("schema-key")
.action(clap::ArgAction::Append)
.help("select schema key from diesel.toml, use 'default' for print_schema without key."),
),
)
.subcommand_required(true)
Expand Down Expand Up @@ -238,60 +249,62 @@ pub fn build_cli() -> Command {
.help("Table names to filter."),
)
.arg(
Arg::new("only-tables")
position_sensitive_flag(Arg::new("only-tables"))
.short('o')
.long("only-tables")
.action(ArgAction::SetTrue)
.action(ArgAction::Append)
.help("Only include tables from table-name that matches regexp.")
.conflicts_with("except-tables"),
)
.arg(
Arg::new("except-tables")
position_sensitive_flag(Arg::new("except-tables"))
.short('e')
.long("except-tables")
.action(ArgAction::SetTrue)
.action(ArgAction::Append)
.help("Exclude tables from table-name that matches regex.")
.conflicts_with("only-tables"),
)
.arg(
Arg::new("with-docs")
position_sensitive_flag(Arg::new("with-docs"))
.long("with-docs")
.action(ArgAction::SetTrue)
.action(ArgAction::Append)
.help("Render documentation comments for tables and columns."),
)
.arg(
Arg::new("with-docs-config")
.long("with-docs-config")
.help("Render documentation comments for tables and columns.")
.num_args(1)
.action(ArgAction::Append)
.value_parser(PossibleValuesParser::new(print_schema::DocConfig::VARIANTS_STR)),
)
.arg(
Arg::new("column-sorting")
.long("column-sorting")
.help("Sort order for table columns.")
.num_args(1)
.action(ArgAction::Append)
.value_parser(PossibleValuesParser::new(["ordinal_position", "name"])),
)
.arg(
Arg::new("patch-file")
.long("patch-file")
.num_args(1)
.action(ArgAction::Append)
.value_parser(clap::value_parser!(std::path::PathBuf))
.help("A unified diff file to be applied to the final schema."),
)
.arg(
Arg::new("import-types")
.long("import-types")
.num_args(1..)
.action(ArgAction::Append)
.action(clap::ArgAction::Append)
.number_of_values(1)
.help("A list of types to import for every table, separated by commas."),
)
.arg(
Arg::new("generate-custom-type-definitions")
position_sensitive_flag(Arg::new("generate-custom-type-definitions"))
.long("no-generate-missing-sql-type-definitions")
.action(ArgAction::SetTrue)
.action(ArgAction::Append)
.help("Generate SQL type definitions for types not provided by diesel"),
)
.arg(
Expand All @@ -303,9 +316,15 @@ pub fn build_cli() -> Command {
.help("A list of derives to implement for every automatically generated SqlType in the schema, separated by commas."),
)
.arg(
Arg::new("sqlite-integer-primary-key-is-bigint")
Arg::new("schema-key")
.long("schema-key")
.action(ArgAction::Append)
.default_values(["default"])
.help("select schema key from diesel.toml, use 'default' for print_schema without key."),
weiznich marked this conversation as resolved.
Show resolved Hide resolved
).arg(
position_sensitive_flag(Arg::new("sqlite-integer-primary-key-is-bigint"))
.long("sqlite-integer-primary-key-is-bigint")
.action(ArgAction::SetTrue)
.action(ArgAction::Append)
.help(
"For SQLite 3.37 and above, detect `INTEGER PRIMARY KEY` columns as `BigInt`, \
when the table isn't declared with `WITHOUT ROWID`.\n\
Expand Down
Loading
Loading