CREATE TABLE IF NOT EXISTS users (
  telegram_id BIGINT PRIMARY KEY,
  username VARCHAR(255),
  first_name VARCHAR(255),
  balance DECIMAL(15,0) DEFAULT 0,
  state_data TEXT,
  created_at INT,
  updated_at INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS transactions (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id BIGINT,
  amount DECIMAL(15,0),
  type VARCHAR(50), -- credit, debit
  note TEXT,
  created_at INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS pending_requests (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id BIGINT,
  type VARCHAR(50), -- topup, order_receipt
  amount DECIMAL(15,0),
  data TEXT, -- json
  status VARCHAR(50) DEFAULT 'pending', -- pending, approved, rejected
  reason TEXT,
  admin_id BIGINT,
  created_at INT,
  updated_at INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS locks (
  key_name VARCHAR(191) PRIMARY KEY,
  data TEXT,
  updated_at INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
