-- Add migration script here

CREATE TABLE users (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    oidc_id VARCHAR(48) NOT NULL,
    name VARCHAR(128) NOT NULL,

    PRIMARY KEY (id),
    UNIQUE (oidc_id),
    FULLTEXT (name)
);

CREATE TABLE user_tokens (
    id int UNSIGNED NOT NULL AUTO_INCREMENT,
    user_id INT UNSIGNED NOT NULL,
    name VARCHAR(255) NOT NULL,
    hash BINARY(32) NOT NULL,
    PRIMARY KEY (id),
    CONSTRAINT fk_users_app_passords FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
