54 lines
2.3 KiB
SQL
54 lines
2.3 KiB
SQL
-- Simplified enhanced quote database structure
|
|
-- Run each section step by step
|
|
|
|
-- 1. Create project_types table
|
|
CREATE TABLE IF NOT EXISTS project_types (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
type_name VARCHAR(100) NOT NULL UNIQUE,
|
|
type_icon VARCHAR(10) DEFAULT NULL,
|
|
description TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- 2. Insert standard project types
|
|
INSERT IGNORE INTO project_types (type_name, type_icon, description) VALUES
|
|
('tagrenovering', '🏠', 'Komplet renovering af eksisterende tag'),
|
|
('tagskifte', '🔧', 'Udskiftning af tagmaterialer'),
|
|
('tagudskiftning', '🔨', 'Fuldstændig udskiftning af tag'),
|
|
('tagreparation', '⚒️', 'Reparation af eksisterende tag'),
|
|
('tagterasse', '🏗️', 'Installation eller renovering af tagterasse'),
|
|
('tageftersyn', '🔍', 'Inspektion og mindre reparationer');
|
|
|
|
-- 3. Create roof_types table
|
|
CREATE TABLE IF NOT EXISTS roof_types (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
roof_name VARCHAR(100) NOT NULL UNIQUE,
|
|
roof_icon VARCHAR(10) DEFAULT NULL,
|
|
description TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- 4. Insert standard roof types
|
|
INSERT IGNORE INTO roof_types (roof_name, roof_icon, description) VALUES
|
|
('skrå tag', '📐', 'Traditionelt skrå tag med hældning'),
|
|
('fladt tag', '📏', 'Fladt tag eller tagterasse'),
|
|
('tagterasse', '🏗️', 'Bebygget tagterasse'),
|
|
('mansardtag', '🏛️', 'Tag med knækket profil'),
|
|
('saddeltag', '⛺', 'Klassisk saddeltag');
|
|
|
|
-- 5. Add project_type_id to customer_projects (check if exists first)
|
|
SELECT COUNT(*) as column_exists FROM information_schema.columns
|
|
WHERE table_name = 'customer_projects' AND column_name = 'project_type_id' AND table_schema = 'tilbudgivern';
|
|
|
|
-- Only run this if the column doesn't exist
|
|
-- ALTER TABLE customer_projects ADD COLUMN project_type_id INT DEFAULT NULL;
|
|
-- ALTER TABLE customer_projects ADD FOREIGN KEY (project_type_id) REFERENCES project_types(id);
|
|
|
|
-- 6. Add roof_type_id to roof_geometry (check if exists first)
|
|
SELECT COUNT(*) as column_exists FROM information_schema.columns
|
|
WHERE table_name = 'roof_geometry' AND column_name = 'roof_type_id' AND table_schema = 'tilbudgivern';
|
|
|
|
-- Only run this if the column doesn't exist
|
|
-- ALTER TABLE roof_geometry ADD COLUMN roof_type_id INT DEFAULT NULL;
|
|
-- ALTER TABLE roof_geometry ADD FOREIGN KEY (roof_type_id) REFERENCES roof_types(id);
|