(db: &DbConn)
| 215 | } |
| 216 | |
| 217 | pub 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 | } |
no test coverage detected