create or replace table accounteggs
(
    accountId int null,
    eggId     int null
);

create or replace table accountfriend
(
    id         int          not null,
    uuidSource varchar(100) not null,
    uuidTarget varchar(100) not null,
    status     varchar(100) null,
    created    timestamp    null,
    sourceId   int          null,
    targetId   int          null,
    favourite  int          null,
    primary key (id, uuidSource, uuidTarget)
)
    charset = latin1;

create or replace table accountfrienddata
(
    accountId int not null,
    status    int null
);

create or replace table accountignore
(
    id          int auto_increment
        primary key,
    uuidIgnorer varchar(100) not null,
    uuidIgnored varchar(100) not null
)
    charset = latin1;

create or replace table accountinventory
(
    id        int auto_increment
        primary key,
    accountId int not null,
    itemId    int not null,
    count     int not null,
    constraint accountItemIndex
        unique (accountId, itemId)
)
    charset = latin1;

create or replace index itemId
    on accountinventory (itemId);

create or replace table accountkits
(
    accountId int        not null,
    kitId     int        null,
    active    tinyint(1) not null
);

create or replace index accountKitStats
    on accountkits (kitId, accountId);

create or replace table accountkitstats
(
    accountId int    not null,
    kitId     int    not null,
    statId    int    null,
    value     bigint null
);

create or replace table accountpolls
(
    id        int auto_increment,
    accountId int     not null,
    pollId    int     not null,
    value     tinyint not null,
    primary key (id, accountId, pollId)
)
    charset = latin1;

create or replace index accountId
    on accountpolls (accountId);

create or replace index pollId
    on accountpolls (pollId);

create or replace table accountpreferences
(
    id                        int auto_increment,
    uuid                      varchar(256)      not null,
    filterChat                tinyint default 1 not null,
    invisibility              tinyint default 0 not null,
    games                     tinyint default 1 not null,
    visibility                tinyint default 1 not null,
    friendChat                tinyint default 1 not null,
    privateMessaging          tinyint default 1 not null,
    showChat                  tinyint default 1 not null,
    partyRequests             tinyint default 1 not null,
    forcefield                tinyint default 0 not null,
    showMacReports            tinyint default 0 not null,
    ignoreVelocity            tinyint default 0 not null,
    pendingFriendRequests     tinyint default 1 not null,
    friendDisplayInventoryUI  tinyint default 1 not null,
    friendDisplayOnlineStatus tinyint default 1 not null,
    friendDisplayServerName   tinyint default 1 not null,
    friendAllowRequests       tinyint default 1 not null,
    friendAllowMessaging      tinyint default 1 not null,
    language                  varchar(45)       null,
    primary key (id, uuid)
)
    charset = latin1;

create or replace table accountpunishments
(
    id       int auto_increment
        primary key,
    target   varchar(16)                           not null,
    category varchar(100)                          not null,
    sentence varchar(100)                          not null,
    reason   varchar(100)                          not null,
    duration double                                not null,
    admin    varchar(16)                           not null,
    severity int                                   not null,
    time     timestamp default current_timestamp() not null
)
    charset = latin1;

create or replace table accounts
(
    id            int auto_increment,
    uuid          varchar(100)                            not null,
    name          varchar(40)                             not null,
    gems          int         default 2500                null,
    lastLogin     timestamp   default current_timestamp() not null,
    totalPlayTime tinytext                                null,
    gold          int         default 1000                not null,
    coins         int         default 5000                null,
    donorRank     varchar(20)                             null,
    `rank`        varchar(20) default 'ALL'               null,
    rankPerm      tinyint                                 null,
    rankExpire    timestamp   default current_timestamp() not null on update current_timestamp(),
    constraint id
        unique (id)
)
    charset = latin1;

create or replace table accountamplifierthank
(
    accountId   int                                   not null,
    amplifierId int                                   not null,
    time        timestamp default current_timestamp() not null on update current_timestamp(),
    constraint accountamplifierthank_ibfk_1
        foreign key (accountId) references accounts (id)
);

create or replace index accountId
    on accountamplifierthank (accountId);

create or replace table accountauth
(
    id        int          not null,
    accountId int          not null,
    authKey   varchar(128) not null,
    constraint accountauth_ibfk_1
        foreign key (accountId) references accounts (id)
);

