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
impl Column
Sourcepub fn nullable(&mut self) -> &mut Self
pub fn nullable(&mut self) -> &mut Self
Lets the column hold NULL. Columns are NOT NULL otherwise, as in Laravel.
Sourcepub fn default(&mut self, value: impl Into<Value>) -> &mut Self
pub fn default(&mut self, value: impl Into<Value>) -> &mut Self
Sets the default value, written into the SQL as a literal.
Sourcepub fn length(&mut self, length: u32) -> &mut Self
pub fn length(&mut self, length: u32) -> &mut Self
Sets the length of a string column. It has no effect on other types.
Sourcepub fn precision(&mut self, precision: u32) -> &mut Self
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.
Sourcepub fn use_current(&mut self) -> &mut Self
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.
Sourcepub fn primary(&mut self) -> &mut Self
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.
Sourcepub fn change(&mut self) -> &mut Self
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§
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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