216 lines
8.2 KiB
SQL
216 lines
8.2 KiB
SQL
-- DONE
|
|
|
|
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
|
|
);
|