Add more shipping, extract products

This commit is contained in:
Adrian Woźniak 2023-06-09 17:30:58 +02:00
parent 1abefd40f7
commit 1ac4327a0a
11 changed files with 934 additions and 414 deletions

View File

@ -0,0 +1,77 @@
use sea_orm_migration::prelude::*;
use crate::sea_orm::Iterable;
use crate::{
auto_uuid_not_null, create_type, drop_type, to_fk_name, to_pk2_name, ts_def_now_not_null,
DropTable, IntoColumnDef,
};
#[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 {
/// CREATE TABLE line_items
/// (
/// id uuid NOT NULL,
/// cart_id uuid,
/// order_id uuid,
/// swap_id uuid,
/// title character varying NOT NULL,
/// description character varying,
/// thumbnail character varying,
/// is_giftcard boolean DEFAULT false NOT NULL,
/// should_merge boolean DEFAULT true NOT NULL,
/// allow_discounts boolean DEFAULT true NOT NULL,
/// has_shipping boolean,
/// unit_price integer NOT NULL,
/// variant_id uuid,
/// quantity integer NOT NULL,
/// fulfilled_quantity integer,
/// returned_quantity integer,
/// shipped_quantity integer,
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
/// metadata jsonb,
/// claim_order_id uuid,
/// is_return boolean DEFAULT false NOT NULL,
/// original_item_id uuid,
/// order_edit_id uuid,
/// CONSTRAINT "CHK_0cd85e15610d11b553d5e8fda6" CHECK ((shipped_quantity <= fulfilled_quantity)),
/// CONSTRAINT "CHK_64eef00a5064887634f1680866" CHECK ((quantity > 0)),
/// CONSTRAINT "CHK_91f40396d847f6ecfd9f752bf8" CHECK ((returned_quantity <= quantity)),
/// CONSTRAINT "CHK_c61716c68f5ad5de2834c827d3" CHECK ((fulfilled_quantity <= quantity))
/// );
///
/// CREATE TABLE line_item_adjustments
/// (
/// id uuid NOT NULL,
/// item_id uuid NOT NULL,
/// description character varying NOT NULL,
/// discount_id uuid,
/// amount numeric NOT NULL,
/// metadata jsonb
/// );
///
/// CREATE TABLE line_item_tax_lines
/// (
/// id uuid NOT NULL,
/// rate real NOT NULL,
/// name character varying NOT NULL,
/// code character varying,
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
/// metadata jsonb,
/// item_id uuid NOT NULL
/// );
}

View File

@ -1,4 +1,5 @@
mod m20230603_120814_checkouts;
mod m20230603_120815_items;
use sea_orm_migration::{MigrationTrait, MigratorTrait};
@ -7,6 +8,9 @@ pub struct CheckoutsMigrator;
#[async_trait::async_trait]
impl MigratorTrait for CheckoutsMigrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![Box::new(m20230603_120814_checkouts::Migration)]
vec![
Box::new(m20230603_120814_checkouts::Migration),
Box::new(m20230603_120815_items::Migration),
]
}
}

View File

