-- Token tiers: map token_hash to tier (trial, user, member, developer, admin).
-- Used by auth_validate to resolve caller tier for feature policy.
-- Create both unprefixed and ftt_ prefixed.

CREATE TABLE IF NOT EXISTS token_tiers (
  token_hash VARCHAR(64) NOT NULL PRIMARY KEY,
  tier VARCHAR(16) NOT NULL DEFAULT 'user',
  name VARCHAR(255) NULL,
  token_id VARCHAR(32) NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NOT NULL,
  INDEX idx_token_tiers_tier (tier)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS ftt_token_tiers (
  token_hash VARCHAR(64) NOT NULL PRIMARY KEY,
  tier VARCHAR(16) NOT NULL DEFAULT 'user',
  name VARCHAR(255) NULL,
  token_id VARCHAR(32) NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NOT NULL,
  INDEX idx_ftt_token_tiers_tier (tier)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
