feat(F-048): completed feature

This commit is contained in:
chattie
2026-08-19 07:17:14 +02:00
parent 8ee1938af9
commit 835ab66eda
187 changed files with 12361 additions and 1065 deletions

View File

@@ -0,0 +1,23 @@
/**
* FIX-19: categories parent/child type.
* Adds is_parent flag (container category). A CHILD is a leaf and cannot
* contain children; only PARENT categories can contain other categories.
*/
/** @param {import('node-pg-migrate'). MigrationBuilder} pgm */
export const up = (pgm) => {
pgm.sql(`ALTER TABLE categories_categories ADD COLUMN is_parent boolean NOT NULL DEFAULT false`);
// Migration rule: categories that already have children become parents.
pgm.sql(`
UPDATE categories_categories c
SET is_parent = true
WHERE EXISTS (
SELECT 1 FROM categories_categories ch WHERE ch.parent_id = c.id
)
`);
};
/** @param {import('node-pg-migrate').MigrationBuilder} pgm */
export const down = (pgm) => {
pgm.sql('ALTER TABLE categories_categories DROP COLUMN IF EXISTS is_parent');
};