pub struct PostgreSql { /* private fields */ }Expand description
The PostgreSQL schema: double-quote quoting, identity columns, SERIAL
types, CHECK-emulated enums, standalone index statements, PL/pgSQL
procedures and triggers, types, sequences, extensions and collations.
use utopia_query::schema::{PostgreSql, Schema};
let mut table = PostgreSql::new().table("users");
table.add_column("bio", utopia_query::schema::ColumnType::Text, None).nullable();
table.drop_column("legacy");
table.index(["email"])?;
assert_eq!(
table.alter()?.query,
"ALTER TABLE \"users\" ADD COLUMN \"bio\" TEXT NULL, DROP COLUMN \"legacy\"; \
CREATE INDEX \"idx_email\" ON \"users\" (\"email\")"
);use Utopia\Query\Schema\ColumnType;
use Utopia\Query\Schema\PostgreSQL;
$table = (new PostgreSQL())->table('users');
$table->addColumn('bio', ColumnType::Text)->nullable();
$table->dropColumn('legacy');
$table->index(['email']);
echo $table->alter()->query, "\n";PHP: Utopia\Query\Schema\PostgreSQL.
Implementations§
Source§impl PostgreSql
impl PostgreSql
Sourcepub fn create_extension(&self, name: &str) -> Result<Statement>
pub fn create_extension(&self, name: &str) -> Result<Statement>
CREATE EXTENSION IF NOT EXISTS name.
PHP: createExtension().
Sourcepub fn drop_extension(&self, name: &str) -> Result<Statement>
pub fn drop_extension(&self, name: &str) -> Result<Statement>
DROP EXTENSION IF EXISTS name.
PHP: dropExtension().
Sourcepub fn create_collation(
&self,
name: &str,
options: &[(&str, &str)],
deterministic: bool,
) -> Result<Statement>
pub fn create_collation( &self, name: &str, options: &[(&str, &str)], deterministic: bool, ) -> Result<Statement>
CREATE COLLATION IF NOT EXISTS name (key = 'value', ..., deterministic = ...);
option keys are identifiers (PHP’s default for deterministic is true).
PHP: createCollation().
Sourcepub fn alter_column_type(
&self,
table: &str,
column: &str,
kind: &str,
using: &str,
) -> Result<Statement>
pub fn alter_column_type( &self, table: &str, column: &str, kind: &str, using: &str, ) -> Result<Statement>
ALTER TABLE table ALTER COLUMN column TYPE type [USING expr]: the
type is a type declaration, the cast expression has no ;, -- or
/* (PHP’s default for using is empty).
PHP: alterColumnType().
Sourcepub fn alter_column_nullable(
&self,
table: &str,
column: &str,
nullable: bool,
) -> Result<Statement>
pub fn alter_column_nullable( &self, table: &str, column: &str, nullable: bool, ) -> Result<Statement>
ALTER TABLE table ALTER COLUMN column DROP NOT NULL / SET NOT NULL.
PHP: alterColumnNullable().
Sourcepub fn drop_index_concurrently(&self, name: &str) -> Result<Statement>
pub fn drop_index_concurrently(&self, name: &str) -> Result<Statement>
DROP INDEX CONCURRENTLY name.
PHP: dropIndexConcurrently().
Trait Implementations§
Source§impl AnalyzeTable for PostgreSql
impl AnalyzeTable for PostgreSql
impl AutoIncrement for PostgreSql
impl Checks for PostgreSql
Source§impl Clone for PostgreSql
impl Clone for PostgreSql
impl Collation for PostgreSql
impl ColumnAlterations for PostgreSql
Source§impl ColumnComments for PostgreSql
impl ColumnComments for PostgreSql
impl CompositePrimary for PostgreSql
Source§impl CreatePartition for PostgreSql
impl CreatePartition for PostgreSql
Source§impl Databases for PostgreSql
impl Databases for PostgreSql
Source§impl Debug for PostgreSql
impl Debug for PostgreSql
Source§impl Default for PostgreSql
impl Default for PostgreSql
impl Dimensions for PostgreSql
Source§impl DropPartition for PostgreSql
impl DropPartition for PostgreSql
impl ForeignKeys for PostgreSql
Source§impl ForeignKeys for PostgreSql
impl ForeignKeys for PostgreSql
impl FulltextSpatialIndex for PostgreSql
impl Generated for PostgreSql
impl InlineForeignKey for PostgreSql
Source§impl Partitioning for PostgreSql
impl Partitioning for PostgreSql
Source§fn compile_create_partitioning(&self, table: &Table<Self>) -> String
fn compile_create_partitioning(&self, table: &Table<Self>) -> String
PARTITION BY kind(expression), without a partition count.
Source§impl Procedures for PostgreSql
impl Procedures for PostgreSql
Source§impl RenameIndex for PostgreSql
impl RenameIndex for PostgreSql
Source§impl ReplaceView for PostgreSql
impl ReplaceView for PostgreSql
Source§fn create_or_replace_view(
&self,
name: &str,
query: &mut dyn AnyBuilder,
) -> Result<Statement>
fn create_or_replace_view( &self, name: &str, query: &mut dyn AnyBuilder, ) -> Result<Statement>
Source§impl Schema for PostgreSql
impl Schema for PostgreSql
Source§fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>
fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>
Identity instead of AUTO_INCREMENT (none for SERIAL types), enums
as a CHECK (... IN (...)), no inline comment.
Source§fn compile_generated_clause(&self, column: &Column<Self>) -> String
fn compile_generated_clause(&self, column: &Column<Self>) -> String
Always STORED: PostgreSQL has no virtual generated columns.
Source§fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>
fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>
Column changes in one ALTER TABLE, indexes as separate CREATE /
DROP INDEX statements, joined by ; .
Source§fn create_index(
&self,
table: &str,
name: &str,
columns: &[&str],
options: &IndexOptions,
) -> Result<Statement>
fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement>
CREATE [UNIQUE] INDEX [CONCURRENTLY] name ON table [USING method] (...).
Source§fn set_executor(&mut self, executor: Executor) -> &mut Self
fn set_executor(&mut self, executor: Executor) -> &mut Self
Statement::execute runs it). Read moreSource§fn literal(&self) -> StringLiteral
fn literal(&self) -> StringLiteral
Source§fn quote(&self, identifier: &str) -> Result<String>
fn quote(&self, identifier: &str) -> Result<String>
Source§fn quote_literal(&self, identifier: &str) -> Result<String>
fn quote_literal(&self, identifier: &str) -> Result<String>
Source§fn compile_column_type(&self, column: &Column<Self>) -> Result<String>
fn compile_column_type(&self, column: &Column<Self>) -> Result<String>
column. Read moreSource§fn compile_auto_increment(&self) -> &'static str
fn compile_auto_increment(&self) -> &'static str
Source§fn quote_collation(&self, collation: &str) -> Result<String>
fn quote_collation(&self, collation: &str) -> Result<String>
COLLATE takes it. Read moreSource§fn compile_unsigned(&self) -> &'static str
fn compile_unsigned(&self) -> &'static str
Source§fn compile_create_suffix(&self, table: &Table<Self>) -> String
fn compile_create_suffix(&self, table: &Table<Self>) -> String
CREATE TABLE (partitioning). Read moreSource§fn table(&self, name: impl Into<String>) -> Table<Self>
fn table(&self, name: impl Into<String>) -> Table<Self>
name compiled by this schema. Read moreSource§impl Sequences for PostgreSql
impl Sequences for PostgreSql
impl Serial for PostgreSql
impl Srid for PostgreSql
impl StandardPartitioning for PostgreSql
Source§impl TableComments for PostgreSql
impl TableComments for PostgreSql
Source§impl Triggers for PostgreSql
impl Triggers for PostgreSql
Source§fn create_trigger(
&self,
name: &str,
table: &str,
timing: TriggerTiming,
event: TriggerEvent,
body: &str,
) -> Result<Statement>
fn create_trigger( &self, name: &str, table: &str, timing: TriggerTiming, event: TriggerEvent, body: &str, ) -> Result<Statement>
A trigger function <name>_func and the trigger executing it; the
body must not contain $$.