pub struct Table {
pub meta: TableMeta,
/* private fields */
}
Fields§
§meta: TableMeta
Implementations§
source§impl Table
impl Table
pub fn new<S: Into<String>>(name: S) -> Self
sourcepub fn add_column<S: Into<String>>(&mut self, name: S, _type: Type) -> &mut Type
pub fn add_column<S: Into<String>>(&mut self, name: S, _type: Type) -> &mut Type
Add a new column to a table
table.add_column("id", types::primary());
table.add_column("name", types::varchar(64));
pub fn drop_column<S: Into<String>>(&mut self, name: S)
pub fn rename_column<S: Into<String>>(&mut self, old: S, new: S)
sourcepub fn inject_custom<S: Into<String>>(&mut self, sql: S)
pub fn inject_custom<S: Into<String>>(&mut self, sql: S)
Inject a line of custom SQL into the table block
This is a bypass to the barrel typesystem, in case there is something your database supports that barrel doesn’t, or if there is an issue with the way that barrel represents types. It does however mean that the SQL provided needs to be specific for one database, meaning that future migrations might become cumbersome.
sourcepub fn add_index<S: Into<String>>(&mut self, name: S, columns: Type)
pub fn add_index<S: Into<String>>(&mut self, name: S, columns: Type)
Add a new index to a table, spanning over multiple columns
pub fn add_constraint<S: Into<String>>(&mut self, name: S, columns: Type)
pub fn add_partial_index<S: Into<String>>( &mut self, name: S, columns: Type, conditions: S )
sourcepub fn drop_index<S: Into<String>>(&mut self, name: S)
pub fn drop_index<S: Into<String>>(&mut self, name: S)
Drop an index on this table
pub fn add_foreign_key( &mut self, columns_on_this_side: &[&str], related_table: &str, columns_on_that_side: &[&str] )
pub fn set_primary_key(&mut self, columns: &[&str])
sourcepub fn make<T: SqlGenerator>(
&mut self,
ex: bool,
schema: Option<&str>
) -> SqlChanges
pub fn make<T: SqlGenerator>( &mut self, ex: bool, schema: Option<&str> ) -> SqlChanges
Generate Sql for this table.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Table
impl !Send for Table
impl !Sync for Table
impl Unpin for Table
impl !UnwindSafe for Table
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