bmc_hub/migrations/110_product_suppliers.sql
Christian 693ac4cfd6 feat: Add case types to settings if not found
feat: Update frontend navigation and links for support and CRM sections

fix: Modify subscription listing and stats endpoints to support 'all' status

feat: Implement subscription status filter in the subscriptions list view

feat: Redirect ticket routes to the new sag path

feat: Integrate devportal routes into the main application

feat: Create a wizard for location creation with nested floors and rooms

feat: Add product suppliers table to track multiple suppliers per product

feat: Implement product audit log to track changes in products

feat: Extend location types to include kantine and moedelokale

feat: Add last_2fa_at column to users table for 2FA grace period tracking
2026-02-09 15:30:07 +01:00

31 lines
1021 B
SQL

-- Migration 110: Product suppliers
-- Track multiple suppliers per product
CREATE TABLE IF NOT EXISTS product_suppliers (
id SERIAL PRIMARY KEY,
product_id INTEGER NOT NULL REFERENCES products(id) ON DELETE CASCADE,
supplier_name VARCHAR(255),
supplier_code VARCHAR(100),
supplier_sku VARCHAR(100),
supplier_price DECIMAL(10, 2),
supplier_currency VARCHAR(10) DEFAULT 'DKK',
supplier_stock INTEGER,
supplier_url TEXT,
supplier_product_url TEXT,
source VARCHAR(50) DEFAULT 'manual',
last_updated_at TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_product_suppliers_product
ON product_suppliers(product_id);
CREATE INDEX IF NOT EXISTS idx_product_suppliers_supplier
ON product_suppliers(supplier_code, supplier_sku);
CREATE TRIGGER trigger_product_suppliers_updated_at
BEFORE UPDATE ON product_suppliers
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();