(db: &DbConn)
| 128 | } |
| 129 | |
| 130 | pub async fn create_lineitem_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 131 | let stmt = Table::create() |
| 132 | .table(lineitem::Entity) |
| 133 | .col( |
| 134 | ColumnDef::new(lineitem::Column::Id) |
| 135 | .integer() |
| 136 | .not_null() |
| 137 | .auto_increment() |
| 138 | .primary_key(), |
| 139 | ) |
| 140 | .col( |
| 141 | ColumnDef::new(lineitem::Column::Price) |
| 142 | .decimal_len(16, 4) |
| 143 | .not_null(), |
| 144 | ) |
| 145 | .col( |
| 146 | ColumnDef::new(lineitem::Column::Quantity) |
| 147 | .integer() |
| 148 | .not_null(), |
| 149 | ) |
| 150 | .col( |
| 151 | ColumnDef::new(lineitem::Column::OrderId) |
| 152 | .integer() |
| 153 | .not_null(), |
| 154 | ) |
| 155 | .col( |
| 156 | ColumnDef::new(lineitem::Column::CakeId) |
| 157 | .integer() |
| 158 | .not_null(), |
| 159 | ) |
| 160 | .foreign_key( |
| 161 | ForeignKey::create() |
| 162 | .name("fk-lineitem-order_id") |
| 163 | .from(lineitem::Entity, lineitem::Column::OrderId) |
| 164 | .to(order::Entity, order::Column::Id) |
| 165 | .on_delete(ForeignKeyAction::Cascade) |
| 166 | .on_update(ForeignKeyAction::Cascade), |
| 167 | ) |
| 168 | .foreign_key( |
| 169 | ForeignKey::create() |
| 170 | .name("fk-lineitem-cake_id") |
| 171 | .from(lineitem::Entity, lineitem::Column::CakeId) |
| 172 | .to(cake::Entity, cake::Column::Id), |
| 173 | ) |
| 174 | .to_owned(); |
| 175 | |
| 176 | create_table(db, &stmt, Lineitem).await |
| 177 | } |
| 178 | |
| 179 | pub async fn create_cakes_bakers_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 180 | let stmt = Table::create() |
no test coverage detected