Add geolocation

This commit is contained in:
eraden 2023-06-07 21:39:39 +02:00
parent bfb164ae36
commit eee5d6c22d
5 changed files with 332 additions and 246 deletions

View File

@ -1,5 +1,4 @@
use sea_orm_migration::prelude::*; use sea_orm_migration::prelude::*;
use sea_query::expr::SimpleExpr;
/// ```sql /// ```sql
/// CREATE TABLE cart_discounts /// CREATE TABLE cart_discounts

View File

@ -111,7 +111,7 @@ impl Migration {
/// tag_id uuid NOT NULL /// tag_id uuid NOT NULL
/// ); /// );
/// ``` /// ```
async fn create_claim_item_tags(manager: &SchemaManager) -> Result<(), DbErr> { async fn create_claim_item_tags(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
manager manager
.create_table( .create_table(
Table::create() Table::create()
@ -139,7 +139,7 @@ impl Migration {
/// metadata jsonb /// metadata jsonb
/// ); /// );
/// ``` /// ```
async fn create_claim_items(manager: &SchemaManager) -> Result<(), DbErr> { async fn create_claim_items(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
manager manager
.create_table( .create_table(
Table::create() Table::create()
@ -179,7 +179,7 @@ impl Migration {
/// metadata jsonb /// metadata jsonb
/// ); /// );
/// ``` /// ```
async fn create_claim_images(manager: &SchemaManager) -> Result<(), DbErr> { async fn create_claim_images(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
manager manager
.create_table( .create_table(
Table::create() Table::create()
@ -215,7 +215,7 @@ impl Migration {
/// no_notification boolean /// no_notification boolean
/// ); /// );
/// ``` /// ```
async fn create_claim_orders(manager: &SchemaManager) -> Result<(), DbErr> { async fn create_claim_orders(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
manager manager
.create_table( .create_table(
Table::create() Table::create()
@ -227,7 +227,7 @@ impl Migration {
ClaimOrderPaymentStatus::ClaimOrderPaymentStatuses, ClaimOrderPaymentStatus::ClaimOrderPaymentStatuses,
ClaimOrderPaymentStatus::iter().skip(1), ClaimOrderPaymentStatus::iter().skip(1),
) )
.default(ClaimOrderPaymentStatus::NA) .default(ClaimOrderPaymentStatus::NA.to_string())
.not_null(), .not_null(),
) )
.col( .col(
@ -236,7 +236,7 @@ impl Migration {
ClaimOrderFulfillmentStatus::ClaimOrderFulfillmentStatuses, ClaimOrderFulfillmentStatus::ClaimOrderFulfillmentStatuses,
ClaimOrderFulfillmentStatus::iter().skip(1), ClaimOrderFulfillmentStatus::iter().skip(1),
) )
.default(ClaimOrderFulfillmentStatus::NotFulfilled) .default(ClaimOrderFulfillmentStatus::NotFulfilled.to_string())
.not_null(), .not_null(),
) )
.col( .col(
@ -273,7 +273,7 @@ impl Migration {
/// metadata jsonb /// metadata jsonb
/// ); /// );
/// ``` /// ```
async fn create_claim_tags(manager: &SchemaManager) -> Result<(), DbErr> { async fn create_claim_tags(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
manager manager
.create_table( .create_table(
Table::create() Table::create()

View File

@ -0,0 +1,84 @@
use sea_orm_migration::prelude::*;
use sea_orm_migration::sea_orm::Iterable;
use sea_query::expr::SimpleExpr;
use crate::types::*;
use crate::{auto_uuid_not_null, ts_def_now_not_null};
/// ```sql
/// ```
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
Ok(())
}
}
impl Migration {
/// ```sql
/// CREATE TABLE public.countries
/// (
/// id sequence NOT NULL,
/// 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,
/// region_id character varying
/// );
/// ```
async fn create_countries(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
todo!()
}
/// ```sql
/// CREATE TABLE public.currencies
/// (
/// code character varying NOT NULL,
/// symbol character varying NOT NULL,
/// symbol_native character varying NOT NULL,
/// name character varying NOT NULL
/// );
/// ```
async fn create_currencies(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
todo!()
}
/// CREATE TABLE public.regions
/// (
/// 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
/// );
async fn create_regions(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
todo!()
}
}
#[derive(Iden)]
pub enum ClaimImage {
ClaimImages,
Id,
ClaimItemId,
Url,
CreatedAt,
UpdatedAt,
DeletedAt,
Metadata,
}

View File

@ -4,6 +4,7 @@ mod m20230603_102630_schema;
mod m20230603_102634_types; mod m20230603_102634_types;
mod m20230603_120814_addresses; mod m20230603_120814_addresses;
mod m20230603_120815_claims; mod m20230603_120815_claims;
mod m20230603_120816_geolocation;
pub struct PublicMigrator; pub struct PublicMigrator;
@ -16,6 +17,7 @@ impl MigratorTrait for PublicMigrator {
Box::new(m20230603_102634_types::Migration), Box::new(m20230603_102634_types::Migration),
Box::new(m20230603_120814_addresses::Migration), Box::new(m20230603_120814_addresses::Migration),
Box::new(m20230603_120815_claims::Migration), Box::new(m20230603_120815_claims::Migration),
Box::new(m20230603_120816_geolocation::Migration),
] ]
} }
} }

View File

@ -207,7 +207,7 @@ CREATE TYPE public.user_roles AS ENUM (
CREATE TABLE public.addresses CREATE TABLE public.addresses
( (
id uuid NOT NULL, id uuid NOT NULL,
customer_id character varying, customer_id uuid,
company character varying, company character varying,
first_name character varying, first_name character varying,
last_name character varying, last_name character varying,
@ -258,11 +258,11 @@ CREATE TABLE public.carts
( (
id uuid NOT NULL, id uuid NOT NULL,
email character varying, email character varying,
billing_address_id character varying, billing_address_id uuid,
shipping_address_id character varying, shipping_address_id uuid,
region_id uuid NOT NULL, region_id uuid NOT NULL,
customer_id character varying, customer_id uuid,
payment_id character varying, payment_id uuid,
type public.cart_types DEFAULT 'default'::public.cart_types NOT NULL, type public.cart_types DEFAULT 'default'::public.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,
@ -272,7 +272,7 @@ CREATE TABLE public.carts
idempotency_key character varying, idempotency_key character varying,
context jsonb, context jsonb,
payment_authorized_at timestamp with time zone, payment_authorized_at timestamp with time zone,
sales_channel_id character varying sales_channel_id uuid
); );
CREATE TABLE public.cart_discounts CREATE TABLE public.cart_discounts
@ -287,15 +287,6 @@ CREATE TABLE public.cart_gift_cards
gift_card_id uuid NOT NULL gift_card_id uuid NOT NULL
); );
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
CREATE TABLE public.claim_images CREATE TABLE public.claim_images
( (
id uuid NOT NULL, id uuid NOT NULL,
@ -335,7 +326,7 @@ CREATE TABLE public.claim_orders
fulfillment_status public.claim_order_fulfillment_statuses DEFAULT 'not_fulfilled'::public.claim_order_fulfillment_statuses NOT NULL, fulfillment_status public.claim_order_fulfillment_statuses DEFAULT 'not_fulfilled'::public.claim_order_fulfillment_statuses NOT NULL,
type public.claim_order_types NOT NULL, type public.claim_order_types NOT NULL,
order_id uuid NOT NULL, order_id uuid NOT NULL,
shipping_address_id character varying, 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,
@ -356,6 +347,32 @@ CREATE TABLE public.claim_tags
metadata jsonb metadata jsonb
); );
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
---- ###########################################################
CREATE TABLE public.regions
(
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
);
CREATE TABLE public.countries CREATE TABLE public.countries
( (
id sequence NOT NULL, id sequence NOT NULL,
@ -364,7 +381,7 @@ CREATE TABLE public.countries
num_code integer NOT NULL, num_code integer NOT NULL,
name character varying NOT NULL, name character varying NOT NULL,
display_name character varying NOT NULL, display_name character varying NOT NULL,
region_id character varying region_id uuid
); );
CREATE TABLE public.currencies CREATE TABLE public.currencies
@ -380,7 +397,7 @@ CREATE TABLE public.custom_shipping_options
id uuid NOT NULL, id uuid NOT NULL,
price integer NOT NULL, price integer NOT NULL,
shipping_option_id uuid NOT NULL, shipping_option_id uuid NOT NULL,
cart_id character varying, cart_id uuid,
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,
@ -393,7 +410,7 @@ CREATE TABLE public.customers
email character varying NOT NULL, email character varying NOT NULL,
first_name character varying, first_name character varying,
last_name character varying, last_name character varying,
billing_address_id character varying, billing_address_id uuid,
password_hash character varying, password_hash character varying,
phone character varying, phone character varying,
has_account boolean DEFAULT false NOT NULL, has_account boolean DEFAULT false NOT NULL,
@ -424,9 +441,9 @@ CREATE TABLE public.discounts
id uuid NOT NULL, id uuid NOT NULL,
code character varying NOT NULL, code character varying NOT NULL,
is_dynamic boolean NOT NULL, is_dynamic boolean NOT NULL,
rule_id character varying, rule_id uuid,
is_disabled boolean NOT NULL, is_disabled boolean NOT NULL,
parent_discount_id character varying, parent_discount_id uuid,
starts_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, starts_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
ends_at timestamp with time zone, ends_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,
@ -525,8 +542,8 @@ CREATE TABLE public.draft_orders
id uuid NOT NULL, id uuid NOT NULL,
status public.draft_order_statuses DEFAULT 'open'::public.draft_order_statuses NOT NULL, status public.draft_order_statuses DEFAULT 'open'::public.draft_order_statuses NOT NULL,
display_id sequence NOT NULL, display_id sequence NOT NULL,
cart_id character varying, cart_id uuid,
order_id character varying, order_id uuid,
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,
@ -539,8 +556,8 @@ CREATE TABLE public.draft_orders
CREATE TABLE public.fulfillments CREATE TABLE public.fulfillments
( (
id uuid NOT NULL, id uuid NOT NULL,
swap_id character varying, swap_id uuid,
order_id character varying, order_id uuid,
tracking_numbers jsonb DEFAULT '[]'::jsonb NOT NULL, tracking_numbers jsonb DEFAULT '[]'::jsonb NOT NULL,
data jsonb NOT NULL, data jsonb NOT NULL,
shipped_at timestamp with time zone, shipped_at timestamp with time zone,
@ -549,10 +566,10 @@ CREATE TABLE public.fulfillments
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,
provider_id character varying, provider_id uuid,
claim_order_id character varying, claim_order_id uuid,
no_notification boolean, no_notification boolean,
location_id character varying location_id uuid
); );
CREATE TABLE public.fulfillment_items CREATE TABLE public.fulfillment_items
@ -575,7 +592,7 @@ CREATE TABLE public.gift_cards
value integer NOT NULL, value integer NOT NULL,
balance integer NOT NULL, balance integer NOT NULL,
region_id uuid NOT NULL, region_id uuid NOT NULL,
order_id character varying, order_id uuid,
is_disabled boolean DEFAULT false NOT NULL, is_disabled boolean DEFAULT false NOT NULL,
ends_at timestamp with time zone, ends_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,
@ -637,9 +654,9 @@ CREATE TABLE public.invites
CREATE TABLE public.line_items CREATE TABLE public.line_items
( (
id uuid NOT NULL, id uuid NOT NULL,
cart_id character varying, cart_id uuid,
order_id character varying, order_id uuid,
swap_id character varying, swap_id uuid,
title character varying NOT NULL, title character varying NOT NULL,
description character varying, description character varying,
thumbnail character varying, thumbnail character varying,
@ -648,7 +665,7 @@ CREATE TABLE public.line_items
allow_discounts boolean DEFAULT true NOT NULL, allow_discounts boolean DEFAULT true NOT NULL,
has_shipping boolean, has_shipping boolean,
unit_price integer NOT NULL, unit_price integer NOT NULL,
variant_id character varying, variant_id uuid,
quantity integer NOT NULL, quantity integer NOT NULL,
fulfilled_quantity integer, fulfilled_quantity integer,
returned_quantity integer, returned_quantity integer,
@ -656,10 +673,10 @@ CREATE TABLE public.line_items
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,
claim_order_id character varying, claim_order_id uuid,
is_return boolean DEFAULT false NOT NULL, is_return boolean DEFAULT false NOT NULL,
original_item_id character varying, original_item_id uuid,
order_edit_id character varying, order_edit_id uuid,
CONSTRAINT "CHK_0cd85e15610d11b553d5e8fda6" CHECK ((shipped_quantity <= fulfilled_quantity)), CONSTRAINT "CHK_0cd85e15610d11b553d5e8fda6" CHECK ((shipped_quantity <= fulfilled_quantity)),
CONSTRAINT "CHK_64eef00a5064887634f1680866" CHECK ((quantity > 0)), CONSTRAINT "CHK_64eef00a5064887634f1680866" CHECK ((quantity > 0)),
CONSTRAINT "CHK_91f40396d847f6ecfd9f752bf8" CHECK ((returned_quantity <= quantity)), CONSTRAINT "CHK_91f40396d847f6ecfd9f752bf8" CHECK ((returned_quantity <= quantity)),
@ -671,7 +688,7 @@ CREATE TABLE public.line_item_adjustments
id uuid NOT NULL, id uuid NOT NULL,
item_id uuid NOT NULL, item_id uuid NOT NULL,
description character varying NOT NULL, description character varying NOT NULL,
discount_id character varying, discount_id uuid,
amount numeric NOT NULL, amount numeric NOT NULL,
metadata jsonb metadata jsonb
); );
@ -700,14 +717,14 @@ CREATE TABLE public.money_amounts
id uuid NOT NULL, id uuid NOT NULL,
currency_code character varying NOT NULL, currency_code character varying NOT NULL,
amount integer NOT NULL, amount integer NOT NULL,
variant_id character varying, variant_id uuid,
region_id character varying, region_id uuid,
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,
min_quantity integer, min_quantity integer,
max_quantity integer, max_quantity integer,
price_list_id character varying price_list_id uuid
); );
CREATE TABLE public.notes CREATE TABLE public.notes
@ -716,7 +733,7 @@ CREATE TABLE public.notes
value character varying NOT NULL, value character varying NOT NULL,
resource_type character varying NOT NULL, resource_type character varying NOT NULL,
resource_id uuid NOT NULL, resource_id uuid NOT NULL,
author_id character varying, author_id uuid,
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,
@ -729,11 +746,11 @@ CREATE TABLE public.notifications
event_name character varying, event_name character varying,
resource_type character varying NOT NULL, resource_type character varying NOT NULL,
resource_id uuid NOT NULL, resource_id uuid NOT NULL,
customer_id character varying, customer_id uuid,
"to" character varying NOT NULL, "to" character varying NOT NULL,
data jsonb NOT NULL, data jsonb NOT NULL,
parent_id character varying, parent_id uuid,
provider_id character varying, provider_id uuid,
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
); );
@ -761,11 +778,11 @@ CREATE TABLE public.orders
fulfillment_status public.order_fulfillment_statuses DEFAULT 'not_fulfilled'::public.order_fulfillment_statuses NOT NULL, fulfillment_status public.order_fulfillment_statuses DEFAULT 'not_fulfilled'::public.order_fulfillment_statuses NOT NULL,
payment_status public.order_payment_statuses DEFAULT 'not_paid'::public.order_payment_statuses NOT NULL, payment_status public.order_payment_statuses DEFAULT 'not_paid'::public.order_payment_statuses NOT NULL,
display_id integer NOT NULL, display_id integer NOT NULL,
cart_id character varying, 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 character varying, billing_address_id uuid,
shipping_address_id character varying, 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,
@ -774,10 +791,10 @@ CREATE TABLE public.orders
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 character varying, draft_order_id uuid,
no_notification boolean, no_notification boolean,
external_id character varying, external_id uuid,
sales_channel_id character varying sales_channel_id uuid
); );
CREATE TABLE public.order_discounts CREATE TABLE public.order_discounts
@ -803,7 +820,7 @@ CREATE TABLE public.order_edits
declined_at timestamp with time zone, declined_at timestamp with time zone,
canceled_by character varying, canceled_by character varying,
canceled_at timestamp with time zone, canceled_at timestamp with time zone,
payment_collection_id character varying payment_collection_id uuid
); );
CREATE TABLE public.order_gift_cards CREATE TABLE public.order_gift_cards
@ -820,16 +837,16 @@ CREATE TABLE public.order_item_changes
deleted_at timestamp with time zone, deleted_at timestamp with time zone,
type public.order_item_change_types NOT NULL, type public.order_item_change_types NOT NULL,
order_edit_id uuid NOT NULL, order_edit_id uuid NOT NULL,
original_line_item_id character varying, original_line_item_id uuid,
line_item_id character varying line_item_id uuid
); );
CREATE TABLE public.payments CREATE TABLE public.payments
( (
id uuid NOT NULL, id uuid NOT NULL,
swap_id character varying, swap_id uuid,
cart_id character varying, cart_id uuid,
order_id character varying, order_id uuid,
amount integer NOT NULL, amount integer NOT NULL,
currency_code character varying NOT NULL, currency_code character varying NOT NULL,
amount_refunded integer DEFAULT 0 NOT NULL, amount_refunded integer DEFAULT 0 NOT NULL,
@ -881,7 +898,7 @@ CREATE TABLE public.payment_providers
CREATE TABLE public.payment_sessions CREATE TABLE public.payment_sessions
( (
id uuid NOT NULL, id uuid NOT NULL,
cart_id character varying, cart_id uuid,
provider_id uuid NOT NULL, provider_id uuid NOT NULL,
is_selected boolean, is_selected boolean,
status public.payment_session_statuses NOT NULL, status public.payment_session_statuses NOT NULL,
@ -936,11 +953,11 @@ CREATE TABLE public.products
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,
collection_id character varying, collection_id uuid,
type_id character varying, type_id uuid,
discountable boolean DEFAULT true NOT NULL, discountable boolean DEFAULT true NOT NULL,
status public.product_statuses DEFAULT 'draft'::public.product_statuses NOT NULL, status public.product_statuses DEFAULT 'draft'::public.product_statuses NOT NULL,
external_id character varying external_id uuid
); );
CREATE TABLE public.product_categories CREATE TABLE public.product_categories
@ -948,7 +965,7 @@ CREATE TABLE public.product_categories
id uuid NOT NULL, id uuid NOT NULL,
name text NOT NULL, name text NOT NULL,
handle text NOT NULL, handle text NOT NULL,
parent_category_id character varying, parent_category_id uuid,
mpath text, mpath text,
is_active boolean DEFAULT false, is_active boolean DEFAULT false,
is_internal boolean DEFAULT false, is_internal boolean DEFAULT false,
@ -990,7 +1007,7 @@ CREATE TABLE public.product_options
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,
product_id character varying product_id uuid
); );
CREATE TABLE public.product_option_values CREATE TABLE public.product_option_values
@ -1113,7 +1130,7 @@ CREATE TABLE public.publishable_api_key_sales_channels
CREATE TABLE public.refunds CREATE TABLE public.refunds
( (
id uuid NOT NULL, id uuid NOT NULL,
order_id character varying, order_id uuid,
amount integer NOT NULL, amount integer NOT NULL,
note character varying, note character varying,
reason public.refund_reasons NOT NULL, reason public.refund_reasons NOT NULL,
@ -1121,23 +1138,7 @@ CREATE TABLE public.refunds
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,
payment_id character varying payment_id uuid
);
CREATE TABLE public.regions
(
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 character varying
); );
CREATE TABLE public.region_fulfillment_providers CREATE TABLE public.region_fulfillment_providers
@ -1156,8 +1157,8 @@ CREATE TABLE public.returns
( (
id uuid NOT NULL, id uuid NOT NULL,
status public.return_statuses DEFAULT 'requested'::public.return_statuses NOT NULL, status public.return_statuses DEFAULT 'requested'::public.return_statuses NOT NULL,
swap_id character varying, swap_id uuid,
order_id character varying, 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,
@ -1165,9 +1166,9 @@ CREATE TABLE public.returns
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 character varying, claim_order_id uuid,
no_notification boolean, no_notification boolean,
location_id character varying location_id uuid
); );
CREATE TABLE public.return_items CREATE TABLE public.return_items
@ -1179,7 +1180,7 @@ CREATE TABLE public.return_items
requested_quantity integer, requested_quantity integer,
received_quantity integer, received_quantity integer,
metadata jsonb, metadata jsonb,
reason_id character varying, reason_id uuid,
note character varying note character varying
); );
@ -1193,7 +1194,7 @@ CREATE TABLE public.return_reasons
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,
parent_return_reason_id character varying parent_return_reason_id uuid
); );
CREATE TABLE public.sales_channels CREATE TABLE public.sales_channels
@ -1222,13 +1223,13 @@ CREATE TABLE public.shipping_methods
( (
id uuid NOT NULL, id uuid NOT NULL,
shipping_option_id uuid NOT NULL, shipping_option_id uuid NOT NULL,
order_id character varying, order_id uuid,
cart_id character varying, cart_id uuid,
swap_id character varying, swap_id uuid,
return_id character varying, return_id uuid,
price integer NOT NULL, price integer NOT NULL,
data jsonb NOT NULL, data jsonb NOT NULL,
claim_order_id character varying, claim_order_id uuid,
CONSTRAINT "CHK_64c6812fe7815be30d688df513" CHECK ((price >= 0)), CONSTRAINT "CHK_64c6812fe7815be30d688df513" CHECK ((price >= 0)),
CONSTRAINT "CHK_a7020b08665bbd64d84a6641cf" CHECK (((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL) OR 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 (cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR
@ -1314,8 +1315,8 @@ CREATE TABLE public.stores
metadata jsonb, metadata jsonb,
payment_link_template character varying, payment_link_template character varying,
invite_link_template character varying, invite_link_template character varying,
default_sales_channel_id character varying, default_sales_channel_id uuid,
default_location_id character varying default_location_id uuid
); );
CREATE TABLE public.store_currencies CREATE TABLE public.store_currencies
@ -1331,8 +1332,8 @@ CREATE TABLE public.swaps
payment_status public.swap_payment_statuses NOT NULL, payment_status public.swap_payment_statuses NOT NULL,
order_id uuid NOT NULL, order_id uuid NOT NULL,
difference_due integer, difference_due integer,
shipping_address_id character varying, shipping_address_id uuid,
cart_id character varying, cart_id uuid,
confirmed_at timestamp with time zone, confirmed_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,