Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE shopify_configs (
|
||||
company_id UUID PRIMARY KEY REFERENCES companies(id) ON DELETE CASCADE,
|
||||
shop_domain TEXT NOT NULL DEFAULT '',
|
||||
access_token TEXT NOT NULL DEFAULT '',
|
||||
api_version TEXT NOT NULL DEFAULT '2024-10',
|
||||
is_enabled BOOLEAN NOT NULL DEFAULT false,
|
||||
sync_options JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
last_synced_at TIMESTAMPTZ,
|
||||
last_test_at TIMESTAMPTZ,
|
||||
last_test_status TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE shopify_orders (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
company_id UUID NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
||||
external_id BIGINT NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT '',
|
||||
currency TEXT NOT NULL DEFAULT '',
|
||||
total NUMERIC(14, 2),
|
||||
customer_id BIGINT,
|
||||
customer_email TEXT,
|
||||
customer_name TEXT,
|
||||
ordered_at TIMESTAMPTZ,
|
||||
payload JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
synced_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (company_id, external_id)
|
||||
);
|
||||
|
||||
CREATE INDEX shopify_orders_company_email_idx ON shopify_orders (company_id, lower(customer_email));
|
||||
CREATE INDEX shopify_orders_company_status_idx ON shopify_orders (company_id, status);
|
||||
CREATE INDEX shopify_orders_company_ordered_idx ON shopify_orders (company_id, ordered_at DESC);
|
||||
|
||||
CREATE TABLE shopify_order_items (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
company_id UUID NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
||||
order_id UUID NOT NULL REFERENCES shopify_orders(id) ON DELETE CASCADE,
|
||||
external_id BIGINT NOT NULL,
|
||||
product_id BIGINT,
|
||||
variant_id BIGINT,
|
||||
sku TEXT NOT NULL DEFAULT '',
|
||||
name TEXT NOT NULL DEFAULT '',
|
||||
quantity INT NOT NULL DEFAULT 1,
|
||||
total NUMERIC(14, 2),
|
||||
payload JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (company_id, order_id, external_id)
|
||||
);
|
||||
|
||||
CREATE INDEX shopify_order_items_company_product_idx ON shopify_order_items (company_id, product_id);
|
||||
CREATE INDEX shopify_order_items_company_sku_idx ON shopify_order_items (company_id, sku) WHERE sku <> '';
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS shopify_order_items;
|
||||
DROP TABLE IF EXISTS shopify_orders;
|
||||
DROP TABLE IF EXISTS shopify_configs;
|
||||
Reference in New Issue
Block a user