61 lines
1.4 KiB
SQL
61 lines
1.4 KiB
SQL
-- Gelato / External print
|
|
|
|
|
|
-- modelled after Gelato
|
|
ALTER TABLE orders DROP COLUMN IF EXISTS external_order_id;
|
|
ALTER TABLE order_rows DROP COLUMN IF EXISTS external_status;
|
|
DROP TABLE IF EXISTS external_print_products;
|
|
DROP TYPE IF EXISTS external_status_type;
|
|
DROP TYPE IF EXISTS orientation_type;
|
|
DROP TYPE IF EXISTS orientation_type;
|
|
|
|
-- Order
|
|
CREATE TYPE external_status_type AS ENUM (
|
|
'N/A',
|
|
'not_created',
|
|
'created',
|
|
'uploading',
|
|
'passed',
|
|
'failed',
|
|
'canceled',
|
|
'printed',
|
|
'shipped',
|
|
'delivered',
|
|
'pending_approval',
|
|
'draft',
|
|
'not_connected'
|
|
);
|
|
|
|
ALTER TABLE orders ADD COLUMN IF NOT EXISTS external_order_id text;
|
|
|
|
ALTER TABLE order_rows ADD COLUMN IF NOT EXISTS external_status external_status_type NOT NULL DEFAULT 'N/A';
|
|
|
|
|
|
-- External print products
|
|
CREATE TYPE orientation_type AS ENUM (
|
|
'landscape',
|
|
'portrait',
|
|
'square'
|
|
);
|
|
|
|
|
|
-- product-groups.groupid senare
|
|
CREATE TABLE external_print_products (
|
|
id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
orientation orientation_type NOT NULL,
|
|
accessory TEXT NOT NULL,
|
|
width_mm numeric NOT NULL,
|
|
height_mm numeric NOT NULL,
|
|
width_inch numeric NOT NULL,
|
|
height_inch numeric NOT NULL,
|
|
external_product_id TEXT NOT NULL UNIQUE,
|
|
inserted timestamp with time zone DEFAULT now(),
|
|
updated timestamp with time zone,
|
|
price_sek numeric NOT NULL,
|
|
group_id INT,
|
|
CONSTRAINT fk_product_groups
|
|
FOREIGN KEY(group_id)
|
|
REFERENCES "product-groups"(groupid)
|
|
);
|
|
|