@ -1,7 +1,9 @@
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};
use crate::{
auto_uuid_not_null, create_type, drop_type, ts_def_now_not_null, DropTable, IntoColumnDef,
};
#[derive(DeriveMigrationName)]
pub struct Migration;
@ -9,6 +11,8 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
Self::create_gift_carts(m).await?;
Self::gift_card_transactions(m).await?;
Ok(())
}
@ -17,4 +21,110 @@ impl MigrationTrait for Migration {
}
}
impl Migration {}
impl Migration {
/// ```sql
/// CREATE TABLE 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
/// );
/// ```
async fn create_gift_carts(m: &SchemaManager<'_>) -> Result<(), DbErr> {
m.create_table(
Table::create()
.table(GiftCard::GiftCards)
.col(auto_uuid_not_null!(GiftCard::Id))
.col(GiftCard::Code.col().string().not_null())
.col(GiftCard::Value.col().integer().not_null())
.col(GiftCard::Balance.col().integer().not_null())
.col(GiftCard::RegionId.col().uuid().not_null())
.col(GiftCard::OrderId.col().uuid())
.col(
GiftCard::IsDisabled
.col()
.boolean()
.default(false)
.not_null(),
)
.col(GiftCard::EndsAt.col().timestamp())
.col(ts_def_now_not_null!(GiftCard::CreatedAt))
.col(ts_def_now_not_null!(GiftCard::UpdatedAt))
.col(GiftCard::DeletedAt.col().uuid())
.col(GiftCard::Metadata.col().json_binary())
.col(GiftCard::TaxRate.col().double())
.to_owned(),
)
.await?;
Ok(())
}
/// ```sql
/// CREATE TABLE 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
/// );
/// ```
async fn gift_card_transactions(m: &SchemaManager<'_>) -> Result<(), DbErr> {
m.create_table(
Table::create()
.table(GiftCardTransaction::GiftCardTransactions)
.col(auto_uuid_not_null!(GiftCardTransaction::Id))
.col(GiftCardTransaction::GiftCardId.col().uuid().not_null())
.col(GiftCardTransaction::OrderId.col().uuid().not_null())
.col(GiftCardTransaction::Amount.col().integer().not_null())
.col(ts_def_now_not_null!(GiftCardTransaction::CreatedAt))
.col(GiftCardTransaction::IsTaxable.col().boolean())
.col(GiftCardTransaction::TaxRate.col().double())
.to_owned(),
)
.await?;
Ok(())
}
}
#[derive(Iden)]
pub enum GiftCard {
GiftCards,
Id,
Code,
Value,
Balance,
RegionId,
OrderId,
IsDisabled,
EndsAt,
CreatedAt,
UpdatedAt,
DeletedAt,
Metadata,
TaxRate,
}
#[derive(Iden)]
pub enum GiftCardTransaction {
GiftCardTransactions,
Id,
GiftCardId,
OrderId,
Amount,
CreatedAt,
IsTaxable,
TaxRate,
}

View File

@ -12,7 +12,10 @@ pub mod schema_list;
pub use schema_list::*;
pub mod checkouts;
pub use checkouts::*;
pub mod shipping;
pub use shipping::*;
pub mod types;
pub use types::*;
#[macro_export]

View File

@ -38,6 +38,7 @@ async fn main() {
migrate_schema!(cli, Carts, CartsMigrator);
migrate_schema!(cli, Discounts, DiscountsMigrator);
migrate_schema!(cli, Checkouts, CheckoutsMigrator);
migrate_schema!(cli, Shipping, ShippingMigrator);
}
pub async fn run_cli<M>(cli: &mut Cli, schema: PostgreSQLSchema, migrator: M)

View File

@ -9,6 +9,7 @@ pub enum PostgreSQLSchema {
Carts,
Discounts,
Checkouts,
Shipping,
}
impl PostgreSQLSchema {
@ -19,6 +20,7 @@ impl PostgreSQLSchema {
PostgreSQLSchema::Carts => "carts",
PostgreSQLSchema::Discounts => "discounts",
PostgreSQLSchema::Checkouts => "checkouts",
PostgreSQLSchema::Shipping => "shipping",
}
}
}

View File