create or replace index accountId
    on accountauth (accountId);

create or replace table accountcointransactions
(
    id        int auto_increment
        primary key,
    accountId int          not null,
    reason    varchar(100) null,
    coins     int          null,
    constraint accountCoinTransactions_ibfk_1
        foreign key (accountId) references accounts (id)
)
    charset = latin1;

create or replace index accountId
    on accountcointransactions (accountId);

create or replace table accountcrowns
(
    accountId  int not null
        primary key,
    crownCount int not null,
    constraint accountcrowns_ibfk_1
        foreign key (accountId) references accounts (id)
);

create or replace table accountcustomdata
(
    accountId    int not null,
    customDataId int not null,
    constraint accountcustomdata_ibfk_1
        foreign key (accountId) references accounts (id)
);

create or replace index accountId
    on accountcustomdata (accountId);

create or replace table accountgemtransactions
(
    id        int auto_increment
        primary key,
    accountId int          null,
    reason    varchar(100) null,
    gems      int          null,
    constraint accountGemTransactions_ibfk_1
        foreign key (accountId) references accounts (id)
)
    charset = latin1;

create or replace index accountId
    on accountgemtransactions (accountId);

create or replace table accountpurchases
(
    id               int auto_increment
        primary key,
    accountId        int         not null,
    salesPackageName varchar(30) null,
    salesPackageId   int         null,
    cost             int         null,
    usingCredits     int(1)      null,
    source           varchar(30) null,
    premium          int(1)      null,
    coinPurchase     int(1)      null,
    known            int(1)      not null,
    constraint accountpurchases_ibfk_1
        foreign key (accountId) references accounts (id)
);

create or replace index accountId
    on accountpurchases (accountId);

create or replace table accountranks
(
    id             int auto_increment
        primary key,
    accountId      int         not null,
    rankIdentifier varchar(40) null,
    primaryGroup   tinyint(1)  null,
    constraint additionalIndex
        unique (accountId, rankIdentifier, primaryGroup),
    constraint accountranks_ibfk_1
        foreign key (accountId) references accounts (id)
);

create or replace index accountIndex
    on accountranks (accountId);

create or replace index rankIndex
    on accountranks (rankIdentifier);

create or replace table accountstat
(
    accountId int    not null,
    statId    int    not null,
    value     bigint null,
    primary key (accountId, statId)
)
    charset = latin1;

create or replace index statId
    on accountstat (statId);

create or replace table accountstats
(
    id        int auto_increment
        primary key,
    accountId int              not null,
    statId    int              not null,
    value     bigint default 1 null
)
    charset = latin1;

create or replace index accountId
    on accountstats (accountId);

create or replace index statId
    on accountstats (statId);

create or replace table accountstatsalltime
(
    accountId int null,
    statId    int null,
    value     int null
);

create or replace table accounttasks
(
    id        int auto_increment
        primary key,
    accountId int not null,
    taskId    int not null
)
    charset = latin1;

create or replace index accountId
    on accounttasks (accountId);

create or replace index taskId
    on accounttasks (taskId);

create or replace table accounttransactions
(
    id            int auto_increment
        primary key,
    accountId     int not null,
    transactionId int not null,
    coins         int null,
    gems          int null
)
    charset = latin1;

create or replace index accountId
    on accounttransactions (accountId);

create or replace index transactionId
    on accounttransactions (transactionId);

create or replace table activetournaments
(
    name        varchar(100)     not null
        primary key,
    start_date  date             not null,
    end_date    date             not null,
    is_gamemode int              not null,
    server_id   tinyint unsigned not null
)
    charset = latin1;

create or replace table bonus
(
    accountId int       not null
        primary key,
    dailytime timestamp null,
    ranktime  date      null
)
    charset = latin1;

create or replace table clanserver
(
    id         int auto_increment,
    serverName varchar(100) not null,
    primary key (id, serverName)
)
    charset = latin1;

create or replace table customdata
(
    id   int          not null,
    name varchar(100) not null
);

create or replace table elorating
(
    id            int(10) auto_increment,
    uuid          varchar(256)     not null,
    gamemode      tinyint unsigned not null,
    matchesPlayed int unsigned     not null,
    elo           int              not null,
    gameType      varchar(40)      not null,
    primary key (id, uuid, gamemode)
)
    charset = latin1;

