discounts

This commit is contained in:
Priec
2026-06-21 22:33:47 +02:00
parent 2ee87fbdd7
commit 9ce1cb97f0
20 changed files with 399 additions and 10 deletions

View File

@@ -35,6 +35,7 @@ mod m20260618_000002_customer_profiles;
mod m20260618_000003_account_type;
mod m20260618_000004_account_ownership;
mod m20260620_000001_add_totp_to_users;
mod m20260621_000001_add_sale_price_to_products;
pub struct Migrator;
#[async_trait::async_trait]
@@ -74,6 +75,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260618_000003_account_type::Migration),
Box::new(m20260618_000004_account_ownership::Migration),
Box::new(m20260620_000001_add_totp_to_users::Migration),
Box::new(m20260621_000001_add_sale_price_to_products::Migration),
// inject-above (do not remove this comment)
]
}

View File

@@ -0,0 +1,19 @@
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> {
// Optional discounted price in minor units. When set (and below
// `price_cents`) the product is on sale; the regular price is shown
// struck through and this is the effective price everywhere.
add_column(m, "products", "sale_price_cents", ColType::BigIntegerNull).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
remove_column(m, "products", "sale_price_cents").await
}
}