Add using migration functions

This commit is contained in:
eraden 2023-06-11 23:13:09 +02:00
parent 4ca694b8a2
commit b8ff7fe65b

View File

@ -1,7 +1,9 @@
use sea_orm_migration::prelude::*; use sea_orm_migration::prelude::*;
use crate::constraint::Check; use crate::constraint::Check;
use crate::{auto_uuid_not_null, ts_def_now_not_null, AsIden, CreateConstraint, IntoColumnDef}; use crate::{
auto_uuid_not_null, ts_def_now_not_null, AsIden, CreateConstraint, DropTable, IntoColumnDef,
};
#[derive(DeriveMigrationName)] #[derive(DeriveMigrationName)]
pub struct Migration; pub struct Migration;
@ -11,18 +13,21 @@ impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> { async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
Self::create_tracking_links(m).await?; Self::create_tracking_links(m).await?;
Self::create_custom_shipping_options(m).await?; Self::create_custom_shipping_options(m).await?;
Self::create_shipping_methods(m).await?;
Self::create_shipping_method_tax_lines(m).await?;
Self::create_shipping_options(m).await?;
Self::create_shipping_option_requirements(m).await?;
Self::create_shipping_profiles(m).await?;
Self::create_shipping_tax_rates(m).await?;
Ok(()) Ok(())
} }
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> { async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.drop_table(Table::drop().table(TrackingLink::TrackingLinks).to_owned()) self.drop_table(m, TrackingLink::TrackingLinks).await?;
.await?; self.drop_table(m, CustomShippingOption::CustomShippingOptions)
m.drop_table(
Table::drop()
.table(CustomShippingOption::CustomShippingOptions)
.to_owned(),
)
.await?; .await?;
Ok(()) Ok(())
} }
} }