Implement persistent Line ordering for project specs and update bible
This commit is contained in:
18
migrations/028_add_line_no_to_configurations.sql
Normal file
18
migrations/028_add_line_no_to_configurations.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
ALTER TABLE qt_configurations
|
||||
ADD COLUMN IF NOT EXISTS line_no INT NULL AFTER only_in_stock;
|
||||
|
||||
UPDATE qt_configurations q
|
||||
JOIN (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY COALESCE(NULLIF(TRIM(project_uuid), ''), '__NO_PROJECT__')
|
||||
ORDER BY created_at ASC, id ASC
|
||||
) AS rn
|
||||
FROM qt_configurations
|
||||
WHERE line_no IS NULL OR line_no <= 0
|
||||
) ranked ON ranked.id = q.id
|
||||
SET q.line_no = ranked.rn * 10;
|
||||
|
||||
ALTER TABLE qt_configurations
|
||||
ADD INDEX IF NOT EXISTS idx_qt_configurations_project_line_no (project_uuid, line_no);
|
||||
Reference in New Issue
Block a user