CREATE TABLE IF NOT EXISTS guilds (
    id BIGINT PRIMARY KEY NOT NULL,
    name TEXT,
    owner_id BIGINT,
    volume INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS messages (
    id TEXT PRIMARY KEY NOT NULL,
    guild_id BIGINT NOT NULL,
    channel_id BIGINT NOT NULL,
    author_id BIGINT NOT NULL,
    created BIGINT NOT NULL,
    model TEXT NOT NULL,
    request TEXT NOT NULL,
    response TEXT NOT NULL,
    request_tags TEXT[] NOT NULL,
    response_tags TEXT[] NOT NULL
);
CREATE TABLE IF NOT EXISTS dice_rolls (
    id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid()
);
CREATE TABLE IF NOT EXISTS events (
    id UUID PRIMARY KEY NOT NULL,
    guild_id BIGINT NOT NULL,
    author_id BIGINT NOT NULL,
    title TEXT NOT NULL,
    date_time TIMESTAMP NOT NULL,
    description TEXT,
    rsvp BIGINT[] NOT NULL
);
CREATE TABLE IF NOT EXISTS races (
    id INTEGER GENERATED ALWAYS AS IDENTITY,
    name TEXT NOT NULL,
    size TEXT NOT NULL,
    source TEXT NOT NULL,
    data JSON NOT NULL
);
CREATE TABLE IF NOT EXISTS classes (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
CREATE TABLE IF NOT EXISTS feats (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
CREATE TABLE IF NOT EXISTS options_features (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
CREATE TABLE IF NOT EXISTS backgrounds (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
CREATE TABLE IF NOT EXISTS items (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
CREATE TABLE IF NOT EXISTS spells (
    id INTEGER GENERATED ALWAYS AS IDENTITY,
    name TEXT NOT NULL,
    school TEXT NOT NULL,
    level INTEGER NOT NULL,
    ritual BOOLEAN DEFAULT FALSE,
    concentration BOOLEAN DEFAULT FALSE,
    classes TEXT[] NOT NULL,
    damage_inflict TEXT[] NOT NULL,
    damage_resist TEXT[] NOT NULL,
    conditions TEXT[] NOT NULL,
    saving_throw TEXT[] NOT NULL,
    attack_type TEXT,
    data JSONB NOT NULL
);
CREATE TABLE IF NOT EXISTS conditions (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
CREATE TABLE IF NOT EXISTS bestiary (
    id INTEGER GENERATED ALWAYS AS IDENTITY
);
