--! Previous: sha1:848f1f09a7cd93047aa139d0c4fc203f9ab6ccc4
--! Hash: sha1:d16f7d7c74ee0a1f58ac87a09de124d165088661
--! Message: Player table

--- Table of in-game user data structures.
CREATE TABLE IF NOT EXISTS Player
(
    --- The internal ID associated with this account.
    --- It's separate from the Discord ID associated with this account. This supports a few things:
    ---   1) We can move the game off of Discord, or add the ability to play it as a separate phone app or webapp,
    ---      without losing our database.
    ---   2) If necessary, we can support having multiple Discord users associated with the same user account, to
    ---      support multi-account play.
    ---   3) If necessary, we can support changing the Discord user associated with a user account, if for any reason
    ---      they are no longer using the old account and want to switch to a new account.
    id         SERIAL PRIMARY KEY       NOT NULL,
    --- The user's name, for the purposes of the game. This is completely separate from both their username and nickname
    --- as Discord sees it, though it defaults to their nickname at time of joining. It does not have to be unique, and
    --- can be changed at any time.
    name       VARCHAR(100)             NOT NULL,
    --- The user's gender, for the purposes of the game. This is purely cosmetic and can be changed at any time.
    genderId   VARCHAR(8)               NOT NULL REFERENCES Gender (id) ON DELETE RESTRICT ON UPDATE CASCADE,
    --- The number of units of currency this user is currently carrying.
    currency   INT                      NOT NULL,
    --- The time and date at which this user joined.
    joinedAt   TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
    --- The last time this user used a command.
    lastActive TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
    --- The last time this user retrieved their daily resources.
    lastDaily  TIMESTAMP WITH TIME ZONE          DEFAULT NULL
)
