-- Your SQL goes here

-- ---------------------------
-- Begin - LS_AUTH_ACCOUNT -
-- ---------------------------

create table LS_AUTH_ACCOUNT (
    id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,
    version INT NOT NULL,
    create_time TIMESTAMP(3) NOT NULL,
    update_time TIMESTAMP(3) NOT NULL,
    data JSON NOT NULL
);

CREATE INDEX LS_AUTH_ACCOUNT_UNIQUE_USERNAME
    ON LS_AUTH_ACCOUNT ((JSON_VALUE(DATA, '$.username' RETURNING CHAR(255))));

CREATE INDEX LS_AUTH_ACCOUNT_UNIQUE_EMAIL
    ON LS_AUTH_ACCOUNT ((JSON_VALUE(DATA, '$.email' RETURNING CHAR(255))));

-- End - LS_AUTH_ACCOUNT -


-- -------------------------
-- Begin - LS_AUTH_TOKEN -
-- -------------------------

create table LS_AUTH_TOKEN (
    id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,
    version INT NOT NULL,
    create_time TIMESTAMP(3) NOT NULL,
    update_time TIMESTAMP(3) NOT NULL,
    data JSON NOT NULL
);

CREATE INDEX LS_AUTH_TOKEN_UNIQUE_TOKEN
    ON LS_AUTH_TOKEN ((JSON_VALUE(DATA, '$.token' RETURNING CHAR(255))));

CREATE INDEX LS_AUTH_TOKEN_EXPIRE_AT
    ON LS_AUTH_TOKEN ((JSON_VALUE(DATA, '$.expire_at_epoch_seconds' RETURNING SIGNED)));

-- End - LS_AUTH_TOKEN -