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, InviteRole);
create_type!(manager, OrderFulfillmentStatus); create_type!(manager, OrderFulfillmentStatus);
create_type!(manager, OrderItemChangeType); 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(()) Ok(())
} }
@ -70,6 +83,19 @@ impl MigrationTrait for Migration {
drop_type!(manager, InviteRole); drop_type!(manager, InviteRole);
drop_type!(manager, OrderFulfillmentStatus); drop_type!(manager, OrderFulfillmentStatus);
drop_type!(manager, OrderItemChangeType); 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(()) Ok(())
} }
} }

View File

@ -191,3 +191,191 @@ pub enum OrderItemChangeType {
#[iden = "item_update"] #[iden = "item_update"]
ItemUpdate, 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', 'canceled',
'requires_action' 'requires_action'
); );
-------------------------------------------------
--
-- Name: order_item_change_types; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.order_item_change_types AS ENUM ( CREATE TYPE public.order_item_change_types AS ENUM (
'item_add', 'item_add',
@ -109,13 +104,6 @@ CREATE TYPE public.order_item_change_types AS ENUM (
'item_update' '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 ( CREATE TYPE public.order_payment_statuses AS ENUM (
'not_paid', 'not_paid',
'awaiting', 'awaiting',
@ -126,13 +114,6 @@ CREATE TYPE public.order_payment_statuses AS ENUM (
'requires_action' '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 ( CREATE TYPE public.order_statuses AS ENUM (
'pending', 'pending',
'completed', 'completed',
@ -141,13 +122,6 @@ CREATE TYPE public.order_statuses AS ENUM (
'requires_action' '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 ( CREATE TYPE public.payment_session_statuses AS ENUM (
'authorized', 'authorized',
'pending', 'pending',
@ -156,37 +130,15 @@ CREATE TYPE public.payment_session_statuses AS ENUM (
'canceled' '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 ( CREATE TYPE public.price_list_statuses AS ENUM (
'active', 'active',
'draft' '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 ( CREATE TYPE public.price_list_types AS ENUM (
'sale', 'sale',
'override' '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 ( CREATE TYPE public.product_statuses AS ENUM (
'draft', 'draft',
'proposed', 'proposed',
@ -194,13 +146,6 @@ CREATE TYPE public.product_statuses AS ENUM (
'rejected' '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 ( CREATE TYPE public.refund_reasons AS ENUM (
'discount', 'discount',
'return', 'return',
@ -209,13 +154,6 @@ CREATE TYPE public.refund_reasons AS ENUM (
'other' '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 ( CREATE TYPE public.return_statuses AS ENUM (
'requested', 'requested',
'received', 'received',
@ -223,50 +161,22 @@ CREATE TYPE public.return_statuses AS ENUM (
'canceled' '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 ( CREATE TYPE public.shipping_option_price_types AS ENUM (
'flat_rate', 'flat_rate',
'calculated' '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 ( CREATE TYPE public.shipping_option_requirement_types AS ENUM (
'min_subtotal', 'min_subtotal',
'max_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 ( CREATE TYPE public.shipping_profile_types AS ENUM (
'default', 'default',
'gift_card', 'gift_card',
'custom' '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 ( CREATE TYPE public.swap_fulfillment_statuses AS ENUM (
'not_fulfilled', 'not_fulfilled',
'fulfilled', 'fulfilled',
@ -276,13 +186,6 @@ CREATE TYPE public.swap_fulfillment_statuses AS ENUM (
'requires_action' '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 ( CREATE TYPE public.swap_payment_statuses AS ENUM (
'not_paid', 'not_paid',
'awaiting', 'awaiting',
@ -295,13 +198,6 @@ CREATE TYPE public.swap_payment_statuses AS ENUM (
'requires_action' '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 ( CREATE TYPE public.user_roles AS ENUM (
'admin', 'admin',
'member', '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 CREATE TABLE public.addresses
( (