pub struct Config {
    pub create_schemas: BTreeSet<Box<str>>,
    pub table_name: Option<Box<str>>,
    pub migrations_dir: Option<Box<str>>,
    pub ignored_chars: BTreeSet<char>,
    pub defaults: MigrationDefaults,
}Expand description
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.
Fields§
§create_schemas: BTreeSet<Box<str>>Specify the names of schemas to create if they don’t already exist.
This is done before checking the existence of the migrations table
(_sqlx_migrations or overridden table_name below) so that it may be placed in
one of these schemas.
§Example
sqlx.toml:
[migrate]
create-schemas = ["foo"]table_name: Option<Box<str>>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.
§Example
sqlx.toml:
[migrate]
# Put `_sqlx_migrations` in schema `foo`
table-name = "foo._sqlx_migrations"migrations_dir: Option<Box<str>>Override the directory used for migrations files.
Relative to the crate root for sqlx::migrate!(), or the current directory for sqlx-cli.
ignored_chars: BTreeSet<char>Specify characters that should be ignored when hashing migrations.
Any characters contained in the given array will be dropped when a migration is hashed.
§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.
§Example: Ignore Carriage Return (<CR> | \r)
Line ending differences between platforms can result in migrations having non-repeatable
hashes. The most common culprit is the carriage return (<CR> | \r), which Windows
uses in its line endings alongside line feed (<LF> | \n), often written CRLF or \r\n,
whereas Linux and macOS use only line feeds.
sqlx.toml:
[migrate]
ignored-chars = ["\r"]For projects using Git, this can also be addressed using .gitattributes:
# Force newlines in migrations to be line feeds on all platforms
migrations/*.sql text eol=lfThis may require resetting or re-checking out the migrations files to take effect.
§Example: Ignore all Whitespace Characters
To make your migrations amenable to reformatting, you may wish to tell SQLx to ignore all whitespace characters in migrations.
§Warning: Beware Syntactically Significant Whitespace!
If your migrations use string literals or quoted identifiers which contain whitespace, this configuration will cause the migration machinery to ignore some changes to these. This may result in a mismatch between the development and production versions of your database.
sqlx.toml:
[migrate]
# Ignore common whitespace characters when hashing
ignored-chars = [" ", "\t", "\r", "\n"]  # Space, tab, CR, LFdefaults: MigrationDefaultsSpecify default options for new migrations created with sqlx migrate add.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more