create or replace table fieldblock
(
    id             int auto_increment
        primary key,
    server         varchar(100) null,
    location       varchar(100) null,
    blockId        int          null,
    blockData      tinyint      null,
    emptyId        int          null,
    emptyData      tinyint      null,
    stockMax       int          null,
    stockRegenTime double       null,
    loot           varchar(100) null
)
    charset = latin1;

create or replace table fieldmonster
(
    id      int auto_increment
        primary key,
    server  varchar(100) null,
    name    varchar(100) null,
    type    varchar(100) null,
    mobMax  int          null,
    mobRate double       null,
    center  varchar(100) null,
    radius  int          null,
    height  int          null
)
    charset = latin1;

create or replace table fieldore
(
    id       int auto_increment
        primary key,
    server   varchar(100) null,
    location varchar(100) null
)
    charset = latin1;

create or replace table incognitostaff
(
    accountId int                  not null
        primary key,
    status    tinyint(1) default 0 null
);

create or replace table ipinfo
(
    id        int auto_increment
        primary key,
    ipAddress text not null
)
    charset = latin1;

create or replace table itemcategories
(
    id   int auto_increment
        primary key,
    name varchar(100) null,
    constraint nameIndex
        unique (name)
)
    charset = latin1;

create or replace table items
(
    id         int auto_increment
        primary key,
    name       varchar(100) null,
    categoryId int          null,
    rarity     int          null,
    constraint uniqueNameCategoryIndex
        unique (name, categoryId)
)
    charset = latin1;

create or replace index categoryId
    on items (categoryId);

create or replace table kitpreferences
(
    accountid int null,
    gameid    int null,
    kitid     int null
);

create or replace table kitprogression
(
    uuid          varchar(36) default '1' not null,
    kitId         varchar(64) default '1' not null,
    xp            int                     null,
    upgrade_level int                     null,
    `default`     tinyint                 null
);

create or replace table mail
(
    id        int auto_increment
        primary key,
    accountId int                                   not null,
    sender    varchar(64)                           not null,
    message   varchar(1024)                         not null,
    archived  tinyint                               not null,
    deleted   tinyint                               not null,
    timeSent  timestamp default current_timestamp() not null on update current_timestamp()
)
    charset = latin1;

create or replace index accountId
    on mail (accountId);

create or replace table mailbox
(
    id        int auto_increment
        primary key,
    accountId int                                   null,
    sender    varchar(64)                           null,
    message   varchar(1024)                         null,
    archived  tinyint                               null,
    deleted   tinyint                               null,
    timeSent  timestamp default current_timestamp() not null on update current_timestamp()
)
    charset = latin1;

create or replace index accountId
    on mailbox (accountId);

create or replace table newnpcsnew
(
    id             int   default 0 not null
        primary key,
    name           varchar(255)    null,
    world          varchar(50)     not null,
    x              float           not null,
    y              float           not null,
    z              float           not null,
    helmet         tinytext        null,
    chestplate     tinytext        null,
    leggings       tinytext        null,
    boots          tinytext        null,
    in_hand        tinytext        null,
    info           tinytext        null,
    yaw            float default 1 not null,
    pitch          float default 1 not null,
    in_hand_data   int             null,
    metadata       varchar(32)     null,
    skin_signature varchar(700)    null,
    skin_value     varchar(400)    null,
    entity_type    varchar(32)     null
)
    charset = latin1;

create or replace table npcs
(
    id             int auto_increment,
    server         varchar(50)     not null,
    name           varchar(255)    null,
    world          varchar(50)     not null,
    x              float           not null,
    y              float           not null,
    z              float           not null,
    yaw            float default 1 not null comment '""',
    pitch          float default 1 not null,
    radius         float           not null,
    entityType     varchar(100)    not null,
    entityMeta     varchar(100)    null,
    adult          bit             not null,
    helmet         tinytext        null,
    chestplate     tinytext        null,
    leggings       tinytext        null,
    boots          tinytext        null,
    inhand         tinytext        null,
    info           tinytext        null,
    infoRadius     float           null,
    infoDelay      int             null,
    in_hand_data   int             null,
    entity_type    varchar(32)     null,
    metadata       varchar(32)     null,
    skin_value     varchar(400)    null,
    skin_signature varchar(700)    null,
    constraint id_2
        unique (id)
)
    charset = latin1;

