account type is permanent and password registration is now working at checkout
This commit is contained in:
@@ -33,6 +33,7 @@ mod m20260617_000003_add_phone_to_orders;
|
||||
mod m20260618_000001_o_auth2_sessions;
|
||||
mod m20260618_000002_customer_profiles;
|
||||
mod m20260618_000003_account_type;
|
||||
mod m20260618_000004_account_ownership;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -70,6 +71,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260618_000001_o_auth2_sessions::Migration),
|
||||
Box::new(m20260618_000002_customer_profiles::Migration),
|
||||
Box::new(m20260618_000003_account_type::Migration),
|
||||
Box::new(m20260618_000004_account_ownership::Migration),
|
||||
// inject-above (do not remove this comment)
|
||||
]
|
||||
}
|
||||
|
||||
38
migration/src/m20260618_000004_account_ownership.rs
Normal file
38
migration/src/m20260618_000004_account_ownership.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use loco_rs::schema::*;
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
// Account type becomes a permanent property of the *user* (chosen at
|
||||
// registration, never switchable), so it moves off `customer_profiles`. Orders
|
||||
// gain a nullable `user_id` linking them to the account that placed them
|
||||
// (null for guest orders that didn't create an account).
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
add_column(
|
||||
m,
|
||||
"users",
|
||||
"account_type",
|
||||
ColType::StringWithDefault("personal".to_string()),
|
||||
)
|
||||
.await?;
|
||||
add_column(m, "orders", "user_id", ColType::IntegerNull).await?;
|
||||
remove_column(m, "customer_profiles", "account_type").await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
add_column(
|
||||
m,
|
||||
"customer_profiles",
|
||||
"account_type",
|
||||
ColType::StringWithDefault("personal".to_string()),
|
||||
)
|
||||
.await?;
|
||||
remove_column(m, "orders", "user_id").await?;
|
||||
remove_column(m, "users", "account_type").await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user