1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::postgres::def::EnumDef;
use sea_query::{
    extension::postgres::{Type, TypeCreateStatement},
    Alias,
};

impl EnumDef {
    /// Converts the [EnumDef] to a [TypeCreateStatement]
    pub fn write(&self) -> TypeCreateStatement {
        Type::create()
            .as_enum(Alias::new(self.typename.as_str()))
            .values(self.values.iter().map(|val| Alias::new(val.as_str())))
            .to_owned()
    }
}