Rust

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;
Rust
pub struct ForeignKey

A foreign key: FOREIGN KEY (column) REFERENCES table (column) with optional ON DELETE / ON UPDATE actions.

use utopia_query::schema::table::Table;
Rust
pub struct Table<S>

A table blueprint for the dialect S: columns, indexes, keys and alterations, compiled by the schema it came from.

Rust
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`))"
);
Also implements Clone, Debug.
use utopia_query::schema::table::TableDefinition;
Rust
pub struct TableDefinition<S>

Everything a table blueprint holds: added columns, indexes, keys, and the alterations, partitioning and engine options set on it.

Also implements Clone, Debug.
use utopia_query::schema::table::Checks;
Rust
pub trait Checks: Schema

Dialects with named table-level CHECK constraints (and column-level ones).

use utopia_query::schema::table::ColumnAlterations;
Rust
pub trait ColumnAlterations: Schema

Dialects that drop and rename columns in ALTER TABLE.

use utopia_query::schema::table::CompositePrimary;
Rust
pub trait CompositePrimary: Schema

Dialects with composite primary keys.

use utopia_query::schema::table::ForeignKeys;
Rust
pub trait ForeignKeys: InlineForeignKey

Dialects that also add and drop foreign keys in ALTER TABLE.

Implemented byMySqlPostgreSql
use utopia_query::schema::table::FulltextSpatialIndex;
Rust
pub trait FulltextSpatialIndex: Schema

Dialects with full-text and spatial indexes.

use utopia_query::schema::table::InlineForeignKey;
Rust
pub trait InlineForeignKey: Schema

Dialects with inline foreign keys in CREATE TABLE.

use utopia_query::schema::table::Serial;
Rust
pub trait Serial: Schema

Dialects with SERIAL column factories.

use utopia_query::schema::table::StandardPartitioning;
Rust
pub trait StandardPartitioning: Schema

Dialects with PARTITION BY RANGE / LIST / HASH.