pub struct CreateTableQuery {Show 13 fields
pub collection_model: CollectionModel,
pub name: String,
pub columns: Vec<CreateColumnDef>,
pub if_not_exists: bool,
pub default_ttl_ms: Option<u64>,
pub context_index_fields: Vec<String>,
pub context_index_enabled: bool,
pub timestamps: bool,
pub partition_by: Option<PartitionSpec>,
pub tenant_by: Option<String>,
pub append_only: bool,
pub subscriptions: Vec<SubscriptionDescriptor>,
pub vault_own_master_key: bool,
}Expand description
CREATE TABLE name (columns) or CREATE {KV|CONFIG|VAULT} name
Fields§
§collection_model: CollectionModelDeclared collection model. Defaults to Table for CREATE TABLE.
name: StringTable name
columns: Vec<CreateColumnDef>Column definitions
if_not_exists: boolIF NOT EXISTS flag
default_ttl_ms: Option<u64>Optional default TTL applied to newly inserted items in this collection.
context_index_fields: Vec<String>Fields to prioritize in the context index (WITH CONTEXT INDEX ON (f1, f2))
context_index_enabled: boolEnables the global context index for this table
(WITH context_index = true). Default false — pure OLTP tables
skip the tokenisation / 3-way RwLock write storm on every insert.
Having context_index_fields non-empty also enables it implicitly.
timestamps: boolWhen true, CREATE TABLE implicitly adds two user-visible columns
created_at and updated_at (BIGINT unix-ms). The runtime
populates them from UnifiedEntity::created_at/updated_at on
every write; created_at is immutable after insert.
Enabled via WITH timestamps = true in the DDL.
partition_by: Option<PartitionSpec>Partitioning spec (Phase 2.2 PG parity).
When present the table is the parent of a partition tree — every
child partition is registered via ALTER TABLE ... ATTACH PARTITION.
Phase 2.2 stops at registry-only: queries against a partitioned
parent don’t auto-rewrite as UNION yet (Phase 4 adds pruning).
tenant_by: Option<String>Table-scoped multi-tenancy declaration (Phase 2.5.4).
Syntax: CREATE TABLE t (...) WITH (tenant_by = 'col_name') or
the shorthand CREATE TABLE t (...) TENANT BY (col_name). The
runtime treats the named column as the tenant discriminator and
automatically:
- Registers the table → column mapping so INSERTs that omit the
column get
CURRENT_TENANT()auto-filled. - Installs an implicit RLS policy equivalent to
USING (col = CURRENT_TENANT())for SELECT/UPDATE/DELETE/INSERT. - Flips
rls_enabled_tableson so the policy actually applies.
None leaves the table non-tenant-scoped — callers manage tenancy manually via explicit CREATE POLICY if they want it.
append_only: boolWhen true, UPDATE and DELETE on this table are rejected at
parse time. Corresponds to CREATE TABLE ... APPEND ONLY or
WITH (append_only = true). Default false (mutable).
subscriptions: Vec<SubscriptionDescriptor>Declarative event subscriptions for this table. #291 stores metadata only; event emission is intentionally out of scope.
vault_own_master_key: boolCREATE VAULT ... WITH OWN MASTER KEY: provision per-vault
key material instead of using the cluster vault key.
Trait Implementations§
Source§impl Clone for CreateTableQuery
impl Clone for CreateTableQuery
Source§fn clone(&self) -> CreateTableQuery
fn clone(&self) -> CreateTableQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CreateTableQuery
impl RefUnwindSafe for CreateTableQuery
impl Send for CreateTableQuery
impl Sync for CreateTableQuery
impl Unpin for CreateTableQuery
impl UnsafeUnpin for CreateTableQuery
impl UnwindSafe for CreateTableQuery
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request