@ -0,0 +1,310 @@
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, IntoColumnDef,
};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
Self::create_tracking_links(m).await?;
Self::create_custom_shipping_options(m).await?;
Ok(())
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.drop_table(Table::drop().table(TrackingLink::TrackingLinks).to_owned())
.await?;
m.drop_table(
Table::drop()
.table(CustomShippingOption::CustomShippingOptions)
.to_owned(),
)
.await?;
Ok(())
}
}
impl Migration {
/// ```sql
/// CREATE TABLE tracking_links
/// (
/// id uuid NOT NULL,
/// url character varying,
/// tracking_number character varying NOT NULL,
/// fulfillment_id uuid NOT NULL,
/// 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,
/// idempotency_key character varying
/// );
/// ```
async fn create_tracking_links(m: &SchemaManager<'_>) -> Result<(), DbErr> {
m.create_table(
Table::create()
.table(TrackingLink::TrackingLinks)
.col(auto_uuid_not_null!(TrackingLink::Id))
.col(TrackingLink::Url.col().string())
.col(TrackingLink::TrackingNumber.col().string().not_null())
.col(TrackingLink::FulfillmentId.col().uuid().not_null())
.col(ts_def_now_not_null!(TrackingLink::CreatedAt))
.col(ts_def_now_not_null!(TrackingLink::UpdatedAt))
.col(TrackingLink::DeletedAt.col().timestamp())
.col(TrackingLink::Metadata.col().json_binary())
.col(TrackingLink::IdempotencyKey.col().uuid())
.to_owned(),
)
.await?;
Ok(())
}
/// ```sql
/// CREATE TABLE custom_shipping_options
/// (
/// id uuid NOT NULL,
/// price integer NOT NULL,
/// shipping_option_id uuid NOT NULL,
/// cart_id uuid,
/// 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
/// );
/// ```
async fn create_custom_shipping_options(m: &SchemaManager<'_>) -> Result<(), DbErr> {
m.create_table(
Table::create()
.table(CustomShippingOption::CustomShippingOptions)
.col(auto_uuid_not_null!(CustomShippingOption::Id))
.col(CustomShippingOption::Price.col().integer().not_null())
.col(
CustomShippingOption::ShippingOptionId
.col()
.uuid()
.not_null(),
)
.col(CustomShippingOption::CartId.col().uuid().not_null())
.col(ts_def_now_not_null!(CustomShippingOption::CreatedAt))
.col(ts_def_now_not_null!(CustomShippingOption::UpdatedAt))
.col(CustomShippingOption::DeletedAt.col().timestamp())
.col(CustomShippingOption::Metadata.col().json_binary())
.to_owned(),
)
.await?;
Ok(())
}
//###########################################
/// ```sql
/// CREATE TABLE shipping_methods
/// (
/// id uuid NOT NULL,
/// shipping_option_id uuid NOT NULL,
/// order_id uuid,
/// cart_id uuid,
/// swap_id uuid,
/// return_id uuid,
/// price integer NOT NULL,
/// data jsonb NOT NULL,
/// claim_order_id uuid,
/// CONSTRAINT "CHK_64c6812fe7815be30d688df513" CHECK ((price >= 0)),
/// CONSTRAINT "CHK_a7020b08665bbd64d84a6641cf" CHECK (((claim_order_id
/// IS NOT NULL) OR (order_id IS NOT NULL) OR
/// (cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR
/// (return_id IS NOT NULL))) );
/// ```
async fn create_shipping_methods(m: &SchemaManager<'_>) -> Result<(), DbErr> {
Ok(())
}
/// ```sql
/// CREATE TABLE shipping_method_tax_lines
/// (
/// id uuid NOT NULL,
/// rate real NOT NULL,
/// name character varying NOT NULL,
/// code character varying,
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
/// metadata jsonb,
/// shipping_method_id uuid NOT NULL
/// );
/// ```
async fn create_shipping_method_tax_lines(m: &SchemaManager<'_>) -> Result<(), DbErr> {
Ok(())
}
/// ```sql
/// CREATE TABLE shipping_options
/// (
/// id uuid NOT NULL,
/// name character varying NOT NULL,
/// region_id uuid NOT NULL,
/// profile_id uuid NOT NULL,
/// provider_id uuid NOT NULL,
/// price_type shipping_option_price_types NOT NULL,
/// amount integer,
/// is_return boolean DEFAULT false NOT NULL,
/// data jsonb NOT NULL,
/// 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,
/// admin_only boolean DEFAULT false NOT NULL,
/// CONSTRAINT "CHK_7a367f5901ae0a5b0df75aee38" CHECK ((amount >= 0))
/// );
/// ````
async fn create_shipping_options(m: &SchemaManager<'_>) -> Result<(), DbErr> {
Ok(())
}
/// ```sql
/// CREATE TABLE shipping_option_requirements
/// (
/// id uuid NOT NULL,
/// shipping_option_id uuid NOT NULL,
/// type shipping_option_requirement_types NOT NULL,
/// amount integer NOT NULL,
/// deleted_at timestamp with time zone
/// );
/// ```
async fn create_shipping_option_requirements(m: &SchemaManager<'_>) -> Result<(), DbErr> {
Ok(())
}
/// ```sql
/// CREATE TABLE shipping_profiles
/// (
/// id uuid NOT NULL,
/// name character varying NOT NULL,
/// type shipping_profile_types NOT NULL,
/// 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
/// );
/// ```
async fn create_shipping_profiles(m: &SchemaManager<'_>) -> Result<(), DbErr> {
Ok(())
}
/// ```sql
/// CREATE TABLE shipping_tax_rates
/// (
/// shipping_option_id uuid NOT NULL,
/// rate_id uuid NOT NULL,
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
/// metadata jsonb
/// );
/// ```
async fn create_shipping_tax_rates(m: &SchemaManager<'_>) -> Result<(), DbErr> {
Ok(())
}
}
#[derive(Iden)]
pub enum TrackingLink {
TrackingLinks,
Id,
Url,
TrackingNumber,
FulfillmentId,
CreatedAt,
UpdatedAt,
DeletedAt,
Metadata,
IdempotencyKey,
}
#[derive(Iden)]
pub enum CustomShippingOption {
CustomShippingOptions,
Id,
Price,
ShippingOptionId,
CartId,
CreatedAt,
UpdatedAt,
DeletedAt,
Metadata,
}
//#############################
#[derive(Iden)]
pub enum ShippingMethod {
ShippingMethods,
Id,
ShippingOptionId,
OrderId,
CartId,
SwapId,
ReturnId,
Price,
Data,
ClaimOrderId,
}
#[derive(Iden)]
pub enum ShippingMethodTaxLine {
ShippingMethodTaxLines,
Id,
Rate,
Name,
Code,
CreatedAt,
UpdatedAt,
Metadata,
ShippingMethodId,
}
#[derive(Iden)]
pub enum ShippingOption {
ShippingOptions,
Id,
Name,
RegionId,
ProfileId,
ProviderId,
PriceType,
Amount,
IsReturn,
Data,
CreatedAt,
UpdatedAt,
DeletedAt,
Metadata,
AdminOnly,
}
#[derive(Iden)]
pub enum ShippingOptionRequirement {
ShippingOptionRequirements,
Id,
ShippingOptionId,
ShippingOptionRequirementType,
Amount,
DeletedAt,
}
#[derive(Iden)]
pub enum ShippingProfile {
ShippingProfiles,
Id,
Name,
ShippingProfileType,
DeletedAt,
ShippingTaxRates,
ShippingOptionId,
RateId,
CreatedAt,
UpdatedAt,
Metadata,
}

