This commit is contained in:
lejay
2026-02-13 00:21:53 +01:00
parent 81d2412835
commit 6923c319a1
85 changed files with 17836 additions and 0 deletions
@@ -0,0 +1,25 @@
-- Migration: Add Formex materials and sync logs tables
-- Run this on existing databases to add crawler support
-- Matériaux Formex (données scrapées)
CREATE TABLE IF NOT EXISTS formex_materials (
id INTEGER PRIMARY KEY AUTOINCREMENT,
formex_code TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
collection TEXT NOT NULL,
width_mm INTEGER,
height_mm INTEGER,
thickness_mm INTEGER,
formex_url TEXT,
last_synced_at TEXT DEFAULT (datetime('now'))
);
-- Journal de synchronisation
CREATE TABLE IF NOT EXISTS sync_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
source TEXT NOT NULL,
status TEXT NOT NULL,
items_count INTEGER,
error TEXT,
created_at TEXT DEFAULT (datetime('now'))
);
@@ -0,0 +1,34 @@
-- Migration: Enhanced Formex materials with dimensions, variants, images
-- Adds support for multiple dimension formats and color variants per product
-- Add new columns to formex_materials
ALTER TABLE formex_materials ADD COLUMN category TEXT;
ALTER TABLE formex_materials ADD COLUMN image_url TEXT;
ALTER TABLE formex_materials ADD COLUMN price_chf REAL;
ALTER TABLE formex_materials ADD COLUMN active INTEGER DEFAULT 1;
-- Dimension variants (multiple dimensions per material)
CREATE TABLE IF NOT EXISTS formex_dimensions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
material_id INTEGER NOT NULL REFERENCES formex_materials(id) ON DELETE CASCADE,
width_mm INTEGER NOT NULL,
height_mm INTEGER NOT NULL,
thickness_mm INTEGER NOT NULL,
is_default INTEGER DEFAULT 0
);
-- Color/decor variants (linked products)
CREATE TABLE IF NOT EXISTS formex_variants (
id INTEGER PRIMARY KEY AUTOINCREMENT,
material_id INTEGER NOT NULL REFERENCES formex_materials(id) ON DELETE CASCADE,
variant_code TEXT NOT NULL,
variant_name TEXT NOT NULL,
variant_url TEXT,
image_url TEXT
);
-- Create indexes for better query performance
CREATE INDEX IF NOT EXISTS idx_formex_dimensions_material ON formex_dimensions(material_id);
CREATE INDEX IF NOT EXISTS idx_formex_variants_material ON formex_variants(material_id);
CREATE INDEX IF NOT EXISTS idx_formex_materials_active ON formex_materials(active);
CREATE INDEX IF NOT EXISTS idx_formex_materials_collection ON formex_materials(collection);
+12
View File
@@ -0,0 +1,12 @@
-- Migration: Room configurations table for AI-analyzed room layouts
-- Stores room analysis results linked to orders
CREATE TABLE IF NOT EXISTS room_configs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
order_id INTEGER REFERENCES orders(id),
image_path TEXT,
analysis_json TEXT NOT NULL,
created_at TEXT DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_room_configs_order ON room_configs(order_id);
+72
View File
@@ -0,0 +1,72 @@
-- Migration: Modules, hardware, and variants for V2 configurator
-- Catalogue de modules standards
CREATE TABLE IF NOT EXISTS modules (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
category TEXT NOT NULL, -- 'penderie', 'rayonnage', 'tiroirs', 'mixte'
width_mm INTEGER NOT NULL,
height_mm INTEGER,
depth_mm INTEGER,
shelves_count INTEGER DEFAULT 0,
drawers_count INTEGER DEFAULT 0,
has_rod INTEGER DEFAULT 0, -- penderie
customizable INTEGER DEFAULT 1,
base_price_chf REAL NOT NULL,
image_url TEXT,
active INTEGER DEFAULT 1,
created_at TEXT DEFAULT (datetime('now'))
);
-- Quincaillerie Blum
CREATE TABLE IF NOT EXISTS blum_hardware (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
type TEXT NOT NULL, -- 'drawer_system', 'hinge', 'lift_system', 'runner'
variant TEXT, -- 'legrabox', 'tandembox', 'clip_top', etc.
price_chf REAL NOT NULL,
specs_json TEXT,
image_url TEXT,
active INTEGER DEFAULT 1
);
-- Variantes poignées
CREATE TABLE IF NOT EXISTS handle_variants (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
style TEXT, -- 'moderne', 'classique', 'minimaliste', etc.
length_mm INTEGER,
price_chf REAL NOT NULL,
image_url TEXT,
active INTEGER DEFAULT 1
);
-- Variantes charnières
CREATE TABLE IF NOT EXISTS hinge_variants (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
type TEXT NOT NULL, -- 'vissee', 'plantee'
brand TEXT DEFAULT 'Blum',
price_chf REAL NOT NULL,
active INTEGER DEFAULT 1
);
-- Configuration couleurs par élément (pour sauvegarder les configs)
CREATE TABLE IF NOT EXISTS element_colors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
order_id INTEGER REFERENCES orders(id) ON DELETE CASCADE,
element_type TEXT NOT NULL, -- 'plintheBas', 'portes', 'cotes', etc.
finish_id INTEGER NOT NULL,
finish_label TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_modules_category ON modules(category);
CREATE INDEX IF NOT EXISTS idx_modules_active ON modules(active);
CREATE INDEX IF NOT EXISTS idx_blum_hardware_type ON blum_hardware(type);
CREATE INDEX IF NOT EXISTS idx_handle_variants_style ON handle_variants(style);
CREATE INDEX IF NOT EXISTS idx_hinge_variants_type ON hinge_variants(type);
CREATE INDEX IF NOT EXISTS idx_element_colors_order ON element_colors(order_id);
@@ -0,0 +1,5 @@
-- Add dominant_color column to formex_materials for 3D preview color representation
ALTER TABLE formex_materials ADD COLUMN dominant_color TEXT;
-- Create index for quick lookups
CREATE INDEX IF NOT EXISTS idx_formex_materials_dominant_color ON formex_materials(dominant_color);