Files
Server/data/ddl/15_user_badges.sql
T
azures04 b03f5c91e6 Add badges, checkins, and transport endpoints
Introduce gamification and check-in support plus expanded transport/admin APIs. Added DDL for checkins, badges and user_badges. New repositories: badgeRepository, userBadgeRepository, checkinRepository. New routes: admin badge management, admin transport (lines/platforms/stations), public transport endpoints, user checkins and stations endpoints, and user badges on /me. Services updated: adminService (badge CRUD & user assignment), userService (checkins, badge queries), authService (hasAdminRights). Minor package.json name update. These changes implement database, repo, service and route wiring for badges, user_badins and checkin features and additional transport admin routes.
2026-09-23 02:09:39 +02:00

13 lines
561 B
SQL

CREATE TABLE IF NOT EXISTS `user_badges` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`userId` UUID NOT NULL,
`badgeId` INT UNSIGNED NOT NULL,
`unlockedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY uq_user_badges_user_badge (userId, badgeId),
INDEX idx_user_badges_user (userId),
CONSTRAINT `fk_user_badges_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_user_badges_badgeId` FOREIGN KEY (`badgeId`) REFERENCES `badges` (`id`) ON DELETE CASCADE
);