Skip to main content

Column

Struct Column 

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

A column of a table being created or changed. Chain nullable, default, use_current, length, precision, primary and change on it.

Implementations§

Source§

impl Column

Source

pub fn nullable(&mut self) -> &mut Self

Lets the column hold NULL. Columns are NOT NULL otherwise, as in Laravel.

Source

pub fn default(&mut self, value: impl Into<Value>) -> &mut Self

Sets the default value, written into the SQL as a literal.

Source

pub fn length(&mut self, length: u32) -> &mut Self

Sets the length of a string column. It has no effect on other types.

Source

pub fn precision(&mut self, precision: u32) -> &mut Self

Sets the fractional-second precision of a date_time or timestamp column, as the $precision argument of Laravel’s dateTime and timestamp (default 0): DATETIME(p) or TIMESTAMP(p) on MySQL, TIMESTAMP(p) WITHOUT TIME ZONE on PostgreSQL. SQLite keeps DATETIME. It has no effect on other types.

The valid range is 0 to 6. Orbit does not check it: MySQL and MariaDB reject a larger value, and PostgreSQL lowers it to 6 with a warning.

Source

pub fn use_current(&mut self) -> &mut Self

Makes the current time the default of a date_time or timestamp column, as Laravel’s ->useCurrent(): DEFAULT CURRENT_TIMESTAMP, or CURRENT_TIMESTAMP(p) on MySQL with a precision p above 0. It takes the place of any default value. As in Laravel, it has no effect on other types.

Source

pub fn primary(&mut self) -> &mut Self

Makes this column the table’s primary key, as Laravel’s ->primary(): PRIMARY KEY at the end of the column definition, for a key that is not an auto-incrementing id, such as t.string("id").length(64).primary(). For a key over several columns, use Blueprint::primary. In schema::table SQLite cannot add it, and no database can take it with .change(): both are Error::Unsupported.

Source

pub fn change(&mut self) -> &mut Self

Modifies this existing column instead of adding it, as Laravel’s ->change(). It only works inside schema::table: the column takes the type, nullability and default described here. SQLite cannot change a column in place, so rendering it there is Error::Unsupported; so is changing an id column, or a column marked primary, on every database.

Trait Implementations§

Source§

impl Clone for Column

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Column

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Column

§

impl Freeze for Column

§

impl Move for Column

§

impl RefUnwindSafe for Column

§

impl Send for Column

§

impl Sync for Column

§

impl Unpin for Column

§

impl UnsafeUnpin for Column

§

impl UnwindSafe for Column

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more