pub struct SchemaManager<'c> { /* private fields */ }Expand description
Runs DDL inside the migration’s transaction and inspects the catalog.
Implementations§
Source§impl<'c> SchemaManager<'c>
impl<'c> SchemaManager<'c>
Sourcepub fn new(conn: &'c Transaction) -> Self
pub fn new(conn: &'c Transaction) -> Self
Wraps a transaction.
Sourcepub fn get_connection(&self) -> &'c Transaction
pub fn get_connection(&self) -> &'c Transaction
The transaction the migration runs in, for data migrations and raw statements.
Sourcepub async fn create_table(&self, stmt: CreateTable) -> Result<(), DbErr>
pub async fn create_table(&self, stmt: CreateTable) -> Result<(), DbErr>
Sourcepub async fn alter_table(&self, stmt: AlterTable) -> Result<(), DbErr>
pub async fn alter_table(&self, stmt: AlterTable) -> Result<(), DbErr>
Sourcepub async fn create_index(&self, stmt: CreateIndex) -> Result<(), DbErr>
pub async fn create_index(&self, stmt: CreateIndex) -> Result<(), DbErr>
Sourcepub async fn has_table(&self, table: &str) -> Result<bool, DbErr>
pub async fn has_table(&self, table: &str) -> Result<bool, DbErr>
Whether a table named table exists.
§Errors
Returns DbErr::Migration when the catalog query returns no row;
DbErr::Driver when the query fails.
Sourcepub async fn has_column(&self, table: &str, column: &str) -> Result<bool, DbErr>
pub async fn has_column(&self, table: &str, column: &str) -> Result<bool, DbErr>
Whether table has a column named column.
§Errors
Returns DbErr::Migration when the catalog query returns no row;
DbErr::Driver when the query fails.
Sourcepub async fn has_index(&self, index: &str) -> Result<bool, DbErr>
pub async fn has_index(&self, index: &str) -> Result<bool, DbErr>
Whether an index named index exists.
§Errors
Returns DbErr::Migration when the catalog query returns no row;
DbErr::Driver when the query fails.
Trait Implementations§
Auto Trait Implementations§
impl<'c> !RefUnwindSafe for SchemaManager<'c>
impl<'c> !UnwindSafe for SchemaManager<'c>
impl<'c> Freeze for SchemaManager<'c>
impl<'c> Send for SchemaManager<'c>
impl<'c> Sync for SchemaManager<'c>
impl<'c> Unpin for SchemaManager<'c>
impl<'c> UnsafeUnpin for SchemaManager<'c>
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
Converts
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> ⓘ
Converts
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