<?php

if (!defined('ABSPATH')) exit;
return [
    'description' => 'Users table v2: status, invite/reset tokens, wp_user_id, last_active, hash_type',
    'up' => [
        "ALTER TABLE {prefix}instinctor_users
            ADD COLUMN status        varchar(20)  NOT NULL DEFAULT 'active' AFTER active,
            ADD COLUMN hash_type     varchar(20)  NOT NULL DEFAULT 'bcrypt'  AFTER password_hash,
            ADD COLUMN invite_token  varchar(64)  NOT NULL DEFAULT ''        AFTER status,
            ADD COLUMN invite_expires datetime    NULL DEFAULT NULL           AFTER invite_token,
            ADD COLUMN reset_token   varchar(64)  NOT NULL DEFAULT ''        AFTER invite_expires,
            ADD COLUMN reset_expires datetime     NULL DEFAULT NULL           AFTER reset_token,
            ADD COLUMN wp_user_id    int unsigned NOT NULL DEFAULT 0         AFTER reset_expires,
            ADD COLUMN last_active   datetime     NULL DEFAULT NULL           AFTER wp_user_id",
        "ALTER TABLE {prefix}instinctor_users
            ADD INDEX invite_token (invite_token),
            ADD INDEX reset_token  (reset_token),
            ADD INDEX wp_user_id   (wp_user_id),
            ADD INDEX status       (status)",
    ],
    'down' => [
        "ALTER TABLE {prefix}instinctor_users
            DROP COLUMN status,
            DROP COLUMN hash_type,
            DROP COLUMN invite_token,
            DROP COLUMN invite_expires,
            DROP COLUMN reset_token,
            DROP COLUMN reset_expires,
            DROP COLUMN wp_user_id,
            DROP COLUMN last_active",
    ],
];
