Finish checkouts, start gift carts
This commit is contained in:
parent
39a34bd53b
commit
a6486b4983
@ -11,6 +11,8 @@ pub struct Migration;
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigrationTrait for Migration {
|
impl MigrationTrait for Migration {
|
||||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
Self::create_types(m).await?;
|
||||||
|
|
||||||
Self::create_orders(m).await?;
|
Self::create_orders(m).await?;
|
||||||
Self::create_order_discounts(m).await?;
|
Self::create_order_discounts(m).await?;
|
||||||
Self::create_order_edits(m).await?;
|
Self::create_order_edits(m).await?;
|
||||||
@ -42,26 +44,26 @@ impl MigrationTrait for Migration {
|
|||||||
self.drop_table(m, OrderDiscount::OrderDiscounts).await?;
|
self.drop_table(m, OrderDiscount::OrderDiscounts).await?;
|
||||||
self.drop_table(m, Order::Orders).await?;
|
self.drop_table(m, Order::Orders).await?;
|
||||||
|
|
||||||
drop_type!(m, crate::types::OrderStatus);
|
drop_type!(m, OrderStatus);
|
||||||
drop_type!(m, crate::types::OrderPaymentStatus);
|
drop_type!(m, OrderPaymentStatus);
|
||||||
drop_type!(m, crate::types::OrderItemChangeType);
|
drop_type!(m, OrderItemChangeType);
|
||||||
drop_type!(m, crate::types::PaymentSessionStatus);
|
drop_type!(m, PaymentSessionStatus);
|
||||||
drop_type!(m, crate::types::PaymentCollectionType);
|
drop_type!(m, PaymentCollectionType);
|
||||||
drop_type!(m, crate::types::OrderFulfillmentStatus);
|
drop_type!(m, OrderFulfillmentStatus);
|
||||||
drop_type!(m, crate::types::PaymentCollectionStatus);
|
drop_type!(m, PaymentCollectionStatus);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Migration {
|
impl Migration {
|
||||||
async fn create_types(m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
async fn create_types(m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
create_type!(m, crate::types::OrderStatus);
|
create_type!(m, OrderStatus);
|
||||||
create_type!(m, crate::types::OrderPaymentStatus);
|
create_type!(m, OrderPaymentStatus);
|
||||||
create_type!(m, crate::types::OrderItemChangeType);
|
create_type!(m, OrderItemChangeType);
|
||||||
create_type!(m, crate::types::PaymentSessionStatus);
|
create_type!(m, PaymentSessionStatus);
|
||||||
create_type!(m, crate::types::PaymentCollectionType);
|
create_type!(m, PaymentCollectionType);
|
||||||
create_type!(m, crate::types::OrderFulfillmentStatus);
|
create_type!(m, OrderFulfillmentStatus);
|
||||||
create_type!(m, crate::types::PaymentCollectionStatus);
|
create_type!(m, PaymentCollectionStatus);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ```sql
|
/// ```sql
|
||||||
@ -102,7 +104,7 @@ impl Migration {
|
|||||||
crate::types::OrderStatus::OrderStatuses,
|
crate::types::OrderStatus::OrderStatuses,
|
||||||
crate::types::OrderStatus::iter().skip(1),
|
crate::types::OrderStatus::iter().skip(1),
|
||||||
)
|
)
|
||||||
.default(crate::types::OrderStatus::Pending)
|
.default(crate::types::OrderStatus::Pending.to_string())
|
||||||
.not_null(),
|
.not_null(),
|
||||||
)
|
)
|
||||||
.col(
|
.col(
|
||||||
@ -514,7 +516,7 @@ impl Migration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum Order {
|
pub enum Order {
|
||||||
Orders,
|
Orders,
|
||||||
Id,
|
Id,
|
||||||
@ -541,14 +543,14 @@ pub enum Order {
|
|||||||
SalesChannelId,
|
SalesChannelId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum OrderDiscount {
|
pub enum OrderDiscount {
|
||||||
OrderDiscounts,
|
OrderDiscounts,
|
||||||
OrderId,
|
OrderId,
|
||||||
DiscountId,
|
DiscountId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum OrderEdit {
|
pub enum OrderEdit {
|
||||||
OrderEdits,
|
OrderEdits,
|
||||||
Id,
|
Id,
|
||||||
@ -569,14 +571,14 @@ pub enum OrderEdit {
|
|||||||
PaymentCollectionId,
|
PaymentCollectionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum OrderGiftCard {
|
pub enum OrderGiftCard {
|
||||||
OrderGiftCards,
|
OrderGiftCards,
|
||||||
OrderId,
|
OrderId,
|
||||||
GiftCardId,
|
GiftCardId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum OrderItemChange {
|
pub enum OrderItemChange {
|
||||||
OrderItemChanges,
|
OrderItemChanges,
|
||||||
Id,
|
Id,
|
||||||
@ -589,7 +591,7 @@ pub enum OrderItemChange {
|
|||||||
LineItemId,
|
LineItemId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum Payment {
|
pub enum Payment {
|
||||||
Payments,
|
Payments,
|
||||||
Id,
|
Id,
|
||||||
@ -609,7 +611,7 @@ pub enum Payment {
|
|||||||
IdempotencyKey,
|
IdempotencyKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum PaymentCollection {
|
pub enum PaymentCollection {
|
||||||
PaymentCollections,
|
PaymentCollections,
|
||||||
Id,
|
Id,
|
||||||
@ -627,28 +629,28 @@ pub enum PaymentCollection {
|
|||||||
CreatedBy,
|
CreatedBy,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum PaymentCollectionPayment {
|
pub enum PaymentCollectionPayment {
|
||||||
PaymentCollectionPayments,
|
PaymentCollectionPayments,
|
||||||
PaymentCollectionId,
|
PaymentCollectionId,
|
||||||
PaymentId,
|
PaymentId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum PaymentCollectionSession {
|
pub enum PaymentCollectionSession {
|
||||||
PaymentCollectionSessions,
|
PaymentCollectionSessions,
|
||||||
PaymentCollectionId,
|
PaymentCollectionId,
|
||||||
PaymentSessionId,
|
PaymentSessionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum PaymentProvider {
|
pub enum PaymentProvider {
|
||||||
PaymentProviders,
|
PaymentProviders,
|
||||||
Id,
|
Id,
|
||||||
IsInstalled,
|
IsInstalled,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Inde)]
|
#[derive(Iden)]
|
||||||
pub enum PaymentSession {
|
pub enum PaymentSession {
|
||||||
PaymentSessions,
|
PaymentSessions,
|
||||||
Id,
|
Id,
|
||||||
|
20
migration/src/discounts/m20230603_120815_gift_carts.rs
Normal file
20
migration/src/discounts/m20230603_120815_gift_carts.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
use crate::sea_orm::Iterable;
|
||||||
|
use crate::{auto_uuid_not_null, create_type, drop_type, ts_def_now_not_null, DropTable};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Migration {}
|
@ -1,4 +1,5 @@
|
|||||||
mod m20230603_120814_discounts;
|
mod m20230603_120814_discounts;
|
||||||
|
mod m20230603_120815_gift_carts;
|
||||||
|
|
||||||
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
||||||
|
|
||||||
@ -7,6 +8,9 @@ pub struct DiscountsMigrator;
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigratorTrait for DiscountsMigrator {
|
impl MigratorTrait for DiscountsMigrator {
|
||||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
vec![Box::new(m20230603_120814_discounts::Migration)]
|
vec![
|
||||||
|
Box::new(m20230603_120814_discounts::Migration),
|
||||||
|
Box::new(m20230603_120815_gift_carts::Migration),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,10 @@ pub trait DropTable {
|
|||||||
impl<T: MigrationTrait> DropTable for T {}
|
impl<T: MigrationTrait> DropTable for T {}
|
||||||
|
|
||||||
pub trait IntoColumnDef: IntoIden {
|
pub trait IntoColumnDef: IntoIden {
|
||||||
fn col(self) -> ColumnDef {
|
fn col(self) -> ColumnDef
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
ColumnDef::new(self)
|
ColumnDef::new(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,16 +484,6 @@ CREATE TABLE public.discount_rule_products
|
|||||||
product_id uuid NOT NULL
|
product_id uuid NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE public.orders
|
CREATE TABLE public.orders
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -634,10 +624,65 @@ CREATE TABLE public.payment_sessions
|
|||||||
is_initiated boolean DEFAULT false NOT NULL
|
is_initiated boolean DEFAULT false NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
---------
|
---- ###########################################################
|
||||||
---------
|
---- ###########################################################
|
||||||
---------
|
---- ###########################################################
|
||||||
---------
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
|
||||||
|
CREATE TABLE public.gift_cards
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
code character varying NOT NULL,
|
||||||
|
value integer NOT NULL,
|
||||||
|
balance integer NOT NULL,
|
||||||
|
region_id uuid NOT NULL,
|
||||||
|
order_id uuid,
|
||||||
|
is_disabled boolean DEFAULT false NOT NULL,
|
||||||
|
ends_at timestamp with time zone,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
tax_rate real
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.gift_card_transactions
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
gift_card_id uuid NOT NULL,
|
||||||
|
order_id uuid NOT NULL,
|
||||||
|
amount integer NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
is_taxable boolean,
|
||||||
|
tax_rate real
|
||||||
|
);
|
||||||
|
|
||||||
|
---------------------------
|
||||||
|
---------------------------
|
||||||
|
---------------------------
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
CREATE TABLE public.idempotency_keys
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
idempotency_key character varying NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
locked_at timestamp with time zone,
|
||||||
|
request_method character varying,
|
||||||
|
request_params jsonb,
|
||||||
|
request_path character varying,
|
||||||
|
response_code integer,
|
||||||
|
response_body jsonb,
|
||||||
|
recovery_point character varying DEFAULT 'started'::character varying NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
---------------------------
|
||||||
|
---------------------------
|
||||||
|
---------------------------
|
||||||
|
|
||||||
CREATE TABLE public.customers
|
CREATE TABLE public.customers
|
||||||
(
|
(
|
||||||
@ -731,48 +776,6 @@ CREATE TABLE public.fulfillment_providers
|
|||||||
is_installed boolean DEFAULT true NOT NULL
|
is_installed boolean DEFAULT true NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE public.gift_cards
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
code character varying NOT NULL,
|
|
||||||
value integer NOT NULL,
|
|
||||||
balance integer NOT NULL,
|
|
||||||
region_id uuid NOT NULL,
|
|
||||||
order_id uuid,
|
|
||||||
is_disabled boolean DEFAULT false NOT NULL,
|
|
||||||
ends_at timestamp with time zone,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
tax_rate real
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE public.gift_card_transactions
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
gift_card_id uuid NOT NULL,
|
|
||||||
order_id uuid NOT NULL,
|
|
||||||
amount integer NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
is_taxable boolean,
|
|
||||||
tax_rate real
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE public.idempotency_keys
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
idempotency_key character varying NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
locked_at timestamp with time zone,
|
|
||||||
request_method character varying,
|
|
||||||
request_params jsonb,
|
|
||||||
request_path character varying,
|
|
||||||
response_code integer,
|
|
||||||
response_body jsonb,
|
|
||||||
recovery_point character varying DEFAULT 'started'::character varying NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE public.images
|
CREATE TABLE public.images
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -851,13 +854,6 @@ CREATE TABLE public.line_item_tax_lines
|
|||||||
item_id uuid NOT NULL
|
item_id uuid NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE public.migrations
|
|
||||||
(
|
|
||||||
id sequence NOT NULL,
|
|
||||||
"timestamp" bigint NOT NULL,
|
|
||||||
name character varying NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE public.money_amounts
|
CREATE TABLE public.money_amounts
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user