Fix migration

This commit is contained in:
Adrian Woźniak 2023-06-14 12:44:55 +02:00
parent 2974a180f5
commit b3b1acdb05
3 changed files with 67 additions and 56 deletions

View File

@ -8,57 +8,45 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
create_type!(manager, PaymentCollectionStatus);
create_type!(manager, CartType);
create_type!(manager, ClaimItemReason);
create_type!(manager, ClaimOrderFulfillmentStatus);
create_type!(manager, ClaimOrderPaymentStatus);
create_type!(manager, ClaimOrderType);
create_type!(manager, DraftOrderStatus);
create_type!(manager, InviteRole);
create_type!(manager, OrderFulfillmentStatus);
create_type!(manager, OrderItemChangeType);
create_type!(manager, OrderPaymentStatus);
create_type!(manager, PaymentSessionStatus);
create_type!(manager, PriceListStatus);
create_type!(manager, PriceListType);
create_type!(manager, ProductStatus);
create_type!(manager, RefundReason);
create_type!(manager, ReturnStatus);
create_type!(manager, ShippingOptionPriceType);
create_type!(manager, ShippingOptionRequirementType);
create_type!(manager, ShippingProfileType);
create_type!(manager, SwapFulfillmentStatus);
create_type!(manager, SwapPaymentStatus);
create_type!(manager, UserRole);
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_type!(m, PaymentCollectionStatus);
create_type!(m, CartType);
create_type!(m, ClaimItemReason);
create_type!(m, ClaimOrderFulfillmentStatus);
create_type!(m, ClaimOrderPaymentStatus);
create_type!(m, ClaimOrderType);
create_type!(m, DraftOrderStatus);
create_type!(m, InviteRole);
create_type!(m, OrderFulfillmentStatus);
create_type!(m, OrderItemChangeType);
create_type!(m, OrderPaymentStatus);
create_type!(m, PaymentSessionStatus);
create_type!(m, RefundReason);
create_type!(m, ReturnStatus);
create_type!(m, SwapFulfillmentStatus);
create_type!(m, SwapPaymentStatus);
create_type!(m, UserRole);
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
drop_type!(manager, PaymentCollectionStatus);
drop_type!(manager, CartType);
drop_type!(manager, ClaimItemReason);
drop_type!(manager, ClaimOrderFulfillmentStatus);
drop_type!(manager, ClaimOrderPaymentStatus);
drop_type!(manager, ClaimOrderType);
drop_type!(manager, DraftOrderStatus);
drop_type!(manager, InviteRole);
drop_type!(manager, OrderFulfillmentStatus);
drop_type!(manager, OrderItemChangeType);
drop_type!(manager, OrderPaymentStatus);
drop_type!(manager, PaymentSessionStatus);
drop_type!(manager, PriceListStatus);
drop_type!(manager, PriceListType);
drop_type!(manager, ProductStatus);
drop_type!(manager, RefundReason);
drop_type!(manager, ReturnStatus);
drop_type!(manager, ShippingOptionPriceType);
drop_type!(manager, ShippingOptionRequirementType);
drop_type!(manager, ShippingProfileType);
drop_type!(manager, SwapFulfillmentStatus);
drop_type!(manager, SwapPaymentStatus);
drop_type!(manager, UserRole);
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_type!(m, PaymentCollectionStatus);
drop_type!(m, CartType);
drop_type!(m, ClaimItemReason);
drop_type!(m, ClaimOrderFulfillmentStatus);
drop_type!(m, ClaimOrderPaymentStatus);
drop_type!(m, ClaimOrderType);
drop_type!(m, DraftOrderStatus);
drop_type!(m, InviteRole);
drop_type!(m, OrderFulfillmentStatus);
drop_type!(m, OrderItemChangeType);
drop_type!(m, OrderPaymentStatus);
drop_type!(m, PaymentSessionStatus);
drop_type!(m, RefundReason);
drop_type!(m, ReturnStatus);
drop_type!(m, SwapFulfillmentStatus);
drop_type!(m, SwapPaymentStatus);
drop_type!(m, UserRole);
Ok(())
}
}

View File

@ -2,10 +2,7 @@ use sea_orm_migration::prelude::*;
use crate::constraint::Check;
use crate::sea_orm::Iterable;
use crate::{
auto_uuid_not_null, ts_def_now_not_null, AsIden, CreateBridgeTable, CreateConstraint,
DropTable, IntoColumnDef,
};
use crate::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
@ -13,6 +10,10 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_type!(m, ShippingOptionPriceType);
create_type!(m, ShippingOptionRequirementType);
create_type!(m, ShippingProfileType);
Self::create_tracking_links(m).await?;
Self::create_custom_shipping_options(m).await?;
@ -26,10 +27,25 @@ impl MigrationTrait for Migration {
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_type!(m, ShippingOptionPriceType);
drop_type!(m, ShippingOptionRequirementType);
drop_type!(m, ShippingProfileType);
self.drop_table(m, TrackingLink::TrackingLinks).await?;
self.drop_table(m, CustomShippingOption::CustomShippingOptions)
.await?;
self.drop_table(m, ShippingMethod::ShippingMethods).await?;
self.drop_table(m, ShippingMethodTaxLine::ShippingMethodTaxLines)
.await?;
self.drop_table(m, ShippingOption::ShippingOptions).await?;
self.drop_table(m, ShippingOptionRequirement::ShippingOptionRequirements)
.await?;
self.drop_table(m, ShippingProfile::ShippingProfiles)
.await?;
self.drop_table(m, ShippingTaxRate::ShippingTaxRates)
.await?;
Ok(())
}
}

View File

@ -2,10 +2,7 @@ use sea_orm_migration::prelude::*;
use crate::constraint::Check;
use crate::sea_orm::Iterable;
use crate::{
auto_uuid_not_null, ts_def_now_not_null, AsIden, CreateBridgeTable, CreateConstraint,
DropTable, IntoColumnDef,
};
use crate::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
@ -13,6 +10,10 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_type!(m, PriceListType);
create_type!(m, PriceListStatus);
create_type!(m, ProductStatus);
self.create_price_lists(m).await?;
self.create_price_list_customer_groups(m).await?;
self.create_products(m).await?;
@ -31,10 +32,15 @@ impl MigrationTrait for Migration {
self.create_product_variants(m).await?;
self.create_product_variant_inventory_items(m).await?;
self.create_money_amounts(m).await?;
Ok(())
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_type!(m, PriceListType);
drop_type!(m, PriceListStatus);
drop_type!(m, ProductStatus);
self.drop_table(m, PriceList::PriceLists).await?;
self.drop_table(m, PriceListCustomerGroup::PriceListCustomerGroups)
.await?;
@ -412,6 +418,7 @@ impl Migration {
m.create_table(
Table::create()
.table(ProductTags)
.col(auto_uuid_not_null!(Id))
.col(Value.col().string().not_null())
.col(ts_def_now_not_null!(CreatedAt))