-- Backpack: unequipped gear (max 40 slots per hero). CREATE TABLE IF NOT EXISTS hero_inventory ( hero_id BIGINT NOT NULL REFERENCES heroes(id) ON DELETE CASCADE, slot_index SMALLINT NOT NULL CHECK (slot_index >= 0 AND slot_index < 40), gear_id BIGINT NOT NULL REFERENCES gear(id) ON DELETE CASCADE, PRIMARY KEY (hero_id, slot_index), UNIQUE (gear_id) ); CREATE INDEX IF NOT EXISTS idx_hero_inventory_hero ON hero_inventory(hero_id);