45 lines
1.4 KiB
Rust
45 lines
1.4 KiB
Rust
use sea_orm_migration::prelude::*;
|
|
|
|
pub struct Migration;
|
|
|
|
impl MigrationName for Migration {
|
|
fn name(&self) -> &str {
|
|
"m20240217_000000_create_route_table" // Make sure this matches with the file name
|
|
}
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
// Define how to apply this migration: Create the table.
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(RouteStopRelation::Table)
|
|
.col(
|
|
ColumnDef::new(RouteStopRelation::RouteId)
|
|
.integer()
|
|
.not_null()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(RouteStopRelationRoute::Name).string().not_null())
|
|
.col(ColumnDef::new(RouteStopRelationBakery::ProfitMargin).double().not_null())
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
// Define how to rollback this migration: Drop the Bakery table.
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Bakery::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[derive(Iden)]
|
|
pub enum RouteStopRelation{
|
|
Table,
|
|
RouteId,
|
|
StopId,
|
|
}
|