Add types

This commit is contained in:
eraden 2023-06-03 14:07:38 +02:00
parent 11681acbda
commit 9c1b57b3c5
3 changed files with 223 additions and 108 deletions

View File

@ -51,6 +51,19 @@ impl MigrationTrait for Migration {
create_type!(manager, InviteRole);
create_type!(manager, OrderFulfillmentStatus);
create_type!(manager, OrderItemChangeType);
create_type!(manager, OrderPaymentStatus);
create_type!(manager, PaymentSessionStatus);
create_type!(manager, PriceListStatus);
create_type!(manager, PriceListType);
create_type!(manager, ProductStatus);
create_type!(manager, RefundReason);
create_type!(manager, ReturnStatus);
create_type!(manager, ShippingOptionPriceType);
create_type!(manager, ShippingOptionRequirementType);
create_type!(manager, ShippingProfileType);
create_type!(manager, SwapFulfillmentStatus);
create_type!(manager, SwapPaymentStatus);
create_type!(manager, UserRole);
Ok(())
}
@ -70,6 +83,19 @@ impl MigrationTrait for Migration {
drop_type!(manager, InviteRole);
drop_type!(manager, OrderFulfillmentStatus);
drop_type!(manager, OrderItemChangeType);
drop_type!(manager, OrderPaymentStatus);
drop_type!(manager, PaymentSessionStatus);
drop_type!(manager, PriceListStatus);
drop_type!(manager, PriceListType);
drop_type!(manager, ProductStatus);
drop_type!(manager, RefundReason);
drop_type!(manager, ReturnStatus);
drop_type!(manager, ShippingOptionPriceType);
drop_type!(manager, ShippingOptionRequirementType);
drop_type!(manager, ShippingProfileType);
drop_type!(manager, SwapFulfillmentStatus);
drop_type!(manager, SwapPaymentStatus);
drop_type!(manager, UserRole);
Ok(())
}
}

View File

@ -191,3 +191,191 @@ pub enum OrderItemChangeType {
#[iden = "item_update"]
ItemUpdate,
}
#[derive(Iden, EnumIter)]
pub enum OrderPaymentStatus {
OrderPaymentStatuses,
#[iden = "not_paid"]
NotPaid,
#[iden = "awaiting"]
Awaiting,
#[iden = "captured"]
Captured,
#[iden = "partially_refunded"]
PartiallyRefunded,
#[iden = "refunded"]
Refunded,
#[iden = "canceled"]
Canceled,
#[iden = "requires_action"]
RequiresAction,
}
#[derive(Iden, EnumIter)]
pub enum OrderStatus {
OrderStatuses,
#[iden = "pending"]
Pending,
#[iden = "completed"]
Completed,
#[iden = "archived"]
Archived,
#[iden = "canceled"]
Canceled,
#[iden = "requires_action"]
RequiresAction,
}
#[derive(Iden, EnumIter)]
pub enum PaymentSessionStatus {
PaymentSessionStatuses,
#[iden = "authorized"]
Authorized,
#[iden = "pending"]
Pending,
#[iden = "requires_more"]
RequiresMore,
#[iden = "error"]
Error,
#[iden = "canceled"]
Canceled,
}
#[derive(Iden, EnumIter)]
pub enum PriceListStatus {
PriceListStatuses,
#[iden = "active"]
Active,
#[iden = "draft"]
Draft,
}
#[derive(Iden, EnumIter)]
pub enum PriceListType {
PriceListTypes,
#[iden = "sale"]
Sale,
#[iden = "override"]
Override,
}
#[derive(Iden, EnumIter)]
pub enum ProductStatus {
ProductStatuses,
#[iden = "draft"]
Draft,
#[iden = "proposed"]
Proposed,
#[iden = "published"]
Published,
#[iden = "rejected"]
Rejected,
}
#[derive(Iden, EnumIter)]
pub enum RefundReason {
RefundReasons,
#[iden = "discount"]
Discount,
#[iden = "return"]
Return,
#[iden = "swap"]
Swap,
#[iden = "claim"]
Claim,
#[iden = "other"]
Other,
}
#[derive(Iden, EnumIter)]
pub enum ReturnStatus {
ReturnStatuses,
#[iden = "requested"]
Requested,
#[iden = "received"]
Received,
#[iden = "requires_action"]
RequiresAction,
#[iden = "canceled"]
Canceled,
}
#[derive(Iden, EnumIter)]
pub enum ShippingOptionPriceType {
ShippingOptionPriceTypes,
#[iden = "flat_rate"]
FlatRate,
#[iden = "calculated"]
Calculated,
}
#[derive(Iden, EnumIter)]
pub enum ShippingOptionRequirementType {
ShippingOptionRequirementTypes,
#[iden = "min_subtotal"]
MinSubtotal,
#[iden = "max_subtotal"]
MaxSubtotal,
}
#[derive(Iden, EnumIter)]
pub enum ShippingProfileType {
ShippingProfileTypes,
#[iden = "default"]
Default,
#[iden = "gift_card"]
GiftCard,
#[iden = "custom"]
Custom,
}
#[derive(Iden, EnumIter)]
pub enum SwapFulfillmentStatus {
SwapFulfillmentStatuses,
#[iden = "not_fulfilled"]
NotFulfilled,
#[iden = "fulfilled"]
Fulfilled,
#[iden = "shipped"]
Shipped,
#[iden = "partially_shipped"]
PartiallyShipped,
#[iden = "canceled"]
Canceled,
#[iden = "requires_action"]
RequiresAction,
}
#[derive(Iden, EnumIter)]
pub enum SwapPaymentStatus {
SwapPaymentStatuses,
#[iden = "not_paid"]
NotPaid,
#[iden = "awaiting"]
Awaiting,
#[iden = "captured"]
Captured,
#[iden = "confirmed"]
Confirmed,
#[iden = "canceled"]
Canceled,
#[iden = "difference_refunded"]
DifferenceRefunded,
#[iden = "partially_refunded"]
PartiallyRefunded,
#[iden = "refunded"]
Refunded,
#[iden = "requires_action"]
RequiresAction,
}
#[derive(Iden, EnumIter)]
pub enum UserRole {
UserRoles,
#[iden = "admin"]
Admin,
#[iden = "member"]
Member,
#[iden = "developer"]
Developer,
}

