Expand description
A database-neutral schema builder, after Laravel’s Schema::create and Blueprint.
A migration describes a table once and the same code runs on SQLite, MySQL and MariaDB, and PostgreSQL:
use orbit_orm::schema::{self, Action};
let posts = schema::create("posts", |t| {
t.id();
t.string("title");
t.text("body").nullable();
t.big_integer("user_id");
t.foreign("user_id").references("users", "id").on_delete(Action::Restrict);
t.unique(["title"]);
});A Statement is only a description. Statement::to_sql renders it for a Driver as a
list of statements to run in order: PostgreSQL and SQLite create a plain index with a separate
CREATE INDEX, and sqlx does not run several statements in one string on every database.
Structs§
- Blueprint
- The columns, indexes and foreign keys of a table, in the order they were added.
- Column
- A column of a table being created. Chain
nullable,defaultandlengthon it. - Foreign
Key - A foreign key under construction. Chain
references,on_deleteandon_update. - Statement
- A schema change, ready to render for any database.
Enums§
- Action
- What a foreign key does to this table’s rows when the referenced row is deleted or updated.
Functions§
- create
- Creates a table. The closure describes its columns, indexes and foreign keys.
- drop
- Drops a table. It is an error in the database if the table does not exist.
- drop_
if_ exists - Drops a table if it exists.