(db: &DbConn)
| 10 | } |
| 11 | |
| 12 | pub async fn create_bakery_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 13 | let stmt = Table::create() |
| 14 | .table(bakery::Entity) |
| 15 | .col( |
| 16 | ColumnDef::new(bakery::Column::Id) |
| 17 | .integer() |
| 18 | .not_null() |
| 19 | .auto_increment() |
| 20 | .primary_key(), |
| 21 | ) |
| 22 | .col(ColumnDef::new(bakery::Column::Name).string().not_null()) |
| 23 | .col( |
| 24 | ColumnDef::new(bakery::Column::ProfitMargin) |
| 25 | .double() |
| 26 | .not_null(), |
| 27 | ) |
| 28 | .col( |
| 29 | ColumnDef::new(bakery::Column::ManagerId) |
| 30 | .integer() |
| 31 | .not_null(), |
| 32 | ) |
| 33 | .col( |
| 34 | ColumnDef::new(bakery::Column::CashierId) |
| 35 | .integer() |
| 36 | .not_null(), |
| 37 | ) |
| 38 | .foreign_key( |
| 39 | ForeignKey::create() |
| 40 | .name("fk-bakery-manager_id") |
| 41 | .from(bakery::Entity, bakery::Column::ManagerId) |
| 42 | .to(worker::Entity, worker::Column::Id), |
| 43 | ) |
| 44 | .foreign_key( |
| 45 | ForeignKey::create() |
| 46 | .name("fk-bakery-cashier_id") |
| 47 | .from(bakery::Entity, bakery::Column::CashierId) |
| 48 | .to(worker::Entity, worker::Column::Id), |
| 49 | ) |
| 50 | .to_owned(); |
| 51 | |
| 52 | create_table(db, &stmt, bakery::Entity).await |
| 53 | } |
| 54 | |
| 55 | pub async fn create_worker_table(db: &DbConn) -> Result<ExecResult, DbErr> { |
| 56 | let stmt = Table::create() |
no test coverage detected