Skip to main content

Migration

Struct Migration 

Source
pub struct Migration { /* private fields */ }
Available on crate feature std only.
Expand description

A migration with its SQL content

Represents a single migration that can be applied to the database. The hash field is used to track which migrations have been applied.

Implementations§

Source§

impl Migration

Source

pub fn new(tag: &str, sql: &str) -> Migration

Create a new migration from embedded SQL

The hash is computed from the SQL content. SQL is split on "--> statement-breakpoint" markers.

Source

pub fn with_hash( tag: impl Into<String>, hash: impl Into<String>, created_at: i64, sql: Vec<String>, ) -> Migration

Create a migration with explicit hash and timestamp

Source

pub fn tag(&self) -> &str

Get the migration tag (folder name)

Source

pub fn name(&self) -> &str

Get the migration folder name used by drizzle-orm tracking metadata.

Source

pub fn hash(&self) -> &str

Get the migration hash (used for tracking)

Source

pub const fn created_at(&self) -> i64

Get the creation timestamp

Source

pub fn statements(&self) -> &[String]

Get the raw SQL statements (already split).

SQLite transaction-owning adapters must use Self::sqlite_execution instead so foreign-key suspension sentinels are handled outside the transaction.

Source

pub fn sqlite_execution( &self, ) -> Result<SqliteMigrationExecution<'_>, SqliteMigrationExecutionError>

Validate SQLite foreign-key suspension sentinels and prepare the statement stream for a transaction-owning runtime adapter.

§Errors

Returns SqliteMigrationExecutionError when foreign-key suspension pragmas are nested, unbalanced, or use an unsupported assignment form.

Source

pub fn is_empty(&self) -> bool

Check if this migration is empty

Source

pub fn has_postgres_concurrent_index(&self) -> bool

Whether this migration contains a PostgreSQL concurrent-index command.

Trait Implementations§

Source§

impl Clone for Migration

Source§

fn clone(&self) -> Migration

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 Migration

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AliasExt for T

Source§

fn alias(self, name: &'static str) -> AliasedExpr<Self>

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> 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<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Scope> ScopeSatisfies<Nil, ()> for Scope

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, <T as TryFrom<U>>::Error>

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