sea_schema/mysql/def/
index.rs

1#[cfg(feature = "with-serde")]
2use serde::{Deserialize, Serialize};
3
4use crate as sea_schema;
5
6#[derive(Clone, Debug, PartialEq)]
7#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
8pub struct IndexInfo {
9    /// Does this index requires unique values
10    pub unique: bool,
11    /// The name of the index
12    pub name: String,
13    /// The parts composing this index
14    pub parts: Vec<IndexPart>,
15    /// Does this index allow null values
16    pub nullable: bool,
17    /// BTree (the default), full-text etc
18    pub idx_type: IndexType,
19    /// User comments
20    pub comment: String,
21    /// True if part of the index is computed
22    pub functional: bool,
23}
24
25#[derive(Clone, Debug, PartialEq)]
26#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
27pub struct IndexPart {
28    /// Identifier for this column. If functional is true, may contain expression.
29    pub column: String,
30    /// Ascending, descending or unordered
31    pub order: IndexOrder,
32    /// If the whole column is indexed, this value is null. Otherwise the number indicates number of characters indexed
33    pub sub_part: Option<u32>,
34}
35
36#[derive(Clone, Debug, PartialEq)]
37#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
38pub enum IndexOrder {
39    Ascending,
40    Descending,
41    Unordered,
42}
43
44#[derive(Clone, Debug, PartialEq, sea_query::Iden, sea_schema_derive::Name)]
45#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
46pub enum IndexType {
47    #[iden = "BTREE"]
48    BTree,
49    #[iden = "FULLTEXT"]
50    FullText,
51    #[iden = "HASH"]
52    Hash,
53    #[iden = "RTREE"]
54    RTree,
55    #[iden = "SPATIAL"]
56    Spatial,
57    #[cfg(feature = "planetscale")]
58    #[iden = "VECTOR"]
59    Vector,
60}