custom_achievements.sql 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* run with sqlite3 -init "configs/sql-init-scripts/sqlite/custom_achievements.sql" "data/sqlite3/custom-achievements.sq3" */
  2. /* list of achievements */
  3. CREATE TABLE achievements (
  4. achievement_id INTEGER PRIMARY KEY AUTOINCREMENT,
  5. name TEXT NOT NULL,
  6. displaytype INTEGER,
  7. visible BOOLEAN DEFAULT TRUE, /* determines whether or not it's rendered on an achievement page */
  8. CONSTRAINT achievement_name UNIQUE(name)
  9. );
  10. /* per-account achievement status */
  11. CREATE TABLE achievement_status (
  12. achievement_id INTEGER,
  13. steamid3 INTEGER NOT NULL,
  14. achieved INTEGER DEFAULT 0, /* should be time achieved */
  15. metadata TEXT,
  16. CONSTRAINT achievement_user UNIQUE(achievement_id, steamid3)
  17. );
  18. /* localized achievement name and descriptions for display */
  19. /* also to be used in CallOnCustomAchievementAwarded() to print to chat */
  20. CREATE TABLE achievement_languages (
  21. achievement_name TEXT NOT NULL,
  22. language_shortcode TEXT NOT NULL,
  23. achievement_local_name TEXT NOT NULL,
  24. achievement_local_description TEXT,
  25. CONSTRAINT achievement_in_language UNIQUE(achievement_name, language_shortcode)
  26. );
  27. /* automatically create language placeholder entries */
  28. CREATE TRIGGER create_achievement_localizations AFTER INSERT ON achievements BEGIN
  29. INSERT INTO achievement_languages (achievement_name, language_shortcode,
  30. achievement_local_name, achievement_local_description) VALUES
  31. (NEW.name, 'en', NEW.name, NEW.name || '_description');
  32. END;