2023-06-09 17:30:58 +02:00
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA
|
|
|
|
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
|
2023-06-03 13:31:57 +02:00
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE payment_collection_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'not_paid',
|
|
|
|
'awaiting',
|
|
|
|
'authorized',
|
|
|
|
'partially_authorized',
|
|
|
|
'canceled'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE payment_collection_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'order_edit'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE cart_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'default',
|
|
|
|
'swap',
|
|
|
|
'draft_order',
|
|
|
|
'payment_link',
|
|
|
|
'claim'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE claim_item_reasons AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'missing_item',
|
|
|
|
'wrong_item',
|
|
|
|
'production_failure',
|
|
|
|
'other'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE claim_order_fulfillment_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'not_fulfilled',
|
|
|
|
'partially_fulfilled',
|
|
|
|
'fulfilled',
|
|
|
|
'partially_shipped',
|
|
|
|
'shipped',
|
|
|
|
'partially_returned',
|
|
|
|
'returned',
|
|
|
|
'canceled',
|
|
|
|
'requires_action'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE claim_order_payment_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'na',
|
|
|
|
'not_refunded',
|
|
|
|
'refunded'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE claim_order_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'refund',
|
|
|
|
'replace'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE discount_condition_operators AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'in',
|
|
|
|
'not_in'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE discount_condition_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'products',
|
|
|
|
'product_types',
|
|
|
|
'product_collections',
|
|
|
|
'product_tags',
|
|
|
|
'customer_groups'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE discount_rule_allocations AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'total',
|
|
|
|
'item'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE discount_rule_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'fixed',
|
|
|
|
'percentage',
|
|
|
|
'free_shipping'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE draft_order_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'open',
|
|
|
|
'completed'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE invite_roles AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'admin',
|
|
|
|
'member',
|
|
|
|
'developer'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE order_fulfillment_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'not_fulfilled',
|
|
|
|
'partially_fulfilled',
|
|
|
|
'fulfilled',
|
|
|
|
'partially_shipped',
|
|
|
|
'shipped',
|
|
|
|
'partially_returned',
|
|
|
|
'returned',
|
|
|
|
'canceled',
|
|
|
|
'requires_action'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE order_item_change_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'item_add',
|
|
|
|
'item_remove',
|
|
|
|
'item_update'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE order_payment_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'not_paid',
|
|
|
|
'awaiting',
|
|
|
|
'captured',
|
|
|
|
'partially_refunded',
|
|
|
|
'refunded',
|
|
|
|
'canceled',
|
|
|
|
'requires_action'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE order_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'pending',
|
|
|
|
'completed',
|
|
|
|
'archived',
|
|
|
|
'canceled',
|
|
|
|
'requires_action'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE payment_session_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'authorized',
|
|
|
|
'pending',
|
|
|
|
'requires_more',
|
|
|
|
'error',
|
|
|
|
'canceled'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE price_list_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'active',
|
|
|
|
'draft'
|
|
|
|
);
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE price_list_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'sale',
|
|
|
|
'override'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE product_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'draft',
|
|
|
|
'proposed',
|
|
|
|
'published',
|
|
|
|
'rejected'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE refund_reasons AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'discount',
|
|
|
|
'return',
|
|
|
|
'swap',
|
|
|
|
'claim',
|
|
|
|
'other'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE return_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'requested',
|
|
|
|
'received',
|
|
|
|
'requires_action',
|
|
|
|
'canceled'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE shipping_option_price_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'flat_rate',
|
|
|
|
'calculated'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE shipping_option_requirement_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'min_subtotal',
|
|
|
|
'max_subtotal'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE shipping_profile_types AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'default',
|
|
|
|
'gift_card',
|
|
|
|
'custom'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE swap_fulfillment_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'not_fulfilled',
|
|
|
|
'fulfilled',
|
|
|
|
'shipped',
|
|
|
|
'partially_shipped',
|
|
|
|
'canceled',
|
|
|
|
'requires_action'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE swap_payment_statuses AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'not_paid',
|
|
|
|
'awaiting',
|
|
|
|
'captured',
|
|
|
|
'confirmed',
|
|
|
|
'canceled',
|
|
|
|
'difference_refunded',
|
|
|
|
'partially_refunded',
|
|
|
|
'refunded',
|
|
|
|
'requires_action'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TYPE user_roles AS ENUM (
|
2023-06-03 13:31:57 +02:00
|
|
|
'admin',
|
|
|
|
'member',
|
|
|
|
'developer'
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE addresses
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
customer_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
company character varying,
|
|
|
|
first_name character varying,
|
|
|
|
last_name character varying,
|
|
|
|
address_1 character varying,
|
|
|
|
address_2 character varying,
|
|
|
|
city character varying,
|
|
|
|
country_code character varying,
|
|
|
|
province character varying,
|
|
|
|
postal_code character varying,
|
|
|
|
phone 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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE analytics_configs
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
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,
|
2023-06-07 21:39:39 +02:00
|
|
|
user_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
opt_out boolean DEFAULT false NOT NULL,
|
|
|
|
anonymize boolean DEFAULT false NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE batch_jobs
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
type text NOT NULL,
|
|
|
|
created_by character varying,
|
|
|
|
context jsonb,
|
|
|
|
result jsonb,
|
|
|
|
dry_run boolean DEFAULT false NOT NULL,
|
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
pre_processed_at timestamp with time zone,
|
|
|
|
confirmed_at timestamp with time zone,
|
|
|
|
processing_at timestamp with time zone,
|
|
|
|
completed_at timestamp with time zone,
|
|
|
|
failed_at timestamp with time zone,
|
|
|
|
canceled_at timestamp with time zone,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
deleted_at timestamp with time zone
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE carts
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-09 17:30:58 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
email character varying,
|
2023-06-07 21:39:39 +02:00
|
|
|
billing_address_id uuid,
|
|
|
|
shipping_address_id uuid,
|
2023-06-09 17:30:58 +02:00
|
|
|
region_id uuid NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
customer_id uuid,
|
|
|
|
payment_id uuid,
|
2023-06-09 17:30:58 +02:00
|
|
|
type cart_types DEFAULT 'default'::cart_types NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
completed_at timestamp with time zone,
|
2023-06-09 17:30:58 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
deleted_at timestamp with time zone,
|
|
|
|
metadata jsonb,
|
|
|
|
idempotency_key character varying,
|
|
|
|
context jsonb,
|
|
|
|
payment_authorized_at timestamp with time zone,
|
2023-06-07 21:39:39 +02:00
|
|
|
sales_channel_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE cart_discounts
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
cart_id uuid NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
discount_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE cart_gift_cards
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
cart_id uuid NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
gift_card_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE claim_images
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
claim_item_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE claim_items
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
claim_order_id uuid NOT NULL,
|
|
|
|
item_id uuid NOT NULL,
|
|
|
|
variant_id uuid NOT NULL,
|
2023-06-09 17:30:58 +02:00
|
|
|
reason claim_item_reasons NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
note character varying,
|
|
|
|
quantity integer 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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE claim_item_tags
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-06 17:02:42 +02:00
|
|
|
item_id uuid NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
tag_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE claim_orders
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-09 17:30:58 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-09 07:21:40 +02:00
|
|
|
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,
|
2023-06-09 17:30:58 +02:00
|
|
|
type claim_order_types NOT NULL,
|
|
|
|
order_id uuid NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
shipping_address_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
refund_amount integer,
|
|
|
|
canceled_at timestamp with time zone,
|
2023-06-09 17:30:58 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
deleted_at timestamp with time zone,
|
|
|
|
metadata jsonb,
|
|
|
|
idempotency_key character varying,
|
|
|
|
no_notification boolean
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE claim_tags
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-07 21:39:39 +02:00
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE regions
|
2023-06-07 21:39:39 +02:00
|
|
|
(
|
|
|
|
id uuid NOT NULL,
|
|
|
|
name character varying NOT NULL,
|
|
|
|
currency_code character varying NOT NULL,
|
|
|
|
tax_rate real NOT NULL,
|
|
|
|
tax_code 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,
|
|
|
|
gift_cards_taxable boolean DEFAULT true NOT NULL,
|
|
|
|
automatic_taxes boolean DEFAULT true NOT NULL,
|
|
|
|
tax_provider_id uuid
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE countries
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-06 17:02:42 +02:00
|
|
|
id sequence NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
iso_2 character varying NOT NULL,
|
|
|
|
iso_3 character varying NOT NULL,
|
|
|
|
num_code integer NOT NULL,
|
|
|
|
name character varying NOT NULL,
|
|
|
|
display_name character varying NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
region_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE currencies
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
|
|
|
code character varying NOT NULL,
|
|
|
|
symbol character varying NOT NULL,
|
|
|
|
symbol_native character varying NOT NULL,
|
|
|
|
name character varying NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discounts
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
code character varying NOT NULL,
|
|
|
|
is_dynamic boolean NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
rule_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
is_disabled boolean NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
parent_discount_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
starts_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP 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,
|
|
|
|
usage_limit integer,
|
|
|
|
usage_count integer DEFAULT 0 NOT NULL,
|
|
|
|
valid_duration character varying
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_conditions
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-09 17:30:58 +02:00
|
|
|
type discount_condition_types NOT NULL,
|
|
|
|
operator discount_condition_operators NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
discount_rule_id uuid NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
deleted_at timestamp with time zone,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_condition_customer_groups
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
customer_group_id uuid NOT NULL,
|
|
|
|
condition_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_condition_products
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
product_id uuid NOT NULL,
|
|
|
|
condition_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_condition_product_collections
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
product_collection_id uuid NOT NULL,
|
|
|
|
condition_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_condition_product_tags
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
product_tag_id uuid NOT NULL,
|
|
|
|
condition_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_condition_product_types
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
product_type_id uuid NOT NULL,
|
|
|
|
condition_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_regions
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-06 17:02:42 +02:00
|
|
|
discount_id uuid NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
region_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_rules
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
description character varying,
|
2023-06-09 17:30:58 +02:00
|
|
|
type discount_rule_types NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
value integer NOT NULL,
|
2023-06-09 07:21:40 +02:00
|
|
|
allocation discount_rule_allocations,
|
2023-06-03 13:31:57 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE discount_rule_products
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-06 17:02:42 +02:00
|
|
|
discount_rule_id uuid NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
product_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE orders
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
2023-06-09 17:30:58 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-09 07:21:40 +02:00
|
|
|
status order_statuses DEFAULT 'pending'::order_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,
|
2023-06-09 17:30:58 +02:00
|
|
|
display_id integer NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
cart_id uuid,
|
2023-06-09 17:30:58 +02:00
|
|
|
customer_id uuid NOT NULL,
|
|
|
|
email character varying NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
billing_address_id uuid,
|
|
|
|
shipping_address_id uuid,
|
2023-06-09 17:30:58 +02:00
|
|
|
region_id uuid NOT NULL,
|
|
|
|
currency_code character varying NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
tax_rate real,
|
|
|
|
canceled_at timestamp with time zone,
|
2023-06-09 17:30:58 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
metadata jsonb,
|
|
|
|
idempotency_key character varying,
|
|
|
|
draft_order_id uuid,
|
|
|
|
no_notification boolean,
|
|
|
|
external_id uuid,
|
|
|
|
sales_channel_id uuid
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE order_discounts
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
order_id uuid NOT NULL,
|
|
|
|
discount_id uuid NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE order_edits
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
id uuid NOT NULL,
|
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
order_id uuid NOT NULL,
|
|
|
|
internal_note character varying,
|
|
|
|
created_by character varying NOT NULL,
|
|
|
|
requested_by character varying,
|
|
|
|
requested_at timestamp with time zone,
|
|
|
|
confirmed_by character varying,
|
|
|
|
confirmed_at timestamp with time zone,
|
|
|
|
declined_by character varying,
|
|
|
|
declined_reason character varying,
|
|
|
|
declined_at timestamp with time zone,
|
|
|
|
canceled_by character varying,
|
|
|
|
canceled_at timestamp with time zone,
|
|
|
|
payment_collection_id uuid
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE order_gift_cards
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
order_id uuid NOT NULL,
|
|
|
|
gift_card_id uuid NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE order_item_changes
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
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,
|
2023-06-09 17:30:58 +02:00
|
|
|
type order_item_change_types NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
order_edit_id uuid NOT NULL,
|
|
|
|
original_line_item_id uuid,
|
|
|
|
line_item_id uuid
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE payments
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
id uuid NOT NULL,
|
|
|
|
swap_id uuid,
|
|
|
|
cart_id uuid,
|
|
|
|
order_id uuid,
|
|
|
|
amount integer NOT NULL,
|
|
|
|
currency_code character varying NOT NULL,
|
|
|
|
amount_refunded integer DEFAULT 0 NOT NULL,
|
|
|
|
provider_id uuid NOT NULL,
|
|
|
|
data jsonb NOT NULL,
|
|
|
|
captured_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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE payment_collections
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
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,
|
2023-06-09 17:30:58 +02:00
|
|
|
type payment_collection_types NOT NULL,
|
|
|
|
status payment_collection_statuses NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
description text,
|
|
|
|
amount integer NOT NULL,
|
|
|
|
authorized_amount integer,
|
|
|
|
region_id uuid NOT NULL,
|
|
|
|
currency_code character varying NOT NULL,
|
|
|
|
metadata jsonb,
|
|
|
|
created_by character varying NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE payment_collection_payments
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
payment_collection_id uuid NOT NULL,
|
|
|
|
payment_id uuid NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE payment_collection_sessions
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
payment_collection_id uuid NOT NULL,
|
|
|
|
payment_session_id uuid NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE payment_providers
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
id uuid NOT NULL,
|
|
|
|
is_installed boolean DEFAULT true NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE payment_sessions
|
2023-06-08 15:48:02 +02:00
|
|
|
(
|
|
|
|
id uuid NOT NULL,
|
|
|
|
cart_id uuid,
|
|
|
|
provider_id uuid NOT NULL,
|
|
|
|
is_selected boolean,
|
2023-06-09 17:30:58 +02:00
|
|
|
status payment_session_statuses NOT NULL,
|
2023-06-08 15:48:02 +02:00
|
|
|
data jsonb NOT NULL,
|
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
idempotency_key character varying,
|
|
|
|
payment_authorized_at timestamp with time zone,
|
|
|
|
amount integer,
|
|
|
|
is_initiated boolean DEFAULT false NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE gift_cards
|
2023-06-08 22:04:03 +02:00
|
|
|
(
|
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE gift_card_transactions
|
2023-06-08 22:04:03 +02:00
|
|
|
(
|
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 17:30:58 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
|
|
|
---- ###########################################################
|
2023-06-08 15:48:02 +02:00
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE draft_orders
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-09 17:30:58 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
status draft_order_statuses DEFAULT 'open'::draft_order_statuses NOT NULL,
|
|
|
|
display_id sequence NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
cart_id uuid,
|
|
|
|
order_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
canceled_at timestamp with time zone,
|
2023-06-09 17:30:58 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
completed_at timestamp with time zone,
|
|
|
|
metadata jsonb,
|
|
|
|
idempotency_key character varying,
|
|
|
|
no_notification_order boolean
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE fulfillments
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
swap_id uuid,
|
|
|
|
order_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
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,
|
2023-06-07 21:39:39 +02:00
|
|
|
provider_id uuid,
|
|
|
|
claim_order_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
no_notification boolean,
|
2023-06-07 21:39:39 +02:00
|
|
|
location_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE fulfillment_items
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
fulfillment_id uuid NOT NULL,
|
|
|
|
item_id uuid NOT NULL,
|
|
|
|
quantity integer NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE fulfillment_providers
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
is_installed boolean DEFAULT true NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE images
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE invites
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
user_email character varying NOT NULL,
|
2023-06-09 17:30:58 +02:00
|
|
|
role invite_roles DEFAULT 'member'::invite_roles,
|
2023-06-03 13:31:57 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE notes
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
value character varying NOT NULL,
|
|
|
|
resource_type character varying NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
resource_id uuid NOT NULL,
|
|
|
|
author_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE oauth
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
display_name character varying NOT NULL,
|
|
|
|
application_name character varying NOT NULL,
|
|
|
|
install_url character varying,
|
|
|
|
uninstall_url character varying,
|
|
|
|
data jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE publishable_api_keys
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
created_by character varying,
|
|
|
|
revoked_by character varying,
|
|
|
|
revoked_at timestamp with time zone,
|
|
|
|
title character varying NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE publishable_api_key_sales_channels
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
sales_channel_id uuid NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
publishable_key_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE refunds
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
order_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
amount integer NOT NULL,
|
|
|
|
note character varying,
|
2023-06-09 17:30:58 +02:00
|
|
|
reason refund_reasons NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
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,
|
2023-06-07 21:39:39 +02:00
|
|
|
payment_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE region_fulfillment_providers
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
region_id uuid NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
provider_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE region_payment_providers
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
region_id uuid NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
provider_id uuid NOT NULL
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE returns
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-09 17:30:58 +02:00
|
|
|
id uuid NOT NULL,
|
|
|
|
status return_statuses DEFAULT 'requested'::return_statuses NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
swap_id uuid,
|
|
|
|
order_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
shipping_data jsonb,
|
2023-06-09 17:30:58 +02:00
|
|
|
refund_amount integer NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
received_at timestamp with time zone,
|
2023-06-09 17:30:58 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
metadata jsonb,
|
|
|
|
idempotency_key character varying,
|
2023-06-07 21:39:39 +02:00
|
|
|
claim_order_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
no_notification boolean,
|
2023-06-07 21:39:39 +02:00
|
|
|
location_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE return_items
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
return_id uuid NOT NULL,
|
|
|
|
item_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
quantity integer NOT NULL,
|
|
|
|
is_requested boolean DEFAULT true NOT NULL,
|
|
|
|
requested_quantity integer,
|
|
|
|
received_quantity integer,
|
|
|
|
metadata jsonb,
|
2023-06-07 21:39:39 +02:00
|
|
|
reason_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
note character varying
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE return_reasons
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
value character varying NOT NULL,
|
|
|
|
label character varying NOT NULL,
|
|
|
|
description 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,
|
2023-06-07 21:39:39 +02:00
|
|
|
parent_return_reason_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE sales_channels
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
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,
|
|
|
|
name character varying NOT NULL,
|
|
|
|
description character varying,
|
|
|
|
is_disabled boolean DEFAULT false NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE sales_channel_locations
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
sales_channel_id text NOT NULL,
|
|
|
|
location_id text NOT NULL,
|
|
|
|
deleted_at timestamp with time zone
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE staged_jobs
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
event_name character varying NOT NULL,
|
|
|
|
data jsonb NOT NULL,
|
|
|
|
options jsonb DEFAULT '{}'::jsonb NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE stores
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
name character varying DEFAULT 'Bazaar'::character varying NOT NULL,
|
2023-06-06 17:02:42 +02:00
|
|
|
default_currency_code character varying DEFAULT 'pln'::character varying NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
swap_link_template character varying,
|
2023-06-06 17:02:42 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
metadata jsonb,
|
|
|
|
payment_link_template character varying,
|
|
|
|
invite_link_template character varying,
|
2023-06-07 21:39:39 +02:00
|
|
|
default_sales_channel_id uuid,
|
|
|
|
default_location_id uuid
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE store_currencies
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
store_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
currency_code character varying NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE swaps
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-09 17:30:58 +02:00
|
|
|
fulfillment_status swap_fulfillment_statuses NOT NULL,
|
|
|
|
payment_status swap_payment_statuses NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
order_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
difference_due integer,
|
2023-06-07 21:39:39 +02:00
|
|
|
shipping_address_id uuid,
|
|
|
|
cart_id uuid,
|
2023-06-03 13:31:57 +02:00
|
|
|
confirmed_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,
|
|
|
|
idempotency_key character varying,
|
|
|
|
no_notification boolean,
|
|
|
|
canceled_at timestamp with time zone,
|
|
|
|
allow_backorder boolean DEFAULT false NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE tax_providers
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
is_installed boolean DEFAULT true NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE tax_rates
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
rate real,
|
|
|
|
code character varying,
|
|
|
|
name character varying NOT NULL,
|
2023-06-07 21:39:39 +02:00
|
|
|
region_id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
|
|
metadata jsonb
|
|
|
|
);
|
|
|
|
|
2023-06-09 07:21:40 +02:00
|
|
|
CREATE TABLE users
|
2023-06-03 13:31:57 +02:00
|
|
|
(
|
2023-06-07 21:39:39 +02:00
|
|
|
id uuid NOT NULL,
|
2023-06-03 13:31:57 +02:00
|
|
|
email character varying NOT NULL,
|
|
|
|
first_name character varying,
|
|
|
|
last_name character varying,
|
|
|
|
password_hash character varying,
|
|
|
|
api_token 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,
|
2023-06-09 17:30:58 +02:00
|
|
|
role user_roles DEFAULT 'member'::user_roles
|
2023-06-03 13:31:57 +02:00
|
|
|
);
|