SqlMigration

Struct SqlMigration 

Source
pub struct SqlMigration { /* private fields */ }
Expand description

A migration defined by SQL strings.

Works with any context that implements SqlExecutor.

Implementations§

Source§

impl SqlMigration

Source

pub fn new( version: u64, name: impl Into<String>, up_sql: impl Into<String>, ) -> Self

Create a new SQL migration

Source

pub fn phase(self, phase: Phase) -> Self

Set the deployment phase

Source

pub fn with_down(self, down_sql: impl Into<String>) -> Self

Add rollback SQL

Source

pub fn up_sql(&self) -> &str

Get the up SQL

Source

pub fn down_sql(&self) -> Option<&str>

Get the down SQL

Source

pub fn version(&self) -> u64

Get the version

Source

pub fn name(&self) -> &str

Get the name

Source

pub fn get_phase(&self) -> Phase

Get the deployment phase

Source

pub fn has_rollback(&self) -> bool

Whether this migration has rollback SQL

Trait Implementations§

Source§

impl<Ctx> Migration<Ctx> for SqlMigration
where Ctx: SqlExecutor,

Source§

fn version(&self) -> u64

Unique version number (must be sequential: 1, 2, 3, …)
Source§

fn name(&self) -> &str

Human-readable name for this migration
Source§

fn phase(&self) -> Phase

Deployment phase (pre-deploy or post-deploy)
Source§

fn apply(&self, ctx: &mut Ctx) -> Result<()>

Apply the migration
Source§

fn rollback(&self, ctx: &mut Ctx) -> Result<()>

Rollback the migration (optional)
Source§

fn can_rollback(&self) -> bool

Whether this migration supports rollback

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> 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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.