diff --git a/pos/migrations/runner.py b/pos/migrations/runner.py index 9044273..acb0cc3 100755 --- a/pos/migrations/runner.py +++ b/pos/migrations/runner.py @@ -52,6 +52,7 @@ MIGRATIONS = { "v4.3": "v4.3_facturapi.sql", "v4.4": "v4.4_workshop.sql", "v4.5": "v4.5_customer_max_discount.sql", + "v4.6": "v4.6_inventory_support.sql", } diff --git a/pos/migrations/v4.6_inventory_support.sql b/pos/migrations/v4.6_inventory_support.sql new file mode 100644 index 0000000..a97b3f7 --- /dev/null +++ b/pos/migrations/v4.6_inventory_support.sql @@ -0,0 +1,20 @@ +-- Tenant DB schema v4.6 — support tables for inventory UI + +-- Product categories (hierarchical, optional) +CREATE TABLE IF NOT EXISTS categories ( + id SERIAL PRIMARY KEY, + name VARCHAR(255) NOT NULL, + parent_id INTEGER REFERENCES categories(id) ON DELETE SET NULL, + is_active BOOLEAN DEFAULT true, + created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_categories_parent ON categories(parent_id); +CREATE INDEX IF NOT EXISTS idx_categories_active ON categories(is_active); + +-- Tier-based discount configuration for price tiers 2 and 3 +CREATE TABLE IF NOT EXISTS tier_discounts ( + tier_id INTEGER PRIMARY KEY, + tier_name VARCHAR(50) NOT NULL, + discount_pct NUMERIC(5,2) DEFAULT 0 +);