MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / create_collection_table

Function create_collection_table

tests/common/features/schema.rs:410–476  ·  view source on GitHub ↗
(db: &DbConn)

Source from the content-addressed store, hash-verified

408}
409
410pub 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 )

Callers 1

create_tablesFunction · 0.85

Calls 6

createFunction · 0.50
newFunction · 0.50
create_tableFunction · 0.50
executeMethod · 0.45
get_database_backendMethod · 0.45
auto_incrementMethod · 0.45

Tested by

no test coverage detected