From 764d6159046ba8e0eab29c6cdf0934de83e92460 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Wed, 22 Dec 2021 16:25:53 +0800 Subject: [PATCH] docs: `Schema::create_enum_from_active_enum` (SeaQL/sea-orm#348) --- .../04-generate-database-schema/02-create-enum.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SeaORM/docs/04-generate-database-schema/02-create-enum.md b/SeaORM/docs/04-generate-database-schema/02-create-enum.md index 1ce06a178e2..9fdd05b566f 100644 --- a/SeaORM/docs/04-generate-database-schema/02-create-enum.md +++ b/SeaORM/docs/04-generate-database-schema/02-create-enum.md @@ -109,7 +109,9 @@ pub mod active_enum { ### PostgreSQL -Enum in PostgreSQL is defined as a custom type, it can be created with [`Schema::create_enum_from_entity`](https://docs.rs/sea-orm/0.*/sea_orm/schema/struct.Schema.html#method.create_enum_from_entity) method. +Enum in PostgreSQL is defined as a custom type, it can be created from an `Entity` with [`Schema::create_enum_from_entity`](https://docs.rs/sea-orm/0.*/sea_orm/schema/struct.Schema.html#method.create_enum_from_entity) method. + +Or, it can be created directly from `ActiveEnum` with [`Schema::create_enum_from_active_enum`](https://docs.rs/sea-orm/0.*/sea_orm/schema/struct.Schema.html#method.create_enum_from_active_enum) method. ```rust use sea_orm::{Schema, Statement}; @@ -129,6 +131,14 @@ assert_eq!( ),] ); +assert_eq!( + db_postgres.build(&schema.create_enum_from_active_enum::()), + Statement::from_string( + db_postgres, + r#"CREATE TYPE "tea" AS ENUM ('EverydayTea', 'BreakfastTea')"#.to_owned() + ) +); + assert_eq!( db_postgres.build(&schema.create_table_from_entity(active_enum::Entity)), Statement::from_string(