Files
tilbudgivern/archive/sql/add_varenr_to_project_materials.sql
T
2025-10-30 18:28:58 +00:00

22 lines
660 B
SQL

-- Add varenr column to project_materials table
-- This allows linking materials to installation_manuals and bygma_products
USE tilbudgivern;
-- Add varenr column if it doesn't exist
ALTER TABLE project_materials
ADD COLUMN IF NOT EXISTS varenr VARCHAR(50) AFTER material_name;
-- Add index for better JOIN performance
CREATE INDEX IF NOT EXISTS idx_varenr ON project_materials(varenr);
-- Show the updated table structure
DESCRIBE project_materials;
-- Count existing materials without varenr
SELECT COUNT(*) as materials_without_varenr
FROM project_materials
WHERE varenr IS NULL OR varenr = '';
SELECT 'Migration completed successfully' as status;