more webshop
This commit is contained in:
@@ -24,6 +24,8 @@ mod m20260616_130610_orders;
|
||||
mod m20260616_130628_order_items;
|
||||
mod m20260616_131000_drop_audio_tables;
|
||||
mod m20260616_132000_drop_blog_and_pages;
|
||||
mod m20260616_150755_shipping_methods;
|
||||
mod m20260616_150812_add_shipping_fields_to_orders;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -52,6 +54,8 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260616_130628_order_items::Migration),
|
||||
Box::new(m20260616_131000_drop_audio_tables::Migration),
|
||||
Box::new(m20260616_132000_drop_blog_and_pages::Migration),
|
||||
Box::new(m20260616_150755_shipping_methods::Migration),
|
||||
Box::new(m20260616_150812_add_shipping_fields_to_orders::Migration),
|
||||
// inject-above (do not remove this comment)
|
||||
]
|
||||
}
|
||||
|
||||
30
migration/src/m20260616_150755_shipping_methods.rs
Normal file
30
migration/src/m20260616_150755_shipping_methods.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
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> {
|
||||
create_table(m, "shipping_methods",
|
||||
&[
|
||||
|
||||
("id", ColType::PkAuto),
|
||||
|
||||
("code", ColType::StringUniq),
|
||||
("name", ColType::String),
|
||||
("price_cents", ColType::BigIntegerWithDefault(0)),
|
||||
("requires_pickup_point", ColType::BooleanWithDefault(false)),
|
||||
("enabled", ColType::BooleanWithDefault(true)),
|
||||
("position", ColType::IntegerWithDefault(0)),
|
||||
],
|
||||
&[
|
||||
]
|
||||
).await
|
||||
}
|
||||
|
||||
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
drop_table(m, "shipping_methods").await
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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> {
|
||||
add_column(m, "orders", "payment_method", ColType::StringNull).await?;
|
||||
add_column(m, "orders", "carrier_code", ColType::StringNull).await?;
|
||||
add_column(m, "orders", "carrier_name", ColType::StringNull).await?;
|
||||
add_column(m, "orders", "shipping_cents", ColType::BigIntegerWithDefault(0)).await?;
|
||||
add_column(m, "orders", "pickup_point_id", ColType::StringNull).await?;
|
||||
add_column(m, "orders", "pickup_point_name", ColType::StringNull).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
remove_column(m, "orders", "payment_method").await?;
|
||||
remove_column(m, "orders", "carrier_code").await?;
|
||||
remove_column(m, "orders", "carrier_name").await?;
|
||||
remove_column(m, "orders", "shipping_cents").await?;
|
||||
remove_column(m, "orders", "pickup_point_id").await?;
|
||||
remove_column(m, "orders", "pickup_point_name").await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user