View File

@ -0,0 +1,12 @@
mod m20230603_120810_shipping;
use sea_orm_migration::{MigrationTrait, MigratorTrait};
pub struct ShippingMigrator;
#[async_trait::async_trait]
impl MigratorTrait for ShippingMigrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![Box::new(m20230603_120810_shipping::Migration)]
}
}

View File

@ -624,15 +624,6 @@ CREATE TABLE payment_sessions
is_initiated boolean DEFAULT false NOT NULL
);
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
CREATE TABLE gift_cards
(
id uuid NOT NULL,
@ -661,9 +652,68 @@ CREATE TABLE gift_card_transactions
tax_rate real
);
---------------------------
---------------------------
---------------------------
CREATE TABLE line_items
(
id uuid NOT NULL,
cart_id uuid,
order_id uuid,
swap_id uuid,
title character varying NOT NULL,
description character varying,
thumbnail character varying,
is_giftcard boolean DEFAULT false NOT NULL,
should_merge boolean DEFAULT true NOT NULL,
allow_discounts boolean DEFAULT true NOT NULL,
has_shipping boolean,
unit_price integer NOT NULL,
variant_id uuid,
quantity integer NOT NULL,
fulfilled_quantity integer,
returned_quantity integer,
shipped_quantity integer,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb,
claim_order_id uuid,
is_return boolean DEFAULT false NOT NULL,
original_item_id uuid,
order_edit_id uuid,
CONSTRAINT "CHK_0cd85e15610d11b553d5e8fda6" CHECK ((shipped_quantity <= fulfilled_quantity)),
CONSTRAINT "CHK_64eef00a5064887634f1680866" CHECK ((quantity > 0)),
CONSTRAINT "CHK_91f40396d847f6ecfd9f752bf8" CHECK ((returned_quantity <= quantity)),
CONSTRAINT "CHK_c61716c68f5ad5de2834c827d3" CHECK ((fulfilled_quantity <= quantity))
);
CREATE TABLE line_item_adjustments
(
id uuid NOT NULL,
item_id uuid NOT NULL,
description character varying NOT NULL,
discount_id uuid,
amount numeric NOT NULL,
metadata jsonb
);
CREATE TABLE line_item_tax_lines
(
id uuid NOT NULL,
rate real NOT NULL,
name character varying NOT NULL,
code character varying,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb,
item_id uuid NOT NULL
);
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
CREATE TABLE draft_orders
(
@ -737,75 +787,6 @@ CREATE TABLE invites
expires_at timestamp with time zone DEFAULT now() NOT NULL
);
CREATE TABLE line_items
(
id uuid NOT NULL,
cart_id uuid,
order_id uuid,
swap_id uuid,
title character varying NOT NULL,
description character varying,
thumbnail character varying,
is_giftcard boolean DEFAULT false NOT NULL,
should_merge boolean DEFAULT true NOT NULL,
allow_discounts boolean DEFAULT true NOT NULL,
has_shipping boolean,
unit_price integer NOT NULL,
variant_id uuid,
quantity integer NOT NULL,
fulfilled_quantity integer,
returned_quantity integer,
shipped_quantity integer,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb,
claim_order_id uuid,
is_return boolean DEFAULT false NOT NULL,
original_item_id uuid,
order_edit_id uuid,
CONSTRAINT "CHK_0cd85e15610d11b553d5e8fda6" CHECK ((shipped_quantity <= fulfilled_quantity)),
CONSTRAINT "CHK_64eef00a5064887634f1680866" CHECK ((quantity > 0)),
CONSTRAINT "CHK_91f40396d847f6ecfd9f752bf8" CHECK ((returned_quantity <= quantity)),
CONSTRAINT "CHK_c61716c68f5ad5de2834c827d3" CHECK ((fulfilled_quantity <= quantity))
);
CREATE TABLE line_item_adjustments
(
id uuid NOT NULL,
item_id uuid NOT NULL,
description character varying NOT NULL,
discount_id uuid,
amount numeric NOT NULL,
metadata jsonb
);
CREATE TABLE line_item_tax_lines
(
id uuid NOT NULL,
rate real NOT NULL,
name character varying NOT NULL,
code character varying,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb,
item_id uuid NOT NULL
);
CREATE TABLE money_amounts
(
id uuid NOT NULL,
currency_code character varying NOT NULL,
amount integer NOT NULL,
variant_id uuid,
region_id uuid,
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,
min_quantity integer,
max_quantity integer,
price_list_id uuid
);
CREATE TABLE notes
(
id uuid NOT NULL,
@ -819,7 +800,6 @@ CREATE TABLE notes
metadata jsonb
);
CREATE TABLE oauth
(
id uuid NOT NULL,
@ -830,205 +810,6 @@ CREATE TABLE oauth
data jsonb
);
CREATE TABLE price_lists
(
id uuid NOT NULL,
name character varying NOT NULL,
description character varying NOT NULL,
type price_list_types DEFAULT 'sale'::price_list_types NOT NULL,
status price_list_statuses DEFAULT 'draft'::price_list_statuses NOT NULL,
starts_at timestamp with time zone,
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
);
CREATE TABLE price_list_customer_groups
(
price_list_id uuid NOT NULL,
customer_group_id uuid NOT NULL
);
CREATE TABLE products
(
id uuid NOT NULL,
title character varying NOT NULL,
subtitle character varying,
description character varying,
handle character varying,
is_giftcard boolean DEFAULT false NOT NULL,
thumbnail character varying,
profile_id uuid NOT NULL,
weight integer,
length integer,
height integer,
width integer,
hs_code character varying,
origin_country character varying,
mid_code character varying,
material character varying,
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,
collection_id uuid,
type_id uuid,
discountable boolean DEFAULT true NOT NULL,
status product_statuses DEFAULT 'draft'::product_statuses NOT NULL,
external_id uuid
);
CREATE TABLE product_categories
(
id uuid NOT NULL,
name text NOT NULL,
handle text NOT NULL,
parent_category_id uuid,
mpath text,
is_active boolean DEFAULT false,
is_internal boolean DEFAULT false,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
rank integer DEFAULT 0 NOT NULL,
description text DEFAULT ''::text NOT NULL,
CONSTRAINT product_category_rank_check CHECK ((rank >= 0))
);
CREATE TABLE product_category_products
(
product_category_id uuid NOT NULL,
product_id uuid NOT NULL
);
CREATE TABLE product_collections
(
id uuid NOT NULL,
title character varying NOT NULL,
handle character varying,
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
);
CREATE TABLE product_images
(
product_id uuid NOT NULL,
image_id uuid NOT NULL
);
CREATE TABLE product_options
(
id uuid NOT NULL,
title character varying NOT NULL,
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,
product_id uuid
);
CREATE TABLE product_option_values
(
id uuid NOT NULL,
value character varying NOT NULL,
option_id uuid NOT NULL,
variant_id uuid NOT NULL,
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
);
CREATE TABLE product_sales_channels
(
product_id uuid NOT NULL,
sales_channel_id uuid NOT NULL
);
CREATE TABLE product_tags
(
id uuid NOT NULL,
value character varying NOT NULL,
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
);
CREATE TABLE product_to_tags
(
product_id uuid NOT NULL,
product_tag_id uuid NOT NULL
);
CREATE TABLE product_tax_rates
(
product_id uuid NOT NULL,
rate_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb
);
CREATE TABLE product_types
(
id uuid NOT NULL,
value character varying NOT NULL,
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
);
CREATE TABLE product_type_tax_rates
(
product_type_id uuid NOT NULL,
rate_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb
);
CREATE TABLE product_variants
(
id uuid NOT NULL,
title character varying NOT NULL,
product_id uuid NOT NULL,
sku character varying,
barcode character varying,
ean character varying,
upc character varying,
inventory_quantity integer NOT NULL,
allow_backorder boolean DEFAULT false NOT NULL,
manage_inventory boolean DEFAULT true NOT NULL,
hs_code character varying,
origin_country character varying,
mid_code character varying,
material character varying,
weight integer,
length integer,
height integer,
width integer,
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,
variant_rank integer DEFAULT 0
);
CREATE TABLE product_variant_inventory_items
(
id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
inventory_item_id text NOT NULL,
variant_id text NOT NULL,
required_quantity integer DEFAULT 1 NOT NULL,
deleted_at timestamp with time zone
);
CREATE TABLE publishable_api_keys
(
id uuid NOT NULL,
@ -1138,83 +919,6 @@ CREATE TABLE sales_channel_locations
deleted_at timestamp with time zone
);
CREATE TABLE shipping_methods
(
id uuid NOT NULL,
shipping_option_id uuid NOT NULL,
order_id uuid,
cart_id uuid,
swap_id uuid,
return_id uuid,
price integer NOT NULL,
data jsonb NOT NULL,
claim_order_id uuid,
CONSTRAINT "CHK_64c6812fe7815be30d688df513" CHECK ((price >= 0)),
CONSTRAINT "CHK_a7020b08665bbd64d84a6641cf" CHECK (((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL) OR
(cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR
(return_id IS NOT NULL)))
);
CREATE TABLE shipping_method_tax_lines
(
id uuid NOT NULL,
rate real NOT NULL,
name character varying NOT NULL,
code character varying,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb,
shipping_method_id uuid NOT NULL
);
CREATE TABLE shipping_options
(
id uuid NOT NULL,
name character varying NOT NULL,
region_id uuid NOT NULL,
profile_id uuid NOT NULL,
provider_id uuid NOT NULL,
price_type shipping_option_price_types NOT NULL,
amount integer,
is_return boolean DEFAULT false NOT NULL,
data jsonb NOT NULL,
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,
admin_only boolean DEFAULT false NOT NULL,
CONSTRAINT "CHK_7a367f5901ae0a5b0df75aee38" CHECK ((amount >= 0))
);
CREATE TABLE shipping_option_requirements
(
id uuid NOT NULL,
shipping_option_id uuid NOT NULL,
type shipping_option_requirement_types NOT NULL,
amount integer NOT NULL,
deleted_at timestamp with time zone
);
CREATE TABLE shipping_profiles
(
id uuid NOT NULL,
name character varying NOT NULL,
type shipping_profile_types NOT NULL,
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
);
CREATE TABLE shipping_tax_rates
(
shipping_option_id uuid NOT NULL,
rate_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb
);
CREATE TABLE staged_jobs
(
id uuid NOT NULL,

View File

@ -22,3 +22,85 @@ CREATE TABLE custom_shipping_options
deleted_at timestamp with time zone,
metadata jsonb
);
---------
---------
---------
---------
CREATE TABLE shipping_methods
(
id uuid NOT NULL,
shipping_option_id uuid NOT NULL,
order_id uuid,
cart_id uuid,
swap_id uuid,
return_id uuid,
price integer NOT NULL,
data jsonb NOT NULL,
claim_order_id uuid,
CONSTRAINT "CHK_64c6812fe7815be30d688df513" CHECK ((price >= 0)),
CONSTRAINT "CHK_a7020b08665bbd64d84a6641cf" CHECK (((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL) OR
(cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR
(return_id IS NOT NULL)))
);
CREATE TABLE shipping_method_tax_lines
(
id uuid NOT NULL,
rate real NOT NULL,
name character varying NOT NULL,
code character varying,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb,
shipping_method_id uuid NOT NULL
);
CREATE TABLE shipping_options
(
id uuid NOT NULL,
name character varying NOT NULL,
region_id uuid NOT NULL,
profile_id uuid NOT NULL,
provider_id uuid NOT NULL,
price_type shipping_option_price_types NOT NULL,
amount integer,
is_return boolean DEFAULT false NOT NULL,
data jsonb NOT NULL,
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,
admin_only boolean DEFAULT false NOT NULL,
CONSTRAINT "CHK_7a367f5901ae0a5b0df75aee38" CHECK ((amount >= 0))
);
CREATE TABLE shipping_option_requirements
(
id uuid NOT NULL,
shipping_option_id uuid NOT NULL,
type shipping_option_requirement_types NOT NULL,
amount integer NOT NULL,
deleted_at timestamp with time zone
);
CREATE TABLE shipping_profiles
(
id uuid NOT NULL,
name character varying NOT NULL,
type shipping_profile_types NOT NULL,
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
);
CREATE TABLE shipping_tax_rates
(
shipping_option_id uuid NOT NULL,
rate_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb
);

View File

@ -0,0 +1,215 @@
-- PENDING
CREATE TABLE price_lists
(
id uuid NOT NULL,
name character varying NOT NULL,
description character varying NOT NULL,
type price_list_types DEFAULT 'sale'::price_list_types NOT NULL,
status price_list_statuses DEFAULT 'draft'::price_list_statuses NOT NULL,
starts_at timestamp with time zone,
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
);
CREATE TABLE price_list_customer_groups
(
price_list_id uuid NOT NULL,
customer_group_id uuid NOT NULL
);
CREATE TABLE products
(
id uuid NOT NULL,
title character varying NOT NULL,
subtitle character varying,
description character varying,
handle character varying,
is_giftcard boolean DEFAULT false NOT NULL,
thumbnail character varying,
profile_id uuid NOT NULL,
weight integer,
length integer,
height integer,
width integer,
hs_code character varying,
origin_country character varying,
mid_code character varying,
material character varying,
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,
collection_id uuid,
type_id uuid,
discountable boolean DEFAULT true NOT NULL,
status product_statuses DEFAULT 'draft'::product_statuses NOT NULL,
external_id uuid
);
CREATE TABLE product_categories
(
id uuid NOT NULL,
name text NOT NULL,
handle text NOT NULL,
parent_category_id uuid,
mpath text,
is_active boolean DEFAULT false,
is_internal boolean DEFAULT false,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
rank integer DEFAULT 0 NOT NULL,
description text DEFAULT ''::text NOT NULL,
CONSTRAINT product_category_rank_check CHECK ((rank >= 0))
);
CREATE TABLE product_category_products
(
product_category_id uuid NOT NULL,
product_id uuid NOT NULL
);
CREATE TABLE product_collections
(
id uuid NOT NULL,
title character varying NOT NULL,
handle character varying,
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
);
CREATE TABLE product_images
(
product_id uuid NOT NULL,
image_id uuid NOT NULL
);
CREATE TABLE product_options
(
id uuid NOT NULL,
title character varying NOT NULL,
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,
product_id uuid
);
CREATE TABLE product_option_values
(
id uuid NOT NULL,
value character varying NOT NULL,
option_id uuid NOT NULL,
variant_id uuid NOT NULL,
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
);
CREATE TABLE product_sales_channels
(
product_id uuid NOT NULL,
sales_channel_id uuid NOT NULL
);
CREATE TABLE product_tags
(
id uuid NOT NULL,
value character varying NOT NULL,
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
);
CREATE TABLE product_to_tags
(
product_id uuid NOT NULL,
product_tag_id uuid NOT NULL
);
CREATE TABLE product_tax_rates
(
product_id uuid NOT NULL,
rate_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb
);
CREATE TABLE product_types
(
id uuid NOT NULL,
value character varying NOT NULL,
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
);
CREATE TABLE product_type_tax_rates
(
product_type_id uuid NOT NULL,
rate_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
metadata jsonb
);
CREATE TABLE product_variants
(
id uuid NOT NULL,
title character varying NOT NULL,
product_id uuid NOT NULL,
sku character varying,
barcode character varying,
ean character varying,
upc character varying,
inventory_quantity integer NOT NULL,
allow_backorder boolean DEFAULT false NOT NULL,
manage_inventory boolean DEFAULT true NOT NULL,
hs_code character varying,
origin_country character varying,
mid_code character varying,
material character varying,
weight integer,
length integer,
height integer,
width integer,
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,
variant_rank integer DEFAULT 0
);
CREATE TABLE product_variant_inventory_items
(
id uuid NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
inventory_item_id text NOT NULL,
variant_id text NOT NULL,
required_quantity integer DEFAULT 1 NOT NULL,
deleted_at timestamp with time zone
);
CREATE TABLE money_amounts
(
id uuid NOT NULL,
currency_code character varying NOT NULL,
amount integer NOT NULL,
variant_id uuid,
region_id uuid,
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,
min_quantity integer,
max_quantity integer,
price_list_id uuid
);