Add more shipping, extract products
This commit is contained in:
parent
1abefd40f7
commit
1ac4327a0a
77
migration/src/checkouts/m20230603_120815_items.rs
Normal file
77
migration/src/checkouts/m20230603_120815_items.rs
Normal 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
|
||||||
|
/// );
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
mod m20230603_120814_checkouts;
|
mod m20230603_120814_checkouts;
|
||||||
|
mod m20230603_120815_items;
|
||||||
|
|
||||||
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
||||||
|
|
||||||
@ -7,6 +8,9 @@ pub struct CheckoutsMigrator;
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigratorTrait for CheckoutsMigrator {
|
impl MigratorTrait for CheckoutsMigrator {
|
||||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
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),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use sea_orm_migration::prelude::*;
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
use crate::sea_orm::Iterable;
|
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)]
|
#[derive(DeriveMigrationName)]
|
||||||
pub struct Migration;
|
pub struct Migration;
|
||||||
@ -9,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_gift_carts(m).await?;
|
||||||
|
Self::gift_card_transactions(m).await?;
|
||||||
Ok(())
|
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,
|
||||||
|
}
|
||||||
|
@ -12,7 +12,10 @@ pub mod schema_list;
|
|||||||
pub use schema_list::*;
|
pub use schema_list::*;
|
||||||
pub mod checkouts;
|
pub mod checkouts;
|
||||||
pub use checkouts::*;
|
pub use checkouts::*;
|
||||||
|
pub mod shipping;
|
||||||
|
pub use shipping::*;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
@ -38,6 +38,7 @@ async fn main() {
|
|||||||
migrate_schema!(cli, Carts, CartsMigrator);
|
migrate_schema!(cli, Carts, CartsMigrator);
|
||||||
migrate_schema!(cli, Discounts, DiscountsMigrator);
|
migrate_schema!(cli, Discounts, DiscountsMigrator);
|
||||||
migrate_schema!(cli, Checkouts, CheckoutsMigrator);
|
migrate_schema!(cli, Checkouts, CheckoutsMigrator);
|
||||||
|
migrate_schema!(cli, Shipping, ShippingMigrator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_cli<M>(cli: &mut Cli, schema: PostgreSQLSchema, migrator: M)
|
pub async fn run_cli<M>(cli: &mut Cli, schema: PostgreSQLSchema, migrator: M)
|
||||||
|
@ -9,6 +9,7 @@ pub enum PostgreSQLSchema {
|
|||||||
Carts,
|
Carts,
|
||||||
Discounts,
|
Discounts,
|
||||||
Checkouts,
|
Checkouts,
|
||||||
|
Shipping,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PostgreSQLSchema {
|
impl PostgreSQLSchema {
|
||||||
@ -19,6 +20,7 @@ impl PostgreSQLSchema {
|
|||||||
PostgreSQLSchema::Carts => "carts",
|
PostgreSQLSchema::Carts => "carts",
|
||||||
PostgreSQLSchema::Discounts => "discounts",
|
PostgreSQLSchema::Discounts => "discounts",
|
||||||
PostgreSQLSchema::Checkouts => "checkouts",
|
PostgreSQLSchema::Checkouts => "checkouts",
|
||||||
|
PostgreSQLSchema::Shipping => "shipping",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
310
migration/src/shipping/m20230603_120810_shipping.rs
Normal file
310
migration/src/shipping/m20230603_120810_shipping.rs
Normal 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,
|
||||||
|
}
|
12
migration/src/shipping/mod.rs
Normal file
12
migration/src/shipping/mod.rs
Normal 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)]
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA
|
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA
|
||||||
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
|
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
|
||||||
|
|
||||||
CREATE TYPE payment_collection_statuses AS ENUM (
|
CREATE TYPE payment_collection_statuses AS ENUM (
|
||||||
'not_paid',
|
'not_paid',
|
||||||
@ -256,17 +256,17 @@ CREATE TABLE batch_jobs
|
|||||||
|
|
||||||
CREATE TABLE carts
|
CREATE TABLE carts
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
email character varying,
|
email character varying,
|
||||||
billing_address_id uuid,
|
billing_address_id uuid,
|
||||||
shipping_address_id uuid,
|
shipping_address_id uuid,
|
||||||
region_id uuid NOT NULL,
|
region_id uuid NOT NULL,
|
||||||
customer_id uuid,
|
customer_id uuid,
|
||||||
payment_id uuid,
|
payment_id uuid,
|
||||||
type cart_types DEFAULT 'default'::cart_types NOT NULL,
|
type cart_types DEFAULT 'default'::cart_types NOT NULL,
|
||||||
completed_at timestamp with time zone,
|
completed_at timestamp with time zone,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_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,
|
deleted_at timestamp with time zone,
|
||||||
metadata jsonb,
|
metadata jsonb,
|
||||||
idempotency_key character varying,
|
idempotency_key character varying,
|
||||||
@ -304,7 +304,7 @@ CREATE TABLE claim_items
|
|||||||
claim_order_id uuid NOT NULL,
|
claim_order_id uuid NOT NULL,
|
||||||
item_id uuid NOT NULL,
|
item_id uuid NOT NULL,
|
||||||
variant_id uuid NOT NULL,
|
variant_id uuid NOT NULL,
|
||||||
reason claim_item_reasons NOT NULL,
|
reason claim_item_reasons NOT NULL,
|
||||||
note character varying,
|
note character varying,
|
||||||
quantity integer NOT NULL,
|
quantity integer NOT NULL,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
@ -321,16 +321,16 @@ CREATE TABLE claim_item_tags
|
|||||||
|
|
||||||
CREATE TABLE claim_orders
|
CREATE TABLE claim_orders
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
payment_status claim_order_payment_statuses DEFAULT 'na'::claim_order_payment_statuses NOT NULL,
|
payment_status claim_order_payment_statuses DEFAULT 'na'::claim_order_payment_statuses NOT NULL,
|
||||||
fulfillment_status claim_order_fulfillment_statuses DEFAULT 'not_fulfilled'::claim_order_fulfillment_statuses NOT NULL,
|
fulfillment_status claim_order_fulfillment_statuses DEFAULT 'not_fulfilled'::claim_order_fulfillment_statuses NOT NULL,
|
||||||
type claim_order_types NOT NULL,
|
type claim_order_types NOT NULL,
|
||||||
order_id uuid NOT NULL,
|
order_id uuid NOT NULL,
|
||||||
shipping_address_id uuid,
|
shipping_address_id uuid,
|
||||||
refund_amount integer,
|
refund_amount integer,
|
||||||
canceled_at timestamp with time zone,
|
canceled_at timestamp with time zone,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_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,
|
deleted_at timestamp with time zone,
|
||||||
metadata jsonb,
|
metadata jsonb,
|
||||||
idempotency_key character varying,
|
idempotency_key character varying,
|
||||||
@ -405,8 +405,8 @@ CREATE TABLE discounts
|
|||||||
CREATE TABLE discount_conditions
|
CREATE TABLE discount_conditions
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
type discount_condition_types NOT NULL,
|
type discount_condition_types NOT NULL,
|
||||||
operator discount_condition_operators NOT NULL,
|
operator discount_condition_operators NOT NULL,
|
||||||
discount_rule_id uuid NOT NULL,
|
discount_rule_id uuid NOT NULL,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
@ -469,7 +469,7 @@ CREATE TABLE discount_rules
|
|||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
description character varying,
|
description character varying,
|
||||||
type discount_rule_types NOT NULL,
|
type discount_rule_types NOT NULL,
|
||||||
value integer NOT NULL,
|
value integer NOT NULL,
|
||||||
allocation discount_rule_allocations,
|
allocation discount_rule_allocations,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
@ -486,22 +486,22 @@ CREATE TABLE discount_rule_products
|
|||||||
|
|
||||||
CREATE TABLE orders
|
CREATE TABLE orders
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
status order_statuses DEFAULT 'pending'::order_statuses NOT NULL,
|
status order_statuses DEFAULT 'pending'::order_statuses NOT NULL,
|
||||||
fulfillment_status order_fulfillment_statuses DEFAULT 'not_fulfilled'::order_fulfillment_statuses NOT NULL,
|
fulfillment_status order_fulfillment_statuses DEFAULT 'not_fulfilled'::order_fulfillment_statuses NOT NULL,
|
||||||
payment_status order_payment_statuses DEFAULT 'not_paid'::order_payment_statuses NOT NULL,
|
payment_status order_payment_statuses DEFAULT 'not_paid'::order_payment_statuses NOT NULL,
|
||||||
display_id integer NOT NULL,
|
display_id integer NOT NULL,
|
||||||
cart_id uuid,
|
cart_id uuid,
|
||||||
customer_id uuid NOT NULL,
|
customer_id uuid NOT NULL,
|
||||||
email character varying NOT NULL,
|
email character varying NOT NULL,
|
||||||
billing_address_id uuid,
|
billing_address_id uuid,
|
||||||
shipping_address_id uuid,
|
shipping_address_id uuid,
|
||||||
region_id uuid NOT NULL,
|
region_id uuid NOT NULL,
|
||||||
currency_code character varying NOT NULL,
|
currency_code character varying NOT NULL,
|
||||||
tax_rate real,
|
tax_rate real,
|
||||||
canceled_at timestamp with time zone,
|
canceled_at timestamp with time zone,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
metadata jsonb,
|
metadata jsonb,
|
||||||
idempotency_key character varying,
|
idempotency_key character varying,
|
||||||
draft_order_id uuid,
|
draft_order_id uuid,
|
||||||
@ -548,7 +548,7 @@ CREATE TABLE order_item_changes
|
|||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_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,
|
deleted_at timestamp with time zone,
|
||||||
type order_item_change_types NOT NULL,
|
type order_item_change_types NOT NULL,
|
||||||
order_edit_id uuid NOT NULL,
|
order_edit_id uuid NOT NULL,
|
||||||
original_line_item_id uuid,
|
original_line_item_id uuid,
|
||||||
line_item_id uuid
|
line_item_id uuid
|
||||||
@ -579,8 +579,8 @@ CREATE TABLE payment_collections
|
|||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_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,
|
deleted_at timestamp with time zone,
|
||||||
type payment_collection_types NOT NULL,
|
type payment_collection_types NOT NULL,
|
||||||
status payment_collection_statuses NOT NULL,
|
status payment_collection_statuses NOT NULL,
|
||||||
description text,
|
description text,
|
||||||
amount integer NOT NULL,
|
amount integer NOT NULL,
|
||||||
authorized_amount integer,
|
authorized_amount integer,
|
||||||
@ -614,7 +614,7 @@ CREATE TABLE payment_sessions
|
|||||||
cart_id uuid,
|
cart_id uuid,
|
||||||
provider_id uuid NOT NULL,
|
provider_id uuid NOT NULL,
|
||||||
is_selected boolean,
|
is_selected boolean,
|
||||||
status payment_session_statuses NOT NULL,
|
status payment_session_statuses NOT NULL,
|
||||||
data jsonb NOT NULL,
|
data jsonb NOT NULL,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
@ -624,15 +624,6 @@ CREATE TABLE payment_sessions
|
|||||||
is_initiated boolean DEFAULT false NOT NULL
|
is_initiated boolean DEFAULT false NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
---- ###########################################################
|
|
||||||
|
|
||||||
CREATE TABLE gift_cards
|
CREATE TABLE gift_cards
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -661,82 +652,6 @@ CREATE TABLE gift_card_transactions
|
|||||||
tax_rate real
|
tax_rate real
|
||||||
);
|
);
|
||||||
|
|
||||||
---------------------------
|
|
||||||
---------------------------
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
CREATE TABLE draft_orders
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
status draft_order_statuses DEFAULT 'open'::draft_order_statuses NOT NULL,
|
|
||||||
display_id sequence NOT NULL,
|
|
||||||
cart_id uuid,
|
|
||||||
order_id uuid,
|
|
||||||
canceled_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,
|
|
||||||
completed_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
idempotency_key character varying,
|
|
||||||
no_notification_order boolean
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE fulfillments
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
swap_id uuid,
|
|
||||||
order_id uuid,
|
|
||||||
tracking_numbers jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
||||||
data jsonb NOT NULL,
|
|
||||||
shipped_at timestamp with time zone,
|
|
||||||
canceled_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,
|
|
||||||
metadata jsonb,
|
|
||||||
idempotency_key character varying,
|
|
||||||
provider_id uuid,
|
|
||||||
claim_order_id uuid,
|
|
||||||
no_notification boolean,
|
|
||||||
location_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE fulfillment_items
|
|
||||||
(
|
|
||||||
fulfillment_id uuid NOT NULL,
|
|
||||||
item_id uuid NOT NULL,
|
|
||||||
quantity integer NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE fulfillment_providers
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
is_installed boolean DEFAULT true NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE images
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
url 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 invites
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
user_email character varying NOT NULL,
|
|
||||||
role invite_roles DEFAULT 'member'::invite_roles,
|
|
||||||
accepted boolean DEFAULT false 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,
|
|
||||||
token character varying NOT NULL,
|
|
||||||
expires_at timestamp with time zone DEFAULT now() NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE line_items
|
CREATE TABLE line_items
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -791,19 +706,85 @@ CREATE TABLE line_item_tax_lines
|
|||||||
item_id uuid NOT NULL
|
item_id uuid NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE money_amounts
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
---- ###########################################################
|
||||||
|
|
||||||
|
CREATE TABLE draft_orders
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
currency_code character varying NOT NULL,
|
status draft_order_statuses DEFAULT 'open'::draft_order_statuses NOT NULL,
|
||||||
amount integer NOT NULL,
|
display_id sequence NOT NULL,
|
||||||
variant_id uuid,
|
cart_id uuid,
|
||||||
region_id uuid,
|
order_id uuid,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
canceled_at timestamp with time zone,
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
deleted_at timestamp with time zone,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
min_quantity integer,
|
completed_at timestamp with time zone,
|
||||||
max_quantity integer,
|
metadata jsonb,
|
||||||
price_list_id uuid
|
idempotency_key character varying,
|
||||||
|
no_notification_order boolean
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE fulfillments
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
swap_id uuid,
|
||||||
|
order_id uuid,
|
||||||
|
tracking_numbers jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||||
|
data jsonb NOT NULL,
|
||||||
|
shipped_at timestamp with time zone,
|
||||||
|
canceled_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,
|
||||||
|
metadata jsonb,
|
||||||
|
idempotency_key character varying,
|
||||||
|
provider_id uuid,
|
||||||
|
claim_order_id uuid,
|
||||||
|
no_notification boolean,
|
||||||
|
location_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE fulfillment_items
|
||||||
|
(
|
||||||
|
fulfillment_id uuid NOT NULL,
|
||||||
|
item_id uuid NOT NULL,
|
||||||
|
quantity integer NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE fulfillment_providers
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
is_installed boolean DEFAULT true NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE images
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
url 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 invites
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
user_email character varying NOT NULL,
|
||||||
|
role invite_roles DEFAULT 'member'::invite_roles,
|
||||||
|
accepted boolean DEFAULT false 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,
|
||||||
|
token character varying NOT NULL,
|
||||||
|
expires_at timestamp with time zone DEFAULT now() NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE notes
|
CREATE TABLE notes
|
||||||
@ -819,7 +800,6 @@ CREATE TABLE notes
|
|||||||
metadata jsonb
|
metadata jsonb
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE oauth
|
CREATE TABLE oauth
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -830,205 +810,6 @@ CREATE TABLE oauth
|
|||||||
data jsonb
|
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
|
CREATE TABLE publishable_api_keys
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -1052,7 +833,7 @@ CREATE TABLE refunds
|
|||||||
order_id uuid,
|
order_id uuid,
|
||||||
amount integer NOT NULL,
|
amount integer NOT NULL,
|
||||||
note character varying,
|
note character varying,
|
||||||
reason refund_reasons NOT NULL,
|
reason refund_reasons NOT NULL,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
metadata jsonb,
|
metadata jsonb,
|
||||||
@ -1074,15 +855,15 @@ CREATE TABLE region_payment_providers
|
|||||||
|
|
||||||
CREATE TABLE returns
|
CREATE TABLE returns
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
status return_statuses DEFAULT 'requested'::return_statuses NOT NULL,
|
status return_statuses DEFAULT 'requested'::return_statuses NOT NULL,
|
||||||
swap_id uuid,
|
swap_id uuid,
|
||||||
order_id uuid,
|
order_id uuid,
|
||||||
shipping_data jsonb,
|
shipping_data jsonb,
|
||||||
refund_amount integer NOT NULL,
|
refund_amount integer NOT NULL,
|
||||||
received_at timestamp with time zone,
|
received_at timestamp with time zone,
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
metadata jsonb,
|
metadata jsonb,
|
||||||
idempotency_key character varying,
|
idempotency_key character varying,
|
||||||
claim_order_id uuid,
|
claim_order_id uuid,
|
||||||
@ -1138,83 +919,6 @@ CREATE TABLE sales_channel_locations
|
|||||||
deleted_at timestamp with time zone
|
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
|
CREATE TABLE staged_jobs
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -1247,8 +951,8 @@ CREATE TABLE store_currencies
|
|||||||
CREATE TABLE swaps
|
CREATE TABLE swaps
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
fulfillment_status swap_fulfillment_statuses NOT NULL,
|
fulfillment_status swap_fulfillment_statuses NOT NULL,
|
||||||
payment_status swap_payment_statuses NOT NULL,
|
payment_status swap_payment_statuses NOT NULL,
|
||||||
order_id uuid NOT NULL,
|
order_id uuid NOT NULL,
|
||||||
difference_due integer,
|
difference_due integer,
|
||||||
shipping_address_id uuid,
|
shipping_address_id uuid,
|
||||||
@ -1294,5 +998,5 @@ CREATE TABLE users
|
|||||||
updated_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,
|
deleted_at timestamp with time zone,
|
||||||
metadata jsonb,
|
metadata jsonb,
|
||||||
role user_roles DEFAULT 'member'::user_roles
|
role user_roles DEFAULT 'member'::user_roles
|
||||||
);
|
);
|
||||||
|
@ -22,3 +22,85 @@ CREATE TABLE custom_shipping_options
|
|||||||
deleted_at timestamp with time zone,
|
deleted_at timestamp with time zone,
|
||||||
metadata jsonb
|
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
|
||||||
|
);
|
||||||
|
215
migrations/202306091717_products.sql
Normal file
215
migrations/202306091717_products.sql
Normal 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
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user