Finish products
This commit is contained in:
parent
4fd3615343
commit
5111c6efb2
@ -51,7 +51,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(
|
||||
m.create_2_col_primary(
|
||||
CartDiscount::CartDiscounts,
|
||||
CartDiscount::CartId,
|
||||
CartDiscount::DiscountId,
|
||||
@ -79,7 +79,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(
|
||||
m.create_2_col_primary(
|
||||
CartGiftCard::CartGiftCards,
|
||||
CartGiftCard::CartId,
|
||||
CartGiftCard::GiftCardId,
|
||||
|
@ -194,7 +194,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(
|
||||
m.create_2_col_primary(
|
||||
OrderDiscount::OrderDiscounts,
|
||||
OrderDiscount::OrderId,
|
||||
OrderDiscount::DiscountId,
|
||||
@ -270,7 +270,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(
|
||||
m.create_2_col_primary(
|
||||
OrderGiftCard::OrderGiftCards,
|
||||
OrderGiftCard::OrderId,
|
||||
OrderGiftCard::GiftCardId,
|
||||
@ -454,7 +454,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(
|
||||
m.create_2_col_primary(
|
||||
PaymentCollectionPayment::PaymentCollectionPayments,
|
||||
PaymentCollectionPayment::PaymentCollectionId,
|
||||
PaymentCollectionPayment::PaymentId,
|
||||
@ -508,7 +508,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(
|
||||
m.create_2_col_primary(
|
||||
PaymentCollectionSession::PaymentCollectionSessions,
|
||||
PaymentCollectionSession::PaymentCollectionId,
|
||||
PaymentCollectionSession::PaymentSessionId,
|
||||
|
@ -55,7 +55,12 @@ impl<T: IntoIden> IntoColumnDef for T {}
|
||||
|
||||
#[async_trait]
|
||||
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
|
||||
T: IntoIden + Copy + 'static + Sync + Send,
|
||||
C1: IntoIden + Copy + 'static + Sync + Send,
|
||||
@ -64,7 +69,12 @@ pub trait CreateIndexExt {
|
||||
|
||||
#[async_trait]
|
||||
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
|
||||
T: IntoIden + Copy + 'static + Sync + Send,
|
||||
C1: IntoIden + Copy + 'static + Sync + Send,
|
||||
@ -120,7 +130,7 @@ impl CreateBridgeTable for SchemaManager<'_> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
self.create_2col_idx(table, col1, col2).await?;
|
||||
self.create_2_col_primary(table, col1, col2).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ impl Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_2col_idx(ShippingTaxRates, ShippingOptionId, RateId)
|
||||
m.create_2_col_primary(ShippingTaxRates, ShippingOptionId, RateId)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
@ -451,6 +451,21 @@ impl Migration {
|
||||
async fn create_product_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
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(())
|
||||
}
|
||||
/// ```sql
|
||||
@ -467,6 +482,19 @@ impl Migration {
|
||||
async fn create_product_types(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
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(())
|
||||
}
|
||||
/// ```sql
|
||||
@ -482,6 +510,21 @@ impl Migration {
|
||||
async fn create_product_type_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
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(())
|
||||
}
|
||||
/// ```sql
|
||||
@ -515,6 +558,36 @@ impl Migration {
|
||||
async fn create_product_variants(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
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(())
|
||||
}
|
||||
/// ```sql
|
||||
@ -535,6 +608,20 @@ impl Migration {
|
||||
) -> Result<(), DbErr> {
|
||||
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(())
|
||||
}
|
||||
/// ```sql
|
||||
@ -556,6 +643,24 @@ impl Migration {
|
||||
async fn create_money_amounts(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user