22 lines
660 B
SQL
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;
|