CREATE TABLE IF NOT EXISTS `users_earnings_claims` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `category` varchar(64) NOT NULL,
  `period_key` varchar(32) NOT NULL,
  `claimed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_earnings_claims_unique_period` (`user_id`, `category`, `period_key`),
  KEY `users_earnings_claims_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO `emulator_settings` (`key`, `value`, `comment`) VALUES
('earnings.enabled', '0', 'Enable the emulator-owned earnings center reward hub.'),
('earnings.daily_gift.enabled', '1', 'Enable daily gift earnings row.'),
('earnings.daily_gift.cooldown.seconds', '86400', 'Cooldown in seconds for daily gift earnings claims.'),
('earnings.daily_gift.credits', '0', 'Credits granted by daily gift earnings claims.'),
('earnings.daily_gift.pixels', '0', 'Pixels granted by daily gift earnings claims.'),
('earnings.daily_gift.points', '0', 'Seasonal points granted by daily gift earnings claims.'),
('earnings.daily_gift.points.type', '5', 'Seasonal point type granted by daily gift earnings claims.'),
('earnings.games.enabled', '1', 'Enable games earnings row.'),
('earnings.games.cooldown.seconds', '86400', 'Cooldown in seconds for games earnings claims.'),
('earnings.games.credits', '0', 'Credits granted by games earnings claims.'),
('earnings.games.pixels', '0', 'Pixels granted by games earnings claims.'),
('earnings.games.points', '0', 'Seasonal points granted by games earnings claims.'),
('earnings.games.points.type', '5', 'Seasonal point type granted by games earnings claims.'),
('earnings.achievements.enabled', '1', 'Enable achievements earnings row.'),
('earnings.achievements.cooldown.seconds', '86400', 'Cooldown in seconds for achievements earnings claims.'),
('earnings.achievements.credits', '0', 'Credits granted by achievements earnings claims.'),
('earnings.achievements.pixels', '0', 'Pixels granted by achievements earnings claims.'),
('earnings.achievements.points', '0', 'Seasonal points granted by achievements earnings claims.'),
('earnings.achievements.points.type', '5', 'Seasonal point type granted by achievements earnings claims.'),
('earnings.marketplace.enabled', '1', 'Enable marketplace earnings row.'),
('earnings.marketplace.cooldown.seconds', '86400', 'Cooldown in seconds for marketplace earnings claims.'),
('earnings.marketplace.credits', '0', 'Credits granted by marketplace earnings claims.'),
('earnings.marketplace.pixels', '0', 'Pixels granted by marketplace earnings claims.'),
('earnings.marketplace.points', '0', 'Seasonal points granted by marketplace earnings claims.'),
('earnings.marketplace.points.type', '5', 'Seasonal point type granted by marketplace earnings claims.'),
('earnings.hc_payday.enabled', '1', 'Enable HC payday earnings row.'),
('earnings.hc_payday.cooldown.seconds', '86400', 'Cooldown in seconds for HC payday earnings claims.'),
('earnings.hc_payday.credits', '0', 'Credits granted by HC payday earnings claims.'),
('earnings.hc_payday.pixels', '0', 'Pixels granted by HC payday earnings claims.'),
('earnings.hc_payday.points', '0', 'Seasonal points granted by HC payday earnings claims.'),
('earnings.hc_payday.points.type', '5', 'Seasonal point type granted by HC payday earnings claims.'),
('earnings.level_progress.enabled', '1', 'Enable level progress earnings row.'),
('earnings.level_progress.cooldown.seconds', '86400', 'Cooldown in seconds for level progress earnings claims.'),
('earnings.level_progress.credits', '0', 'Credits granted by level progress earnings claims.'),
('earnings.level_progress.pixels', '0', 'Pixels granted by level progress earnings claims.'),
('earnings.level_progress.points', '0', 'Seasonal points granted by level progress earnings claims.'),
('earnings.level_progress.points.type', '5', 'Seasonal point type granted by level progress earnings claims.'),
('earnings.donations.enabled', '1', 'Enable donations earnings row.'),
('earnings.donations.cooldown.seconds', '86400', 'Cooldown in seconds for donations earnings claims.'),
('earnings.donations.credits', '0', 'Credits granted by donations earnings claims.'),
('earnings.donations.pixels', '0', 'Pixels granted by donations earnings claims.'),
('earnings.donations.points', '0', 'Seasonal points granted by donations earnings claims.'),
('earnings.donations.points.type', '5', 'Seasonal point type granted by donations earnings claims.'),
('earnings.bonus_bag.enabled', '1', 'Enable bonus bag earnings row.'),
('earnings.bonus_bag.cooldown.seconds', '86400', 'Cooldown in seconds for bonus bag earnings claims.'),
('earnings.bonus_bag.credits', '0', 'Credits granted by bonus bag earnings claims.'),
('earnings.bonus_bag.pixels', '0', 'Pixels granted by bonus bag earnings claims.'),
('earnings.bonus_bag.points', '0', 'Seasonal points granted by bonus bag earnings claims.'),
('earnings.bonus_bag.points.type', '5', 'Seasonal point type granted by bonus bag earnings claims.'),
('earnings.mystery_boxes.enabled', '1', 'Enable mystery boxes earnings row.'),
('earnings.mystery_boxes.cooldown.seconds', '86400', 'Cooldown in seconds for mystery boxes earnings claims.'),
('earnings.mystery_boxes.credits', '0', 'Credits granted by mystery boxes earnings claims.'),
('earnings.mystery_boxes.pixels', '0', 'Pixels granted by mystery boxes earnings claims.'),
('earnings.mystery_boxes.points', '0', 'Seasonal points granted by mystery boxes earnings claims.'),
('earnings.mystery_boxes.points.type', '5', 'Seasonal point type granted by mystery boxes earnings claims.'),
('earnings.club_job.enabled', '1', 'Enable club and job earnings row.'),
('earnings.club_job.cooldown.seconds', '86400', 'Cooldown in seconds for club and job earnings claims.'),
('earnings.club_job.credits', '0', 'Credits granted by club and job earnings claims.'),
('earnings.club_job.pixels', '0', 'Pixels granted by club and job earnings claims.'),
('earnings.club_job.points', '0', 'Seasonal points granted by club and job earnings claims.'),
('earnings.club_job.points.type', '5', 'Seasonal point type granted by club and job earnings claims.');

INSERT IGNORE INTO `emulator_settings` (`key`, `value`, `comment`) VALUES
('earnings.daily_gift.badge', '', 'Badge code granted by daily gift earnings claims.'),
('earnings.daily_gift.item_id', '0', 'Items base id granted by daily gift earnings claims.'),
('earnings.daily_gift.item.quantity', '1', 'Furni quantity granted by daily gift earnings claims.'),
('earnings.daily_gift.hc.days', '0', 'HC days granted by daily gift earnings claims.'),
('earnings.games.badge', '', 'Badge code granted by games earnings claims.'),
('earnings.games.item_id', '0', 'Items base id granted by games earnings claims.'),
('earnings.games.item.quantity', '1', 'Furni quantity granted by games earnings claims.'),
('earnings.games.hc.days', '0', 'HC days granted by games earnings claims.'),
('earnings.achievements.badge', '', 'Badge code granted by achievements earnings claims.'),
('earnings.achievements.item_id', '0', 'Items base id granted by achievements earnings claims.'),
('earnings.achievements.item.quantity', '1', 'Furni quantity granted by achievements earnings claims.'),
('earnings.achievements.hc.days', '0', 'HC days granted by achievements earnings claims.'),
('earnings.marketplace.badge', '', 'Badge code granted by marketplace earnings claims.'),
('earnings.marketplace.item_id', '0', 'Items base id granted by marketplace earnings claims.'),
('earnings.marketplace.item.quantity', '1', 'Furni quantity granted by marketplace earnings claims.'),
('earnings.marketplace.hc.days', '0', 'HC days granted by marketplace earnings claims.'),
('earnings.hc_payday.badge', '', 'Badge code granted by HC payday earnings claims.'),
('earnings.hc_payday.item_id', '0', 'Items base id granted by HC payday earnings claims.'),
('earnings.hc_payday.item.quantity', '1', 'Furni quantity granted by HC payday earnings claims.'),
('earnings.hc_payday.hc.days', '0', 'HC days granted by HC payday earnings claims.'),
('earnings.level_progress.badge', '', 'Badge code granted by level progress earnings claims.'),
('earnings.level_progress.item_id', '0', 'Items base id granted by level progress earnings claims.'),
('earnings.level_progress.item.quantity', '1', 'Furni quantity granted by level progress earnings claims.'),
('earnings.level_progress.hc.days', '0', 'HC days granted by level progress earnings claims.'),
('earnings.donations.badge', '', 'Badge code granted by donations earnings claims.'),
('earnings.donations.item_id', '0', 'Items base id granted by donations earnings claims.'),
('earnings.donations.item.quantity', '1', 'Furni quantity granted by donations earnings claims.'),
('earnings.donations.hc.days', '0', 'HC days granted by donations earnings claims.'),
('earnings.bonus_bag.badge', '', 'Badge code granted by bonus bag earnings claims.'),
('earnings.bonus_bag.item_id', '0', 'Items base id granted by bonus bag earnings claims.'),
('earnings.bonus_bag.item.quantity', '1', 'Furni quantity granted by bonus bag earnings claims.'),
('earnings.bonus_bag.hc.days', '0', 'HC days granted by bonus bag earnings claims.'),
('earnings.mystery_boxes.badge', '', 'Badge code granted by mystery boxes earnings claims.'),
('earnings.mystery_boxes.item_id', '0', 'Items base id granted by mystery boxes earnings claims.'),
('earnings.mystery_boxes.item.quantity', '1', 'Furni quantity granted by mystery boxes earnings claims.'),
('earnings.mystery_boxes.hc.days', '0', 'HC days granted by mystery boxes earnings claims.'),
('earnings.club_job.badge', '', 'Badge code granted by club and job earnings claims.'),
('earnings.club_job.item_id', '0', 'Items base id granted by club and job earnings claims.'),
('earnings.club_job.item.quantity', '1', 'Furni quantity granted by club and job earnings claims.'),
('earnings.club_job.hc.days', '0', 'HC days granted by club and job earnings claims.');

INSERT IGNORE INTO `emulator_settings` (`key`, `value`, `comment`) VALUES
('earnings.daily_gift.native.enabled', '0', 'Use native hotel subsystem data for daily gift earnings claims when available.'),
('earnings.games.native.enabled', '0', 'Use native hotel subsystem data for games earnings claims when available.'),
('earnings.achievements.native.enabled', '1', 'Use achievement score thresholds for achievements earnings claims.'),
('earnings.marketplace.native.enabled', '1', 'Use marketplace sold item payouts for marketplace earnings claims.'),
('earnings.hc_payday.native.enabled', '1', 'Use unclaimed HC payday logs for HC payday earnings claims.'),
('earnings.level_progress.native.enabled', '1', 'Use talent track levels for level progress earnings claims.'),
('earnings.donations.native.enabled', '0', 'Use native hotel subsystem data for donations earnings claims when available.'),
('earnings.bonus_bag.native.enabled', '0', 'Use native hotel subsystem data for bonus bag earnings claims when available.'),
('earnings.mystery_boxes.native.enabled', '0', 'Use native hotel subsystem data for mystery boxes earnings claims when available.'),
('earnings.club_job.native.enabled', '0', 'Use native hotel subsystem data for club and job earnings claims when available.');

INSERT IGNORE INTO `emulator_settings` (`key`, `value`, `comment`) VALUES
('earnings.achievements.min_score', '1', 'Minimum achievement score required before achievements earnings can be claimed.'),
('earnings.achievements.score.step', '100', 'Achievement score bucket size used to prevent repeated claims for the same progress band.'),
('earnings.level_progress.min_level', '1', 'Minimum citizenship/helper talent level required before level progress earnings can be claimed.');
