# `sqlx.toml` reference. # # Note: shown values are *not* defaults. # They are explicitly set to non-default values to test parsing. # Refer to the comment for a given option for its default value. ############################################################################################### # Configuration shared by multiple components. [common] # Change the environment variable to get the database URL. # # This is used by both the macros and `sqlx-cli`. # # If not specified, defaults to `DATABASE_URL` database-url-var = "FOO_DATABASE_URL" ############################################################################################### # Configuration of SQLx database drivers (**applies to macros and sqlx-cli only**) [drivers] # Configure MySQL databases in macros and sqlx-cli. [drivers.mysql] # No fields implemented yet. This key is only used to validate parsing. # Configure Postgres databases in macros and sqlx-cli. [drivers.postgres] # No fields implemented yet. This key is only used to validate parsing. # Configure Postgres databases in macros and sqlx-cli. [drivers.sqlite] # Load extensions into SQLite when running macros or migrations # # Defaults to an empty list, which has no effect. # # Must be specified separately at run-time using `SqliteConnectOptions::extension()` or `::extension_with_entrypoint()`. # # Safety # This causes arbitrary DLLs on the filesystem to be loaded at runtime, # which can easily result in undefined behavior, memory corruption, # or exploitable vulnerabilities if misused. # # It is not possible to provide a truly safe version of this API. # # Use this field with care, and only load extensions that you trust. unsafe-load-extensions = ["uuid", "vsv"] # Configure external drivers in macros and sqlx-cli. # # These keys are only validated when the external driver tries to parse them, # unlike config for built-in drivers which is validated directly. [drivers.external.""] foo = 'foo' bar = true ############################################################################################### # Configuration for the `query!()` family of macros. [macros] [macros.preferred-crates] # Force the macros to use the `chrono` crate for date/time types, even if `time` is enabled. # # Defaults to "inferred": use whichever crate is enabled (`time` takes precedence over `chrono`). date-time = "chrono" # Or, ensure the macros always prefer `time` # in case new date/time crates are added in the future: # date-time = "time" # Force the macros to use the `rust_decimal` crate for `NUMERIC`, even if `bigdecimal` is enabled. # # Defaults to "inferred": use whichever crate is enabled (`bigdecimal` takes precedence over `rust_decimal`). numeric = "rust_decimal" # Or, ensure the macros always prefer `bigdecimal` # in case new decimal crates are added in the future: # numeric = "bigdecimal" # Set global overrides for mapping SQL types to Rust types. # # Default type mappings are defined by the database driver. # Refer to the `sqlx::types` module for details. # # Postgres users: schema qualification should not be used for types in the search path. # # ### Note: Orthogonal to Nullability # These overrides do not affect whether `query!()` decides to wrap a column in `Option<_>` # or not. They only override the inner type used. [macros.type-overrides] # Override a built-in type (map all `UUID` columns to `crate::types::MyUuid`) # Note: currently, the case of the type name MUST match. # Built-in types are spelled in all-uppercase to match SQL convention. 'UUID' = "crate::types::MyUuid" # Support an external or custom wrapper type (e.g. from the `isn` Postgres extension) # (NOTE: FOR DOCUMENTATION PURPOSES ONLY; THIS CRATE/TYPE DOES NOT EXIST AS OF WRITING) 'isbn13' = "isn_rs::isbn::ISBN13" # SQL type `foo` to Rust type `crate::types::Foo`: 'foo' = "crate::types::Foo" # SQL type `"Bar"` to Rust type `crate::types::Bar`; notice the extra pair of quotes: '"Bar"' = "crate::types::Bar" # Will NOT work (the first pair of quotes are parsed by TOML) # "Bar" = "crate::types::Bar" # Schema qualified 'foo.bar' = "crate::types::Bar" # Schema qualified and quoted 'foo."Bar"' = "crate::schema::foo::Bar" # Quoted schema name '"Foo".bar' = "crate::schema::foo::Bar" # Quoted schema and type name '"Foo"."Bar"' = "crate::schema::foo::Bar" # Set per-table and per-column overrides for mapping SQL types to Rust types. # # Note: table name is required in the header. # # Postgres users: schema qualification should not be used for types in the search path. # # ### Note: Orthogonal to Nullability # These overrides do not affect whether `query!()` decides to wrap a column in `Option<_>` # or not. They only override the inner type used. [macros.table-overrides.'foo'] # Map column `bar` of table `foo` to Rust type `crate::types::Foo`: 'bar' = "crate::types::Bar" # Quoted column name # Note: same quoting requirements as `macros.type_overrides` '"Bar"' = "crate::types::Bar" # Note: will NOT work (parses as `Bar`) # "Bar" = "crate::types::Bar" # Table name may be quoted (note the wrapping single-quotes) [macros.table-overrides.'"Foo"'] 'bar' = "crate::types::Bar" '"Bar"' = "crate::types::Bar" # Table name may also be schema-qualified. # Note how the dot is inside the quotes. [macros.table-overrides.'my_schema.my_table'] 'my_column' = "crate::types::MyType" # Quoted schema, table, and column names [macros.table-overrides.'"My Schema"."My Table"'] '"My Column"' = "crate::types::MyType" ############################################################################################### # Configuration for migrations when executed using `sqlx::migrate!()` or through `sqlx-cli`. # # ### Note # A manually constructed [`Migrator`][crate::migrate::Migrator] will not be aware of these # configuration options. We recommend using `sqlx::migrate!()` instead. # # ### Warning: Potential Data Loss or Corruption! # Many of these options, if changed after migrations are set up, # can result in data loss or corruption of a production database # if the proper precautions are not taken. # # Be sure you know what you are doing and that you read all relevant documentation _thoroughly_. [migrate] # Override the name of the table used to track executed migrations. # # May be schema-qualified and/or contain quotes. Defaults to `_sqlx_migrations`. # # Potentially useful for multi-tenant databases. # # ### Warning: Potential Data Loss or Corruption! # Changing this option for a production database will likely result in data loss or corruption # as the migration machinery will no longer be aware of what migrations have been applied # and will attempt to re-run them. # # You should create the new table as a copy of the existing migrations table (with contents!), # and be sure all instances of your application have been migrated to the new # table before deleting the old one. table-name = "foo._sqlx_migrations" # Override the directory used for migrations files. # # Relative to the crate root for `sqlx::migrate!()`, or the current directory for `sqlx-cli`. migrations-dir = "foo/migrations" # Specify characters that should be ignored when hashing migrations. # # Any characters contained in the given set will be dropped when a migration is hashed. # # Defaults to an empty array (don't drop any characters). # # ### Warning: May Change Hashes for Existing Migrations # Changing the characters considered in hashing migrations will likely # change the output of the hash. # # This may require manual rectification for deployed databases. # ignored-chars = [] # Ignore Carriage Returns (`` | `\r`) # Note that the TOML format requires double-quoted strings to process escapes. # ignored-chars = ["\r"] # Ignore common whitespace characters (beware syntatically significant whitespace!) # Space, tab, CR, LF, zero-width non-breaking space (U+FEFF) # # U+FEFF is added by some editors as a magic number at the beginning of a text file indicating it is UTF-8 encoded, # where it is known as a byte-order mark (BOM): https://en.wikipedia.org/wiki/Byte_order_mark ignored-chars = [" ", "\t", "\r", "\n", "\uFEFF"] # Set default options for new migrations. [migrate.defaults] # Specify reversible migrations by default (for `sqlx migrate create`). # # Defaults to "inferred": uses the type of the last migration, or "simple" otherwise. migration-type = "reversible" # Specify simple (non-reversible) migrations by default. # migration-type = "simple" # Specify sequential versioning by default (for `sqlx migrate create`). # # Defaults to "inferred": guesses the versioning scheme from the latest migrations, # or "timestamp" otherwise. migration-versioning = "sequential" # Specify timestamp versioning by default. # migration-versioning = "timestamp"