-- Restructure harvestables table to store expanded data
DROP TABLE IF EXISTS harvestables;

CREATE TABLE harvestables (
    id INTEGER PRIMARY KEY NOT NULL,
    name TEXT NOT NULL,
    description TEXT NOT NULL,
    comment TEXT NOT NULL,
    level INTEGER NOT NULL,
    skill TEXT NOT NULL,
    tool TEXT NOT NULL,
    min_health INTEGER NOT NULL,
    max_health INTEGER NOT NULL,
    harvesttime INTEGER NOT NULL,
    hittime INTEGER NOT NULL,
    respawntime INTEGER NOT NULL
);

-- Create harvestable_drops table
CREATE TABLE harvestable_drops (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    harvestable_id INTEGER NOT NULL,
    item_id INTEGER NOT NULL,
    minamount INTEGER NOT NULL,
    maxamount INTEGER NOT NULL,
    droprate INTEGER NOT NULL,
    droprateboost INTEGER NOT NULL,
    amountboost INTEGER NOT NULL,
    comment TEXT NOT NULL,
    FOREIGN KEY (harvestable_id) REFERENCES harvestables(id),
    FOREIGN KEY (item_id) REFERENCES items(id)
);

CREATE INDEX idx_harvestable_drops_harvestable_id ON harvestable_drops(harvestable_id);
CREATE INDEX idx_harvestable_drops_item_id ON harvestable_drops(item_id);
CREATE INDEX idx_harvestables_skill ON harvestables(skill);
CREATE INDEX idx_harvestables_tool ON harvestables(tool);
CREATE INDEX idx_harvestables_level ON harvestables(level);

