Finish products
This commit is contained in:
parent
4fd3615343
commit
5111c6efb2
@ -51,7 +51,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(
|
m.create_2_col_primary(
|
||||||
CartDiscount::CartDiscounts,
|
CartDiscount::CartDiscounts,
|
||||||
CartDiscount::CartId,
|
CartDiscount::CartId,
|
||||||
CartDiscount::DiscountId,
|
CartDiscount::DiscountId,
|
||||||
@ -79,7 +79,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(
|
m.create_2_col_primary(
|
||||||
CartGiftCard::CartGiftCards,
|
CartGiftCard::CartGiftCards,
|
||||||
CartGiftCard::CartId,
|
CartGiftCard::CartId,
|
||||||
CartGiftCard::GiftCardId,
|
CartGiftCard::GiftCardId,
|
||||||
|
@ -194,7 +194,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(
|
m.create_2_col_primary(
|
||||||
OrderDiscount::OrderDiscounts,
|
OrderDiscount::OrderDiscounts,
|
||||||
OrderDiscount::OrderId,
|
OrderDiscount::OrderId,
|
||||||
OrderDiscount::DiscountId,
|
OrderDiscount::DiscountId,
|
||||||
@ -270,7 +270,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(
|
m.create_2_col_primary(
|
||||||
OrderGiftCard::OrderGiftCards,
|
OrderGiftCard::OrderGiftCards,
|
||||||
OrderGiftCard::OrderId,
|
OrderGiftCard::OrderId,
|
||||||
OrderGiftCard::GiftCardId,
|
OrderGiftCard::GiftCardId,
|
||||||
@ -454,7 +454,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(
|
m.create_2_col_primary(
|
||||||
PaymentCollectionPayment::PaymentCollectionPayments,
|
PaymentCollectionPayment::PaymentCollectionPayments,
|
||||||
PaymentCollectionPayment::PaymentCollectionId,
|
PaymentCollectionPayment::PaymentCollectionId,
|
||||||
PaymentCollectionPayment::PaymentId,
|
PaymentCollectionPayment::PaymentId,
|
||||||
@ -508,7 +508,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(
|
m.create_2_col_primary(
|
||||||
PaymentCollectionSession::PaymentCollectionSessions,
|
PaymentCollectionSession::PaymentCollectionSessions,
|
||||||
PaymentCollectionSession::PaymentCollectionId,
|
PaymentCollectionSession::PaymentCollectionId,
|
||||||
PaymentCollectionSession::PaymentSessionId,
|
PaymentCollectionSession::PaymentSessionId,
|
||||||
|
@ -55,7 +55,12 @@ impl<T: IntoIden> IntoColumnDef for T {}
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait CreateIndexExt {
|
pub trait CreateIndexExt {
|
||||||
async fn create_2col_idx<T, C1, C2>(&self, table: T, col1: C1, col2: C2) -> Result<(), DbErr>
|
async fn create_2_col_primary<T, C1, C2>(
|
||||||
|
&self,
|
||||||
|
table: T,
|
||||||
|
col1: C1,
|
||||||
|
col2: C2,
|
||||||
|
) -> Result<(), DbErr>
|
||||||
where
|
where
|
||||||
T: IntoIden + Copy + 'static + Sync + Send,
|
T: IntoIden + Copy + 'static + Sync + Send,
|
||||||
C1: IntoIden + Copy + 'static + Sync + Send,
|
C1: IntoIden + Copy + 'static + Sync + Send,
|
||||||
@ -64,7 +69,12 @@ pub trait CreateIndexExt {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl CreateIndexExt for SchemaManager<'_> {
|
impl CreateIndexExt for SchemaManager<'_> {
|
||||||
async fn create_2col_idx<T, C1, C2>(&self, table: T, col1: C1, col2: C2) -> Result<(), DbErr>
|
async fn create_2_col_primary<T, C1, C2>(
|
||||||
|
&self,
|
||||||
|
table: T,
|
||||||
|
col1: C1,
|
||||||
|
col2: C2,
|
||||||
|
) -> Result<(), DbErr>
|
||||||
where
|
where
|
||||||
T: IntoIden + Copy + 'static + Sync + Send,
|
T: IntoIden + Copy + 'static + Sync + Send,
|
||||||
C1: IntoIden + Copy + 'static + Sync + Send,
|
C1: IntoIden + Copy + 'static + Sync + Send,
|
||||||
@ -120,7 +130,7 @@ impl CreateBridgeTable for SchemaManager<'_> {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.create_2col_idx(table, col1, col2).await?;
|
self.create_2_col_primary(table, col1, col2).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ impl Migration {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
m.create_2col_idx(ShippingTaxRates, ShippingOptionId, RateId)
|
m.create_2_col_primary(ShippingTaxRates, ShippingOptionId, RateId)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -451,6 +451,21 @@ impl Migration {
|
|||||||
async fn create_product_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
async fn create_product_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
use ProductTaxRate::*;
|
use ProductTaxRate::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProductTaxRates)
|
||||||
|
.col(ProductId.col().uuid().not_null())
|
||||||
|
.col(RateId.col().uuid().not_null())
|
||||||
|
.col(ts_def_now_not_null!(CreatedAt))
|
||||||
|
.col(ts_def_now_not_null!(UpdatedAt))
|
||||||
|
.col(Metadata.col().json_binary())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
m.create_2_col_primary(ProductTaxRates, ProductId, RateId)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -467,6 +482,19 @@ impl Migration {
|
|||||||
async fn create_product_types(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
async fn create_product_types(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
use ProductType::*;
|
use ProductType::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProductTypes)
|
||||||
|
.col(auto_uuid_not_null!(Id))
|
||||||
|
.col(Value.col().string().not_null())
|
||||||
|
.col(ts_def_now_not_null!(CreatedAt))
|
||||||
|
.col(ts_def_now_not_null!(UpdatedAt))
|
||||||
|
.col(DeletedAt.col().timestamp())
|
||||||
|
.col(Metadata.col().json_binary())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -482,6 +510,21 @@ impl Migration {
|
|||||||
async fn create_product_type_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
async fn create_product_type_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
use ProductTypeTaxRate::*;
|
use ProductTypeTaxRate::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProductTypeTaxRates)
|
||||||
|
.col(ProductTypeId.col().uuid().not_null())
|
||||||
|
.col(RateId.col().uuid().not_null())
|
||||||
|
.col(ts_def_now_not_null!(CreatedAt))
|
||||||
|
.col(ts_def_now_not_null!(UpdatedAt))
|
||||||
|
.col(Metadata.col().json_binary())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
m.create_2_col_primary(ProductTypeTaxRates, ProductTypeId, RateId)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -515,6 +558,36 @@ impl Migration {
|
|||||||
async fn create_product_variants(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
async fn create_product_variants(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
use ProductVariant::*;
|
use ProductVariant::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProductVariants)
|
||||||
|
.col(auto_uuid_not_null!(Id))
|
||||||
|
.col(Title.col().string().not_null())
|
||||||
|
.col(ProductId.col().uuid().not_null())
|
||||||
|
.col(Sku.col().string())
|
||||||
|
.col(Barcode.col().string())
|
||||||
|
.col(Ean.col().string())
|
||||||
|
.col(Upc.col().string())
|
||||||
|
.col(InventoryQuantity.col().integer().not_null())
|
||||||
|
.col(AllowBackorder.col().boolean().default(false).not_null())
|
||||||
|
.col(ManageInventory.col().boolean().default(true).not_null())
|
||||||
|
.col(HsCode.col().string())
|
||||||
|
.col(OriginCountry.col().string())
|
||||||
|
.col(MidCode.col().string())
|
||||||
|
.col(Material.col().string())
|
||||||
|
.col(Weight.col().integer())
|
||||||
|
.col(Length.col().integer())
|
||||||
|
.col(Height.col().integer())
|
||||||
|
.col(Width.col().integer())
|
||||||
|
.col(ts_def_now_not_null!(CreatedAt))
|
||||||
|
.col(ts_def_now_not_null!(UpdatedAt))
|
||||||
|
.col(DeletedAt.col().timestamp())
|
||||||
|
.col(Metadata.col().json_binary())
|
||||||
|
.col(VariantRank.col().integer().default(0))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -535,6 +608,20 @@ impl Migration {
|
|||||||
) -> Result<(), DbErr> {
|
) -> Result<(), DbErr> {
|
||||||
use ProductVariantInventoryItem::*;
|
use ProductVariantInventoryItem::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProductVariantInventoryItems)
|
||||||
|
.col(auto_uuid_not_null!(Id))
|
||||||
|
.col(ts_def_now_not_null!(CreatedAt))
|
||||||
|
.col(ts_def_now_not_null!(UpdatedAt))
|
||||||
|
.col(InventoryItemId.col().uuid().not_null())
|
||||||
|
.col(VariantId.col().uuid().not_null())
|
||||||
|
.col(RequiredQuantity.col().integer().default(1).not_null())
|
||||||
|
.col(DeletedAt.col().timestamp())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -556,6 +643,24 @@ impl Migration {
|
|||||||
async fn create_money_amounts(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
async fn create_money_amounts(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
use MoneyAmount::*;
|
use MoneyAmount::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(MoneyAmounts)
|
||||||
|
.col(auto_uuid_not_null!(Id))
|
||||||
|
.col(CurrencyCode.col().string().not_null())
|
||||||
|
.col(Amount.col().integer().not_null())
|
||||||
|
.col(VariantId.col().uuid())
|
||||||
|
.col(RegionId.col().uuid())
|
||||||
|
.col(ts_def_now_not_null!(CreatedAt))
|
||||||
|
.col(ts_def_now_not_null!(UpdatedAt))
|
||||||
|
.col(DeletedAt.col().timestamp())
|
||||||
|
.col(MinQuantity.col().integer())
|
||||||
|
.col(MaxQuantity.col().integer())
|
||||||
|
.col(PriceListId.col().uuid())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user