diff --git a/api b/api index a3868c1..929a224 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit a3868c18dc9fe6b478ad4f8a5a90f1805124b3e5 +Subproject commit 929a22425e27b94bf7bc3b65befc4177f478023a diff --git a/schema/migrate-v1postgres.mjs b/schema/migrate-v1postgres.mjs index 2476b54..24854f2 100644 --- a/schema/migrate-v1postgres.mjs +++ b/schema/migrate-v1postgres.mjs @@ -156,6 +156,8 @@ async function migrateProducts() { name: p.name, // VARCHAR(128) NOT NULL, price: p.price, // NUMERIC NOT NULL, promo: Boolean(p.promo), // BOOL, + available_from: p.availableFrom ? new Date(p.availableFrom).toISOString() : null, // TIMESTAMP, + available_until: p.availableUntil ? new Date(p.availableUntil).toISOString() : null, // TIMESTAMP, created: p.created, // TIMESTAMP DEFAULT NOW(), // Defaulting to created for migration only updated: p.created, // TIMESTAMP DEFAULT NOW(), diff --git a/schema/v1schema.sql b/schema/v1schema.sql index c4a1d3c..1a23989 100644 --- a/schema/v1schema.sql +++ b/schema/v1schema.sql @@ -83,6 +83,8 @@ CREATE TABLE products ( price NUMERIC NOT NULL, promo BOOL NOT NULL, max_quantity INT, + available_from TIMESTAMP, + available_until TIMESTAMP, target_product_id uuid, created TIMESTAMP NOT NULL DEFAULT NOW(), updated TIMESTAMP NOT NULL DEFAULT NOW(), @@ -124,6 +126,8 @@ CREATE TABLE products ( ) ); CREATE INDEX ON products (event_id); +CREATE INDEX ON products (available_from); +CREATE INDEX ON products (available_until); CREATE TYPE promo_status AS ENUM ('active', 'claimed', 'disabled');