-- Items table
CREATE TABLE items (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_items_name ON items(name);

-- NPCs table
CREATE TABLE npcs (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_npcs_name ON npcs(name);

-- Quests table
CREATE TABLE quests (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_quests_name ON quests(name);

-- Harvestables table
CREATE TABLE harvestables (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_harvestables_name ON harvestables(name);

-- Loot tables
CREATE TABLE loot_tables (
    table_id TEXT PRIMARY KEY,
    npc_id TEXT,
    data TEXT NOT NULL
);

CREATE INDEX idx_loot_npc ON loot_tables(npc_id);

-- Maps table
CREATE TABLE maps (
    scene_id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_maps_name ON maps(name);

-- Fast travel locations table
CREATE TABLE fast_travel_locations (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    map_name TEXT NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_fast_travel_name ON fast_travel_locations(name);
CREATE INDEX idx_fast_travel_map ON fast_travel_locations(map_name);

-- Player houses table
CREATE TABLE player_houses (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    map_id INTEGER NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_player_houses_name ON player_houses(name);
CREATE INDEX idx_player_houses_map ON player_houses(map_id);

-- Traits table
CREATE TABLE traits (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    description TEXT,
    trainer_id INTEGER,
    data TEXT NOT NULL
);

CREATE INDEX idx_traits_name ON traits(name);
CREATE INDEX idx_traits_trainer ON traits(trainer_id);

-- Shops table
CREATE TABLE shops (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    unique_items INTEGER NOT NULL,  -- boolean as 0/1
    item_count INTEGER NOT NULL,
    data TEXT NOT NULL
);

CREATE INDEX idx_shops_name ON shops(name);
