Skip to main content

Table

Struct Table 

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

The table being created or altered.

Implementations§

Source§

impl Table

Source

pub fn id(&mut self) -> &mut Column

id bigserial primary key — the conventional key every table gets.

Source

pub fn uuid_id(&mut self) -> &mut Column

A UUID primary key, for tables whose ids are exposed publicly.

Source

pub fn string(&mut self, name: &str) -> &mut Column

Source

pub fn string_with(&mut self, name: &str, length: u32) -> &mut Column

Source

pub fn text(&mut self, name: &str) -> &mut Column

Source

pub fn integer(&mut self, name: &str) -> &mut Column

Source

pub fn big_integer(&mut self, name: &str) -> &mut Column

Source

pub fn float(&mut self, name: &str) -> &mut Column

Source

pub fn decimal(&mut self, name: &str, precision: u32, scale: u32) -> &mut Column

An exact decimal — money belongs here, never in a float.

Source

pub fn boolean(&mut self, name: &str) -> &mut Column

Source

pub fn json(&mut self, name: &str) -> &mut Column

Source

pub fn uuid(&mut self, name: &str) -> &mut Column

Source

pub fn date(&mut self, name: &str) -> &mut Column

Source

pub fn timestamp(&mut self, name: &str) -> &mut Column

Source

pub fn binary(&mut self, name: &str) -> &mut Column

Source

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).

Source

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.

Source

pub fn soft_deletes(&mut self)

A nullable deleted_at, for soft deletes.

Source

pub fn index(&mut self, columns: &[&str])

An index across several columns.

Source

pub fn unique(&mut self, columns: &[&str])

Source

pub fn drop_column(&mut self, name: &str)

Drop a column. Only meaningful inside alter.

Trait Implementations§

Source§

impl Default for Table

Source§

fn default() -> Table

Returns the “default value” for a type. Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.