table
Module[Table]: a fluent table blueprint, compiled by its schema into
CREATE TABLE, ALTER TABLE and the other table statements; and
ForeignKey, a foreign key declared on it.
Contents
use utopia_query::schema::table::ForeignKey;pub struct ForeignKeyA foreign key: FOREIGN KEY (column) REFERENCES table (column) with
optional ON DELETE / ON UPDATE actions.
use utopia_query::schema::table::Table;pub struct Table<S>A table blueprint for the dialect S: columns, indexes, keys and
alterations, compiled by the schema it came from.
use utopia_query::schema::{MySql, Schema};
let mut users = MySql::new().table("users");
users.id("id");
users.string("email", 255).unique();
users.foreign_key("team_id").references("id").on("teams");
assert_eq!(
users.create()?.query,
"CREATE TABLE `users` (`id` BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, `email` VARCHAR(255) NOT NULL, \
PRIMARY KEY (`id`), UNIQUE (`email`), FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`))"
);Clone, Debug.use utopia_query::schema::table::TableDefinition;pub struct TableDefinition<S>Everything a table blueprint holds: added columns, indexes, keys, and the alterations, partitioning and engine options set on it.
Clone, Debug.use utopia_query::schema::table::Checks;pub trait Checks: SchemaDialects with named table-level CHECK constraints (and column-level ones).
use utopia_query::schema::table::ColumnAlterations;pub trait ColumnAlterations: SchemaDialects that drop and rename columns in ALTER TABLE.
use utopia_query::schema::table::CompositePrimary;pub trait CompositePrimary: SchemaDialects with composite primary keys.
use utopia_query::schema::table::ForeignKeys;pub trait ForeignKeys: InlineForeignKeyDialects that also add and drop foreign keys in ALTER TABLE.
use utopia_query::schema::table::FulltextSpatialIndex;pub trait FulltextSpatialIndex: SchemaDialects with full-text and spatial indexes.
use utopia_query::schema::table::InlineForeignKey;pub trait InlineForeignKey: SchemaDialects with inline foreign keys in CREATE TABLE.
use utopia_query::schema::table::Serial;pub trait Serial: SchemaDialects with SERIAL column factories.
use utopia_query::schema::table::StandardPartitioning;pub trait StandardPartitioning: SchemaDialects with PARTITION BY RANGE / LIST / HASH.