pub struct Blueprint { /* private fields */ }Expand description
The columns and commands (indexes, keys, renames, drops) of a table, in the order they were added.
Implementations§
Source§impl Blueprint
impl Blueprint
Sourcepub fn id(&mut self) -> &mut Column
pub fn id(&mut self) -> &mut Column
An auto-incrementing 64-bit primary key named id. In schema::table
SQLite cannot add it, as SQLite cannot add a primary key column to an existing table.
Sourcepub fn string(&mut self, name: &str) -> &mut Column
pub fn string(&mut self, name: &str) -> &mut Column
A VARCHAR(255); TEXT on SQLite. Change the length with .length(n).
Sourcepub fn medium_text(&mut self, name: &str) -> &mut Column
pub fn medium_text(&mut self, name: &str) -> &mut Column
A MEDIUMTEXT column (up to 16 MB) on MySQL and MariaDB, as Laravel’s mediumText. It is
TEXT on PostgreSQL, which has no size limit, and on SQLite, where text is limited only by
the database’s size limits.
Sourcepub fn long_text(&mut self, name: &str) -> &mut Column
pub fn long_text(&mut self, name: &str) -> &mut Column
A LONGTEXT column (up to 4 GB) on MySQL and MariaDB, as Laravel’s longText. It is TEXT
on PostgreSQL, which has no size limit, and on SQLite, where text is limited only by the
database’s size limits. WordPress uses LONGTEXT for post content and for option and meta
values.
Sourcepub fn big_integer(&mut self, name: &str) -> &mut Column
pub fn big_integer(&mut self, name: &str) -> &mut Column
A BIGINT column; INTEGER on SQLite, whose integers are 64-bit already.
Sourcepub fn boolean(&mut self, name: &str) -> &mut Column
pub fn boolean(&mut self, name: &str) -> &mut Column
A boolean: BOOLEAN on PostgreSQL, TINYINT(1) elsewhere.
Sourcepub fn date_time(&mut self, name: &str) -> &mut Column
pub fn date_time(&mut self, name: &str) -> &mut Column
A date and time without a time zone: DATETIME, or TIMESTAMP(0) on PostgreSQL. Set
fractional seconds with .precision(p) and a default of the current time with
.use_current().
Sourcepub fn timestamp(&mut self, name: &str) -> &mut Column
pub fn timestamp(&mut self, name: &str) -> &mut Column
A timestamp, as Laravel’s timestamp: TIMESTAMP on MySQL, TIMESTAMP(0) WITHOUT TIME ZONE on PostgreSQL, DATETIME on SQLite. Set fractional seconds with .precision(p) and
a default of the current time with .use_current().
On MySQL and MariaDB with explicit_defaults_for_timestamp off (the MariaDB default
before 10.10), the first TIMESTAMP column of a table that is NOT NULL and has no
default gets DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP from the server.
Laravel’s columns get the same. Add .nullable() or a default to avoid it.
Sourcepub fn binary(&mut self, name: &str) -> &mut Column
pub fn binary(&mut self, name: &str) -> &mut Column
A column of raw bytes, as Laravel’s binary: BLOB, or BYTEA on PostgreSQL.
Sourcepub fn timestamps(&mut self)
pub fn timestamps(&mut self)
Nullable created_at and updated_at columns.
Sourcepub fn unique<I, S>(&mut self, columns: I) -> &mut Index
pub fn unique<I, S>(&mut self, columns: I) -> &mut Index
A unique constraint over columns, named {table}_{columns}_unique unless .name()
gives another name.
Sourcepub fn index<I, S>(&mut self, columns: I) -> &mut Index
pub fn index<I, S>(&mut self, columns: I) -> &mut Index
A plain index over columns, named {table}_{columns}_index unless .name() gives
another name.
Sourcepub fn primary<I, S>(&mut self, columns: I)
pub fn primary<I, S>(&mut self, columns: I)
A primary key over columns, as Laravel’s $table->primary(['a', 'b']): the table
constraint PRIMARY KEY (a, b). For a key of one column, .primary() on the column does
the same. In schema::table SQLite cannot add it: it is
Error::Unsupported there.
Sourcepub fn foreign(&mut self, column: &str) -> &mut ForeignKey
pub fn foreign(&mut self, column: &str) -> &mut ForeignKey
A foreign key on column, named {table}_{column}_foreign unless .name() gives another
name. In schema::table SQLite renders nothing, as SQLite cannot add a
constraint to an existing table.
Sourcepub fn rename_column(&mut self, from: &str, to: &str)
pub fn rename_column(&mut self, from: &str, to: &str)
Renames the column from to to: ALTER TABLE ... RENAME COLUMN. Only in
schema::table.
RENAME COLUMN needs MySQL 8.0.3 or later, or MariaDB 10.5.2 or later. On older servers
Laravel falls back to CHANGE old new <definition>; Orbit does not, and the server
reports a syntax error.
Sourcepub fn drop_column(&mut self, name: &str)
pub fn drop_column(&mut self, name: &str)
Drops the column name: ALTER TABLE ... DROP COLUMN. Only in
schema::table. SQLite needs version 3.35 or later.
Sourcepub fn drop_index(&mut self, name: &str)
pub fn drop_index(&mut self, name: &str)
Drops the index name, as Laravel’s dropIndex('name'). Only in
schema::table.
On MySQL it drops a unique index too. On SQLite it drops a unique only when unique added
it in schema::table: a unique declared in schema::create is an inline
constraint there and cannot be dropped this way. On PostgreSQL unique always adds a
constraint, and DROP INDEX cannot drop the index of a constraint. Orbit has no
drop_unique (Laravel’s dropUnique).
Sourcepub fn drop_foreign(&mut self, name: &str)
pub fn drop_foreign(&mut self, name: &str)
Drops the foreign key name, as Laravel’s dropForeign('name'). Only in
schema::table. SQLite renders nothing, as it cannot drop a constraint
from an existing table and foreign added none there.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Blueprint
impl Freeze for Blueprint
impl Move for Blueprint
impl RefUnwindSafe for Blueprint
impl Send for Blueprint
impl Sync for Blueprint
impl Unpin for Blueprint
impl UnsafeUnpin for Blueprint
impl UnwindSafe for Blueprint
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