create or replace index id
    on npcs (id);

create or replace index id_3
    on npcs (id);

alter table npcs
    add primary key (id);

create or replace table playerinfo
(
    id      int auto_increment
        primary key,
    uuid    varchar(256) not null,
    name    text         not null,
    version text         not null
)
    charset = latin1;

create or replace table playerips
(
    id           int auto_increment
        primary key,
    playerInfoId int  not null,
    ipInfoId     int  not null,
    date         text not null
)
    charset = latin1;

create or replace table playerloginsessions
(
    id           int auto_increment
        primary key,
    loginTime    text not null,
    playerInfoId int  not null,
    timeInGame   text not null
)
    charset = latin1;

create or replace table playermap
(
    id         int auto_increment,
    playerName varchar(256) not null,
    serverName varchar(256) not null,
    us         tinyint      not null,
    primary key (id, playerName)
)
    charset = latin1;

create or replace table playeruniquelogins
(
    id           int auto_increment
        primary key,
    playerInfoId int  not null,
    day          text not null
)
    charset = latin1;

create or replace table polls
(
    id          int          not null
        primary key,
    enabled     bit          null,
    question    varchar(256) not null,
    answerA     varchar(256) not null,
    answerB     varchar(256) null,
    answerC     varchar(256) null,
    answerD     varchar(256) null,
    coinReward  int          not null,
    displayType int          not null
)
    charset = latin1;

create or replace table preferences
(
    id int not null
);

create or replace table rankbenefits
(
    id        int auto_increment,
    accountId int          null,
    benefit   varchar(100) null,
    constraint id
        unique (id)
)
    charset = latin1;

create or replace index accountId
    on rankbenefits (accountId);

alter table rankbenefits
    add primary key (id);

create or replace table reporthandlers
(
    reportId  int        null,
    handlerId int        null,
    aborted   tinyint(1) null
);

create or replace table reportreasons
(
    reportId   int null,
    reporterId int null,
    reason     int null,
    server     int null,
    weight     int null,
    time       int null
);

create or replace table reportresults
(
    reportId   int null,
    resultId   int null,
    reason     int null,
    closedTime int null
);

create or replace table reports
(
    suspectId    int null,
    categoryId   int null,
    snapshotId   int null,
    assignedTeam int null,
    region       int null,
    id           int null
);

create or replace table reportteammemberships
(
    teamId    int null,
    accountId int null
);

create or replace table servergroupstats
(
    id                   int auto_increment
        primary key,
    serverGroup          varchar(100)         null,
    updated              mediumtext           null,
    players              int                  null,
    maxPlayers           int                  null,
    totalNetworkCpuUsage double(4, 2)         null,
    totalNetworkRamUsage double(4, 2)         null,
    totalCpu             mediumint            null,
    totalRam             mediumint            null,
    US                   tinyint(1) default 1 not null
);

create or replace table serverpassword
(
    id       int auto_increment
        primary key,
    server   varchar(100) null,
    password varchar(100) null
)
    charset = latin1;

create or replace table spawns
(
    id         int auto_increment
        primary key,
    serverName varchar(100) null,
    location   varchar(100) null
)
    charset = latin1;

create or replace table statevents
(
    eventId     int unsigned      not null,
    accountId   int unsigned      not null,
    date        date              not null,
    gamemode    tinyint unsigned  not null,
    serverGroup varchar(100)      not null,
    type        tinyint unsigned  not null,
    value       smallint unsigned not null,
    primary key (eventId, accountId, date, gamemode, serverGroup, type)
)
    charset = latin1;

create or replace table stats
(
    id   int auto_increment,
    name varchar(100) not null,
    primary key (id, name)
)
    charset = latin1;

create or replace table stattypes
(
    id   tinyint(11) auto_increment,
    name varchar(100) not null,
    primary key (id, name)
)
    charset = latin1;

create or replace table tasks
(
    id   int auto_increment,
    name varchar(100) not null,
    primary key (id, name)
)
    charset = latin1;

create or replace table tournamentlb
(
    `rank`    int unsigned not null,
    accountId int unsigned not null,
    value     int unsigned not null,
    primary key (`rank`, accountId)
)
    charset = latin1;

create or replace table transactions
(
    id   int auto_increment
        primary key,
    name varchar(60) not null
)
    charset = latin1;