View File

@ -97,11 +97,6 @@ CREATE TYPE public.order_fulfillment_statuses AS ENUM (
'canceled',
'requires_action'
);
-------------------------------------------------
--
-- Name: order_item_change_types; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.order_item_change_types AS ENUM (
'item_add',
@ -109,13 +104,6 @@ CREATE TYPE public.order_item_change_types AS ENUM (
'item_update'
);
ALTER TYPE public.order_item_change_types OWNER TO postgres;
--
-- Name: order_payment_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.order_payment_statuses AS ENUM (
'not_paid',
'awaiting',
@ -126,13 +114,6 @@ CREATE TYPE public.order_payment_statuses AS ENUM (
'requires_action'
);
ALTER TYPE public.order_payment_statuses OWNER TO postgres;
--
-- Name: order_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.order_statuses AS ENUM (
'pending',
'completed',
@ -141,13 +122,6 @@ CREATE TYPE public.order_statuses AS ENUM (
'requires_action'
);
ALTER TYPE public.order_statuses OWNER TO postgres;
--
-- Name: payment_session_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.payment_session_statuses AS ENUM (
'authorized',
'pending',
@ -156,37 +130,15 @@ CREATE TYPE public.payment_session_statuses AS ENUM (
'canceled'
);
ALTER TYPE public.payment_session_statuses OWNER TO postgres;
--
-- Name: price_list_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.price_list_statuses AS ENUM (
'active',
'draft'
);
ALTER TYPE public.price_list_statuses OWNER TO postgres;
--
-- Name: price_list_types; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.price_list_types AS ENUM (
'sale',
'override'
);
ALTER TYPE public.price_list_types OWNER TO postgres;
--
-- Name: product_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.product_statuses AS ENUM (
'draft',
'proposed',
@ -194,13 +146,6 @@ CREATE TYPE public.product_statuses AS ENUM (
'rejected'
);
ALTER TYPE public.product_statuses OWNER TO postgres;
--
-- Name: refund_reason_enum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.refund_reasons AS ENUM (
'discount',
'return',
@ -209,13 +154,6 @@ CREATE TYPE public.refund_reasons AS ENUM (
'other'
);
ALTER TYPE public.refund_reasons OWNER TO postgres;
--
-- Name: return_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.return_statuses AS ENUM (
'requested',
'received',
@ -223,50 +161,22 @@ CREATE TYPE public.return_statuses AS ENUM (
'canceled'
);
ALTER TYPE public.return_statuses OWNER TO postgres;
--
-- Name: shipping_option_price_types; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.shipping_option_price_types AS ENUM (
'flat_rate',
'calculated'
);
ALTER TYPE public.shipping_option_price_types OWNER TO postgres;
--
-- Name: shipping_option_requirement_types; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.shipping_option_requirement_types AS ENUM (
'min_subtotal',
'max_subtotal'
);
ALTER TYPE public.shipping_option_requirement_types OWNER TO postgres;
--
-- Name: shipping_profile_types; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.shipping_profile_types AS ENUM (
'default',
'gift_card',
'custom'
);
ALTER TYPE public.shipping_profile_types OWNER TO postgres;
--
-- Name: swap_fulfillment_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.swap_fulfillment_statuses AS ENUM (
'not_fulfilled',
'fulfilled',
@ -276,13 +186,6 @@ CREATE TYPE public.swap_fulfillment_statuses AS ENUM (
'requires_action'
);
ALTER TYPE public.swap_fulfillment_statuses OWNER TO postgres;
--
-- Name: swap_payment_statuses; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.swap_payment_statuses AS ENUM (
'not_paid',
'awaiting',
@ -295,13 +198,6 @@ CREATE TYPE public.swap_payment_statuses AS ENUM (
'requires_action'
);
ALTER TYPE public.swap_payment_statuses OWNER TO postgres;
--
-- Name: user_roles; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.user_roles AS ENUM (
'admin',
'member',
@ -309,11 +205,16 @@ CREATE TYPE public.user_roles AS ENUM (
);
ALTER TYPE public.user_roles OWNER TO postgres;
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
--
-- Name: address; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.addresses
(