Start stocks
This commit is contained in:
parent
25732c8511
commit
87fb672497
@ -16,6 +16,8 @@ pub mod shipping;
|
||||
pub use shipping::*;
|
||||
mod sea_ext;
|
||||
pub use sea_ext::*;
|
||||
pub mod stocks;
|
||||
pub use stocks::*;
|
||||
pub mod types;
|
||||
|
||||
pub use types::*;
|
||||
|
581
migration/src/stocks/m20230603_120810_products.rs
Normal file
581
migration/src/stocks/m20230603_120810_products.rs
Normal file
@ -0,0 +1,581 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
use crate::constraint::Check;
|
||||
use crate::sea_orm::Iterable;
|
||||
use crate::{
|
||||
auto_uuid_not_null, ts_def_now_not_null, AsIden, CreateConstraint, CreateIndexExt, 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 {
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_price_lists(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use PriceList::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// CREATE TABLE price_list_customer_groups
|
||||
/// (
|
||||
/// price_list_id uuid NOT NULL,
|
||||
/// customer_group_id uuid NOT NULL
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_price_list_customer_groups(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use PriceListCustomerGroup::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_products(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use Product::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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))
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_categories(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductCategory::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// CREATE TABLE product_category_products
|
||||
/// (
|
||||
/// product_category_id uuid NOT NULL,
|
||||
/// product_id uuid NOT NULL
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_category_products(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductCategoryProduct::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_collections(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductCollection::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// CREATE TABLE product_images
|
||||
/// (
|
||||
/// product_id uuid NOT NULL,
|
||||
/// image_id uuid NOT NULL
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_images(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductImage::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_options(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductOption::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_option_values(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductOptionValue::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// CREATE TABLE product_sales_channels
|
||||
/// (
|
||||
/// product_id uuid NOT NULL,
|
||||
/// sales_channel_id uuid NOT NULL
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_sales_channels(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductSalesChannel::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_tags(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductTag::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// CREATE TABLE product_to_tags
|
||||
/// (
|
||||
/// product_id uuid NOT NULL,
|
||||
/// product_tag_id uuid NOT NULL
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_to_tags(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductToTag::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductTaxRate::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_types(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductType::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_type_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ProductTypeTaxRate::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_variants(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_product_variant_inventory_items(
|
||||
use ::*;
|
||||
|
||||
&self,
|
||||
m: &SchemaManager<'_>,
|
||||
) -> Result<(), DbErr> {
|
||||
Ok(())
|
||||
}
|
||||
/// ```sql
|
||||
/// 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
|
||||
/// );
|
||||
/// ```
|
||||
async fn create_money_amounts(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
use ::*;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum PriceList {
|
||||
PriceLists,
|
||||
Id,
|
||||
Name,
|
||||
Description,
|
||||
PriceListType,
|
||||
Status,
|
||||
StartsAt,
|
||||
EndsAt,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum PriceListCustomerGroup {
|
||||
PriceListCustomerGroups,
|
||||
PriceListId,
|
||||
CustomerGroupId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum Product {
|
||||
Products,
|
||||
Id,
|
||||
Title,
|
||||
Subtitle,
|
||||
Description,
|
||||
Handle,
|
||||
IsGiftcard,
|
||||
Thumbnail,
|
||||
ProfileId,
|
||||
Weight,
|
||||
Length,
|
||||
Height,
|
||||
Width,
|
||||
HsCode,
|
||||
OriginCountry,
|
||||
MidCode,
|
||||
Material,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
CollectionId,
|
||||
TypeId,
|
||||
Discountable,
|
||||
Status,
|
||||
ExternalId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductCategory {
|
||||
ProductCategories,
|
||||
Id,
|
||||
Name,
|
||||
Handle,
|
||||
ParentCategoryId,
|
||||
Mpath,
|
||||
IsActive,
|
||||
IsInternal,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Rank,
|
||||
Description,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductCategoryProduct {
|
||||
ProductCategoryProducts,
|
||||
ProductCategoryId,
|
||||
ProductId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductCollection {
|
||||
ProductCollections,
|
||||
Id,
|
||||
Title,
|
||||
Handle,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductImage {
|
||||
ProductImages,
|
||||
ProductId,
|
||||
ImageId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductOption {
|
||||
ProductOptions,
|
||||
Id,
|
||||
Title,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
ProductId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductOptionValue {
|
||||
ProductOptionValues,
|
||||
Id,
|
||||
Value,
|
||||
OptionId,
|
||||
VariantId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductSalesChannel {
|
||||
ProductSalesChannels,
|
||||
ProductId,
|
||||
SalesChannelId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductTag {
|
||||
ProductTags,
|
||||
Id,
|
||||
Value,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductToTag {
|
||||
ProductToTags,
|
||||
ProductId,
|
||||
ProductTagId,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductTaxRate {
|
||||
ProductTaxRates,
|
||||
ProductId,
|
||||
RateId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductType {
|
||||
ProductTypes,
|
||||
Id,
|
||||
Value,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
#[derive(Iden, Copy, Clone)]
|
||||
pub enum ProductTypeTaxRate {
|
||||
ProductTypeTaxRates,
|
||||
ProductTypeId,
|
||||
RateId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum ProductVariant {
|
||||
ProductVariants,
|
||||
Id,
|
||||
Title,
|
||||
ProductId,
|
||||
Sku,
|
||||
Barcode,
|
||||
Ean,
|
||||
Upc,
|
||||
InventoryQuantity,
|
||||
AllowBackorder,
|
||||
ManageInventory,
|
||||
HsCode,
|
||||
OriginCountry,
|
||||
MidCode,
|
||||
Material,
|
||||
Weight,
|
||||
Length,
|
||||
Height,
|
||||
Width,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
Metadata,
|
||||
VariantRank,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum ProductVariantInventoryItem {
|
||||
ProductVariantInventoryItems,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
InventoryItemId,
|
||||
VariantId,
|
||||
RequiredQuantity,
|
||||
DeletedAt,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum MoneyAmount {
|
||||
MoneyAmounts,
|
||||
Id,
|
||||
CurrencyCode,
|
||||
Amount,
|
||||
VariantId,
|
||||
RegionId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
DeletedAt,
|
||||
MinQuantity,
|
||||
MaxQuantity,
|
||||
PriceListId,
|
||||
}
|
12
migration/src/stocks/mod.rs
Normal file
12
migration/src/stocks/mod.rs
Normal file
@ -0,0 +1,12 @@
|
||||
mod m20230603_120810_products;
|
||||
|
||||
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
||||
|
||||
pub struct ShocksMigrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for ShocksMigrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![Box::new(m20230603_120810_products::Migration)]
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
-- PENDING
|
||||
-- DONE
|
||||
|
||||
CREATE TABLE price_lists
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user