(db: &DbConn)
| 408 | } |
| 409 | |
| 410 | pub async fn create_collection_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 411 | db.execute(sea_orm::Statement::from_string( |
| 412 | db.get_database_backend(), |
| 413 | "CREATE EXTENSION IF NOT EXISTS citext", |
| 414 | )) |
| 415 | .await?; |
| 416 | |
| 417 | let stmt = sea_query::Table::create() |
| 418 | .table(collection::Entity) |
| 419 | .col( |
| 420 | ColumnDef::new(collection::Column::Id) |
| 421 | .integer() |
| 422 | .not_null() |
| 423 | .auto_increment() |
| 424 | .primary_key(), |
| 425 | ) |
| 426 | .col( |
| 427 | ColumnDef::new(collection::Column::Name) |
| 428 | .custom("citext") |
| 429 | .not_null(), |
| 430 | ) |
| 431 | .col( |
| 432 | ColumnDef::new(collection::Column::Integers) |
| 433 | .array(sea_query::ColumnType::Integer) |
| 434 | .not_null(), |
| 435 | ) |
| 436 | .col(ColumnDef::new(collection::Column::IntegersOpt).array(sea_query::ColumnType::Integer)) |
| 437 | .col( |
| 438 | ColumnDef::new(collection::Column::Teas) |
| 439 | .array(sea_query::ColumnType::Enum { |
| 440 | name: TeaEnum.into_iden(), |
| 441 | variants: vec![ |
| 442 | TeaVariant::EverydayTea.into_iden(), |
| 443 | TeaVariant::BreakfastTea.into_iden(), |
| 444 | ], |
| 445 | }) |
| 446 | .not_null(), |
| 447 | ) |
| 448 | .col( |
| 449 | ColumnDef::new(collection::Column::TeasOpt).array(sea_query::ColumnType::Enum { |
| 450 | name: TeaEnum.into_iden(), |
| 451 | variants: vec![ |
| 452 | TeaVariant::EverydayTea.into_iden(), |
| 453 | TeaVariant::BreakfastTea.into_iden(), |
| 454 | ], |
| 455 | }), |
| 456 | ) |
| 457 | .col( |
| 458 | ColumnDef::new(collection::Column::Colors) |
| 459 | .array(sea_query::ColumnType::Integer) |
| 460 | .not_null(), |
| 461 | ) |
| 462 | .col(ColumnDef::new(collection::Column::ColorsOpt).array(sea_query::ColumnType::Integer)) |
| 463 | .col( |
| 464 | ColumnDef::new(collection::Column::Uuid) |
| 465 | .array(sea_query::ColumnType::Uuid) |
| 466 | .not_null(), |
| 467 | ) |
no test coverage detected