ALTER TABLE `users`
  ADD COLUMN IF NOT EXISTS `is_test_account` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否为开发测试实验室账号' AFTER `role`;

SET @test_account_index_exists := (
  SELECT COUNT(*)
  FROM information_schema.statistics
  WHERE table_schema = DATABASE()
    AND table_name = 'users'
    AND index_name = 'idx_users_is_test_account'
);
SET @test_account_index_sql := IF(
  @test_account_index_exists = 0,
  'CREATE INDEX `idx_users_is_test_account` ON `users` (`is_test_account`)',
  'SELECT 1'
);
PREPARE test_account_index_stmt FROM @test_account_index_sql;
EXECUTE test_account_index_stmt;
DEALLOCATE PREPARE test_account_index_stmt;
