uqa_sql/ast/type_lifecycle.rs
1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! `ALTER TYPE | DOMAIN ... RENAME TO | SET SCHEMA | OWNER TO`.
8
9use serde::{Deserialize, Serialize};
10
11use super::RoleSpecification;
12
13/// The keyword that named the target. `DOMAIN` statements reject types that are not domains.
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
15pub enum TypeObjectKind {
16 Type,
17 Domain,
18}
19
20/// One `ALTER TYPE` or `ALTER DOMAIN` lifecycle change of a user-defined type and its generated array type.
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct AlterTypeObject {
23 pub kind: TypeObjectKind,
24 /// Rendered, possibly qualified type name as written.
25 pub name: String,
26 pub action: AlterTypeObjectAction,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub enum AlterTypeObjectAction {
31 /// The new unqualified name.
32 RenameTo(String),
33 /// The destination schema.
34 SetSchema(String),
35 OwnerTo(RoleSpecification),
36 /// Append attributes to a standalone composite relation in written order.
37 AddAttributes(Vec<super::CompositeAttributeAddition>),
38}