Skip to content

Commit

Permalink
[SeaORM] Edit Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Jan 27, 2024
1 parent 933ad35 commit a1e97a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
22 changes: 3 additions & 19 deletions SeaORM/docs/03-migration/02-writing-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,12 @@ assert_eq!(Post::Text.to_string(), "text");
```
- Create Data Type (PostgreSQL only)
```rust
use sea_orm::{EnumIter, Iterable};

#[derive(Iden, EnumIter)]
pub enum Category {
Table,
#[iden = "Feed"]
Feed,
#[iden = "Story"]
Story,
}

manager
.create_type(
// CREATE TYPE "tea" AS ENUM ('EverydayTea', 'BreakfastTea')
Type::create()
.as_enum(Category::Table)
.values([Category::Feed, Category::Story])
// Or, write it like below.
// Keep in mind that for it to work,
// 1. you need to derive `EnumIter`,
// 2. import `Iterable` into scope
// 3. and make sure `Category::Table` is the first variant
.values(Category::iter().skip(1))
.as_enum(Alias::new("tea"))
.values([Alias::new("EverydayTea"), Alias::new("BreakfastTea")])
.to_owned(),
)
.await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,12 @@ assert_eq!(Post::Text.to_string(), "text");
```
- Create Data Type (PostgreSQL only)
```rust
use sea_orm::{EnumIter, Iterable};

#[derive(Iden, EnumIter)]
pub enum Category {
Table,
#[iden = "Feed"]
Feed,
#[iden = "Story"]
Story,
}

manager
.create_type(
// CREATE TYPE "tea" AS ENUM ('EverydayTea', 'BreakfastTea')
Type::create()
.as_enum(Category::Table)
.values([Category::Feed, Category::Story])
// Or, write it like below.
// Keep in mind that for it to work,
// 1. you need to derive `EnumIter`,
// 2. import `Iterable` into scope
// 3. and make sure `Category::Table` is the first variant
.values(Category::iter().skip(1))
.as_enum(Alias::new("tea"))
.values([Alias::new("EverydayTea"), Alias::new("BreakfastTea")])
.to_owned(),
)
.await?;
Expand Down

0 comments on commit a1e97a9

Please sign in to comment.