Trait butane_core::migrations::MigrationsMut
source · pub trait MigrationsMut: Migrationswhere
Self::M: MigrationMut,{
// Required methods
fn new_migration(&self, name: &str) -> Self::M;
fn add_migration(&mut self, m: Self::M) -> Result<()>;
fn clear_migrations(&mut self, conn: &impl ConnectionMethods) -> Result<()>;
fn current(&mut self) -> &mut Self::M;
fn clear_current(&mut self) -> Result<()>;
// Provided methods
fn create_migration(
&mut self,
backend: &impl Backend,
name: &str,
from: Option<&Self::M>
) -> Result<bool> { ... }
fn create_migration_to(
&mut self,
backend: &impl Backend,
name: &str,
from: Option<&Self::M>,
to_db: ADB
) -> Result<bool> { ... }
}
Required Methods§
sourcefn new_migration(&self, name: &str) -> Self::M
fn new_migration(&self, name: &str) -> Self::M
Construct a new, uninitialized migration. You may want to use
create_migration
instead, which provides higher-level
functionality.
sourcefn add_migration(&mut self, m: Self::M) -> Result<()>
fn add_migration(&mut self, m: Self::M) -> Result<()>
Adds a migration constructed from new_migration
into the set
of migrations. Should be called after filling in the migration
details. Unnecessary when using create_migration
.
sourcefn clear_migrations(&mut self, conn: &impl ConnectionMethods) -> Result<()>
fn clear_migrations(&mut self, conn: &impl ConnectionMethods) -> Result<()>
Clears all migrations – deleting them from this object (and any storage backing it) and deleting the record of their existence/application from the database. The database schema is not modified, nor is any other data removed. Use carefully.
sourcefn current(&mut self) -> &mut Self::M
fn current(&mut self) -> &mut Self::M
Get a pseudo-migration representing the current state as determined by the last build of models. This does not necessarily match the current state of the database if migrations have not yet been applied.
This migration is named “current”. It is not a “real” migration
- it should never be applied
- it will never be returned by
latest
,migrations_since
,all_migrations
or other similar methods.
sourcefn clear_current(&mut self) -> Result<()>
fn clear_current(&mut self) -> Result<()>
Clears the current state (as would be returned by the current
method).
Provided Methods§
sourcefn create_migration(
&mut self,
backend: &impl Backend,
name: &str,
from: Option<&Self::M>
) -> Result<bool>
fn create_migration( &mut self, backend: &impl Backend, name: &str, from: Option<&Self::M> ) -> Result<bool>
Create a migration from
-> current
named name
. From may be None, in which
case the migration is created from an empty database.
Returns true if a migration was created, false if from
and current
represent identical states.
sourcefn create_migration_to(
&mut self,
backend: &impl Backend,
name: &str,
from: Option<&Self::M>,
to_db: ADB
) -> Result<bool>
fn create_migration_to( &mut self, backend: &impl Backend, name: &str, from: Option<&Self::M>, to_db: ADB ) -> Result<bool>
Create a migration from
-> to_db
named name
. From may be None, in which
case the migration is created from an empty database.
Returns true if a migration was created, false if from
and current
represent identical states.