pub struct Table { /* private fields */ }Expand description
The table being created or altered.
Implementations§
Source§impl Table
impl Table
Sourcepub fn id(&mut self) -> &mut Column
pub fn id(&mut self) -> &mut Column
id bigserial primary key — the conventional key every table gets.
Sourcepub fn uuid_id(&mut self) -> &mut Column
pub fn uuid_id(&mut self) -> &mut Column
A UUID primary key, for tables whose ids are exposed publicly.
pub fn string(&mut self, name: &str) -> &mut Column
pub fn string_with(&mut self, name: &str, length: u32) -> &mut Column
pub fn text(&mut self, name: &str) -> &mut Column
pub fn integer(&mut self, name: &str) -> &mut Column
pub fn big_integer(&mut self, name: &str) -> &mut Column
pub fn float(&mut self, name: &str) -> &mut Column
Sourcepub fn decimal(&mut self, name: &str, precision: u32, scale: u32) -> &mut Column
pub fn decimal(&mut self, name: &str, precision: u32, scale: u32) -> &mut Column
An exact decimal — money belongs here, never in a float.
pub fn boolean(&mut self, name: &str) -> &mut Column
pub fn json(&mut self, name: &str) -> &mut Column
pub fn uuid(&mut self, name: &str) -> &mut Column
pub fn date(&mut self, name: &str) -> &mut Column
pub fn timestamp(&mut self, name: &str) -> &mut Column
pub fn binary(&mut self, name: &str) -> &mut Column
Sourcepub fn foreign_id(&mut self, singular: &str) -> &mut Column
pub fn foreign_id(&mut self, singular: &str) -> &mut Column
A foreign key column named after the table it points at:
t.foreign_id("user") becomes user_id bigint references users (id).
Sourcepub fn timestamps(&mut self)
pub fn timestamps(&mut self)
created_at and updated_at, both defaulting to now.
The expression is filled in when the statements are rendered, because only then is the database known.
Sourcepub fn soft_deletes(&mut self)
pub fn soft_deletes(&mut self)
A nullable deleted_at, for soft deletes.
pub fn unique(&mut self, columns: &[&str])
Sourcepub fn drop_column(&mut self, name: &str)
pub fn drop_column(&mut self, name: &str)
Drop a column. Only meaningful inside alter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin 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