(db: &DbConn)
| 83 | } |
| 84 | |
| 85 | pub 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 | |
| 130 | pub async fn create_lineitem_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 131 | let stmt = Table::create() |
no test coverage detected