-- Migration: Add brands table -- Date: 2026-05-01 -- Description: Create brands table for storing brand names CREATE TABLE IF NOT EXISTS brand ( id SERIAL PRIMARY KEY, name VARCHAR(100) NOT NULL UNIQUE ); CREATE INDEX IF NOT EXISTS idx_brand_name ON brand(name); -- Insert existing brands from products INSERT INTO brand (name) SELECT DISTINCT brand FROM product WHERE brand IS NOT NULL AND brand != '' ON CONFLICT (name) DO NOTHING; -- Insert existing brands from model table INSERT INTO brand (name) SELECT DISTINCT brand FROM model WHERE brand IS NOT NULL AND brand != '' ON CONFLICT (name) DO NOTHING;