diff --git a/README.md b/README.md index 3a0a72d..7398b10 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The credentials for each environment that could be updated is stored in the `env/default.conf` could look like this: ``` #!/bin/bash -export PSQL_OPTS="-h HOST_NAME -U USER_NAME" +export PSQL_OPTS="-h HOST_NAME -U root" export DB_NAME=DATABASE_NAME ``` diff --git a/migrations/000.360.sql b/migrations/000.360.sql new file mode 100644 index 0000000..b0ab0b8 --- /dev/null +++ b/migrations/000.360.sql @@ -0,0 +1,60 @@ +-- 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) +); +