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

Function create_order_table

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

Source from the content-addressed store, hash-verified

83}
84
85pub async fn create_order_table(db: &DbConn) -> Result<ExecResult, DbErr> {
86 let stmt = Table::create()
87 .table(order::Entity)
88 .col(
89 ColumnDef::new(order::Column::Id)
90 .integer()
91 .not_null()
92 .auto_increment()
93 .primary_key(),
94 )
95 .col(
96 ColumnDef::new(order::Column::Total)
97 .decimal_len(16, 4)
98 .not_null(),
99 )
100 .col(ColumnDef::new(order::Column::BakeryId).integer().not_null())
101 .col(
102 ColumnDef::new(order::Column::CustomerId)
103 .integer()
104 .not_null(),
105 )
106 .col(
107 ColumnDef::new(order::Column::PlacedAt)
108 .date_time()
109 .not_null(),
110 )
111 .foreign_key(
112 ForeignKey::create()
113 .name("fk-order-bakery_id")
114 .from(order::Entity, order::Column::BakeryId)
115 .to(bakery::Entity, bakery::Column::Id),
116 )
117 .foreign_key(
118 ForeignKey::create()
119 .name("fk-order-customer_id")
120 .from(order::Entity, order::Column::CustomerId)
121 .to(customer::Entity, customer::Column::Id)
122 .on_delete(ForeignKeyAction::Cascade)
123 .on_update(ForeignKeyAction::Cascade),
124 )
125 .to_owned();
126
127 create_table(db, &stmt, Order).await
128}
129
130pub async fn create_lineitem_table(db: &DbConn) -> Result<ExecResult, DbErr> {
131 let stmt = Table::create()

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