SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_finance_applications (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  app_code VARCHAR(32) NOT NULL,
  operation VARCHAR(64) NOT NULL,
  wallet_identity VARCHAR(32) NOT NULL DEFAULT '',
  target_user_id VARCHAR(64) NOT NULL,
  coin_amount BIGINT NOT NULL DEFAULT 0,
  recharge_amount DECIMAL(18,2) NOT NULL DEFAULT 0.00,
  credential_image_url VARCHAR(1024) NOT NULL DEFAULT '',
  credential_text TEXT NULL,
  applicant_user_id BIGINT UNSIGNED NOT NULL,
  applicant_name VARCHAR(64) NOT NULL DEFAULT '',
  auditor_user_id BIGINT UNSIGNED NULL,
  auditor_name VARCHAR(64) NOT NULL DEFAULT '',
  status VARCHAR(32) NOT NULL DEFAULT 'pending',
  audit_remark TEXT NULL,
  audited_at_ms BIGINT NULL,
  created_at_ms BIGINT NOT NULL,
  updated_at_ms BIGINT NOT NULL,
  PRIMARY KEY (id),
  KEY idx_admin_finance_app_app_status (app_code, status, created_at_ms),
  KEY idx_admin_finance_app_operation (operation),
  KEY idx_admin_finance_app_target (target_user_id),
  KEY idx_admin_finance_app_applicant (applicant_user_id),
  KEY idx_admin_finance_app_auditor (auditor_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
