
SET @alter_users_sql := IF(
    @has_pin_column = 0,
    'ALTER TABLE users ADD COLUMN pin VARCHAR(20) DEFAULT NULL AFTER password_hash',
    'SELECT 1'
);
PREPARE alter_users_stmt FROM @alter_users_sql;
EXECUTE alter_users_stmt;
DEALLOCATE PREPARE alter_users_stmt;
