Skip to main content

DatabaseConfig

Struct DatabaseConfig 

Source
pub struct DatabaseConfig {
Show 13 fields pub dialect: Dialect, pub schema: Schema, pub out: PathBuf, pub breakpoints: bool, pub driver: Option<Driver>, pub tables_filter: Option<Filter>, pub schema_filter: Option<Filter>, pub extensions_filters: Option<Vec<Extension>>, pub entities: Option<EntitiesFilter>, pub casing: Option<Casing>, pub introspect: Option<IntrospectConfig>, pub verbose: bool, pub migrations: Option<MigrationsOpts>, /* private fields */
}
Expand description

Settings for one database: the top level of a single-database config, or one [databases.<name>] table.

Field names match drizzle-kit (dbCredentials, tablesFilter, …).

Fields§

§dialect: Dialect

Database dialect (required)

§schema: Schema

Schema file paths or glob patterns, relative to the config file.

§out: PathBuf

Migrations folder (default ./drizzle), relative to the config file.

§breakpoints: bool

Whether to use SQL breakpoints in migrations (default: true)

§driver: Option<Driver>

Database driver for Rust connections

§tables_filter: Option<Filter>

Table name filter (glob patterns supported)

§schema_filter: Option<Filter>

Schema name filter (PostgreSQL only)

§extensions_filters: Option<Vec<Extension>>

Extensions filter (PostgreSQL only, e.g., ["postgis"])

§entities: Option<EntitiesFilter>

Entities filter (roles, etc.)

§casing: Option<Casing>

Casing preference for generated names. Currently ignored when building snapshots: table macros always snake_case inferred names.

§introspect: Option<IntrospectConfig>

Introspection configuration

§verbose: bool

Verbose output

§migrations: Option<MigrationsOpts>

Migration table configuration

Implementations§

Source§

impl DatabaseConfig

Source

pub fn credentials(&self) -> Result<Option<Credentials>, Error>

Returns typed credentials, reading any { env = "VAR" } values.

Returns None when dbCredentials is absent or its shape does not fit the dialect (loading a config already rejects most such mismatches).

§Errors

Returns Error if a referenced environment variable is unset or not valid UTF-8, or an ssl value is not a recognized mode.

Source

pub fn migrations_dir(&self) -> &Path

Returns the migrations folder (out).

Source

pub fn meta_dir(&self) -> PathBuf

Returns out/meta, where legacy drizzle-kit layouts keep the journal.

Source

pub fn journal_path(&self) -> PathBuf

Returns the legacy out/meta/_journal.json path.

Source

pub fn schema_display(&self) -> String

Returns the schema paths joined for display.

Source

pub fn schema_files(&self) -> Result<Vec<PathBuf>, Error>

Resolves schema paths and globs to files.

§Errors

Returns Error if a listed path is missing, if a glob pattern is invalid, fails to expand or matches no file (see resolve_schema_patterns), or if nothing is listed at all.

Source

pub fn effective_casing(&self) -> Casing

Returns casing, or camelCase when unset.

Source

pub fn effective_introspect_casing(&self) -> IntrospectCasing

Returns introspect.casing, or camel when unset.

Source

pub fn effective_entities(&self) -> EntitiesFilter

Returns the entities filter, or the default when unset.

Source

pub fn should_include_role(&self, role_name: &str) -> bool

Returns true if role_name passes the entities.roles filter (false when no entities filter is set).

Source

pub fn roles_enabled(&self) -> bool

Returns true if the entities.roles filter is enabled.

Source

pub fn extensions(&self) -> &[Extension]

Returns the extensionsFilters list (PostgreSQL only; empty when unset).

Source

pub fn has_extension(&self, ext: Extension) -> bool

Returns true if ext is in extensionsFilters.

Source

pub fn migrations_table(&self) -> &str

Returns the migrations tracking table (default __drizzle_migrations).

Source

pub fn migrations_schema(&self) -> &str

Returns the migrations tracking schema (PostgreSQL only, default drizzle).

Source

pub fn bundle_enabled(&self) -> bool

Should a bundled migrations.js index be emitted alongside migration.sql?

Resolution order:

  1. Explicit [migrations] bundle = true/false in the config wins.
  2. Otherwise, auto-enable for driver = "durable-sqlite" since Durable Objects need the JS index to import migrations at Worker build time (there’s no other way to ship SQL into a DO).
  3. Otherwise, default to false.

Trait Implementations§

Source§

impl Clone for DatabaseConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DatabaseConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DatabaseConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for DatabaseConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Joined, From> JoinKey<From, JoinReverse> for Joined
where From: Joinable<Joined> + ?Sized,

Source§

fn pairs() -> &'static [(&'static str, &'static str)]

(joined_column, from_column) pairs the ON condition matches, in key order, read through Self::pair.
Source§

fn pair(pair: &(&'static str, &'static str)) -> (&'static str, &'static str)

The (joined_column, from_column) names of pair.
Source§

impl<List> ListIncludes<Nil, ()> for List

Source§

impl<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeEq<T> for T