(db: &DbConn)
| 36 | } |
| 37 | |
| 38 | pub async fn create_baker_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 39 | let stmt = Table::create() |
| 40 | .table(baker::Entity) |
| 41 | .col( |
| 42 | ColumnDef::new(baker::Column::Id) |
| 43 | .integer() |
| 44 | .not_null() |
| 45 | .auto_increment() |
| 46 | .primary_key(), |
| 47 | ) |
| 48 | .col(ColumnDef::new(baker::Column::Name).string().not_null()) |
| 49 | .col( |
| 50 | ColumnDef::new(baker::Column::ContactDetails) |
| 51 | .json() |
| 52 | .not_null(), |
| 53 | ) |
| 54 | .col(ColumnDef::new(baker::Column::BakeryId).integer()) |
| 55 | .foreign_key( |
| 56 | ForeignKey::create() |
| 57 | .name("fk-baker-bakery_id") |
| 58 | .from(baker::Entity, baker::Column::BakeryId) |
| 59 | .to(bakery::Entity, bakery::Column::Id) |
| 60 | .on_delete(ForeignKeyAction::SetNull) |
| 61 | .on_update(ForeignKeyAction::Cascade), |
| 62 | ) |
| 63 | .to_owned(); |
| 64 | |
| 65 | create_table(db, &stmt, Baker).await |
| 66 | } |
| 67 | |
| 68 | pub async fn create_customer_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 69 | let stmt = Table::create() |
no test coverage detected