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

Function create_cake_table

tests/common/bakery_chain/schema.rs:217–251  ·  view source on GitHub ↗
(db: &DbConn)

Source from the content-addressed store, hash-verified

215}
216
217pub async fn create_cake_table(db: &DbConn) -> Result<ExecResult, DbErr> {
218 let stmt = Table::create()
219 .table(cake::Entity)
220 .col(
221 ColumnDef::new(cake::Column::Id)
222 .integer()
223 .not_null()
224 .auto_increment()
225 .primary_key(),
226 )
227 .col(ColumnDef::new(cake::Column::Name).string().not_null())
228 .col(
229 ColumnDef::new(cake::Column::Price)
230 .decimal_len(16, 4)
231 .not_null(),
232 )
233 .col(ColumnDef::new(cake::Column::BakeryId).integer())
234 .foreign_key(
235 ForeignKey::create()
236 .name("fk-cake-bakery_id")
237 .from(cake::Entity, cake::Column::BakeryId)
238 .to(bakery::Entity, bakery::Column::Id)
239 .on_delete(ForeignKeyAction::SetNull)
240 .on_update(ForeignKeyAction::Cascade),
241 )
242 .col(
243 ColumnDef::new(cake::Column::GlutenFree)
244 .boolean()
245 .not_null(),
246 )
247 .col(ColumnDef::new(cake::Column::Serial).uuid().not_null())
248 .to_owned();
249
250 create_table(db, &stmt, Cake).await
251}

Callers 1

create_tablesFunction · 0.85

Calls 9

on_updateMethod · 0.80
on_deleteMethod · 0.80
createFunction · 0.50
newFunction · 0.50
create_tableFunction · 0.50
auto_incrementMethod · 0.45
toMethod · 0.45
fromMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected