feat(items): add dye previews support
Add item_dye_previews table to store color preview images per dyeable part Update item detail and edit views to support managing dye previews
This commit is contained in:
@@ -1218,6 +1218,22 @@ CREATE TABLE IF NOT EXISTS items (
|
||||
CHECK (usage_key IS NULL OR usage_key IN ('decoration', 'relaxation', 'toy', 'road', 'food'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS item_dye_previews (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
item_id integer NOT NULL REFERENCES items(id) ON DELETE CASCADE,
|
||||
part_index integer NOT NULL CHECK (part_index BETWEEN 1 AND 3),
|
||||
color_name text NOT NULL,
|
||||
image_path text NOT NULL,
|
||||
sort_order integer NOT NULL DEFAULT 0 CHECK (sort_order >= 0),
|
||||
CHECK (length(color_name) BETWEEN 1 AND 80)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS item_dye_previews_item_part_color_idx
|
||||
ON item_dye_previews(item_id, part_index, lower(color_name));
|
||||
|
||||
CREATE INDEX IF NOT EXISTS item_dye_previews_item_order_idx
|
||||
ON item_dye_previews(item_id, part_index, sort_order, id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS recipes (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
item_id integer NOT NULL UNIQUE REFERENCES items(id),
|
||||
@@ -1557,6 +1573,22 @@ ALTER TABLE skills
|
||||
ALTER TABLE items
|
||||
ADD COLUMN IF NOT EXISTS dyeability integer NOT NULL DEFAULT 0 CHECK (dyeability IN (0, 1, 2, 3));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS item_dye_previews (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
item_id integer NOT NULL REFERENCES items(id) ON DELETE CASCADE,
|
||||
part_index integer NOT NULL CHECK (part_index BETWEEN 1 AND 3),
|
||||
color_name text NOT NULL,
|
||||
image_path text NOT NULL,
|
||||
sort_order integer NOT NULL DEFAULT 0 CHECK (sort_order >= 0),
|
||||
CHECK (length(color_name) BETWEEN 1 AND 80)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS item_dye_previews_item_part_color_idx
|
||||
ON item_dye_previews(item_id, part_index, lower(color_name));
|
||||
|
||||
CREATE INDEX IF NOT EXISTS item_dye_previews_item_order_idx
|
||||
ON item_dye_previews(item_id, part_index, sort_order, id);
|
||||
|
||||
ALTER TABLE environments
|
||||
ADD COLUMN IF NOT EXISTS description text NOT NULL DEFAULT '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user