global discount price
This commit is contained in:
@@ -39,6 +39,7 @@ mod m20260621_000001_add_sale_price_to_products;
|
||||
mod m20260621_000002_account_product_prices;
|
||||
mod m20260621_000003_discount_profiles;
|
||||
mod m20260621_000004_add_business_sale_price_to_products;
|
||||
mod m20260622_000001_audience_discount_profiles;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -82,6 +83,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260621_000002_account_product_prices::Migration),
|
||||
Box::new(m20260621_000003_discount_profiles::Migration),
|
||||
Box::new(m20260621_000004_add_business_sale_price_to_products::Migration),
|
||||
Box::new(m20260622_000001_audience_discount_profiles::Migration),
|
||||
// inject-above (do not remove this comment)
|
||||
]
|
||||
}
|
||||
|
||||
40
migration/src/m20260622_000001_audience_discount_profiles.rs
Normal file
40
migration/src/m20260622_000001_audience_discount_profiles.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use loco_rs::schema::*;
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
// Discount profiles applied globally to a whole audience, set on the
|
||||
// discounts page: "personal" lowers the public price for everyone,
|
||||
// "business" lowers the price for all company accounts. Per-company
|
||||
// assignments (account_discount_profiles) still layer on top.
|
||||
create_table(
|
||||
m,
|
||||
"audience_discount_profiles",
|
||||
&[
|
||||
("id", ColType::PkAuto),
|
||||
("audience", ColType::String),
|
||||
],
|
||||
&[("discount_profile", "")],
|
||||
)
|
||||
.await?;
|
||||
|
||||
m.create_index(
|
||||
Index::create()
|
||||
.name("idx_audience_discount_profiles_unique")
|
||||
.table(Alias::new("audience_discount_profiles"))
|
||||
.col(Alias::new("audience"))
|
||||
.col(Alias::new("discount_profile_id"))
|
||||
.unique()
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
drop_table(m, "audience_discount_profiles").await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user