Skip to content

DB Schema Refactor: UserCore#50

Open
Flicksie wants to merge 25 commits intodevfrom
db-refactor
Open

DB Schema Refactor: UserCore#50
Flicksie wants to merge 25 commits intodevfrom
db-refactor

Conversation

@Flicksie
Copy link
Member

@Flicksie Flicksie commented Mar 7, 2026

This pull request implements a significant refactor of user data storage and access throughout the codebase. The main change is the migration from the old monolithic modules object to a more modular structure, splitting user data into progression, currency, profile, and a dedicated userInventory collection for cosmetics and inventory items. This improves data organization, scalability, and separation of concerns. The changes affect multiple core systems, including achievements, crafting, economy, premium rewards, progression, user profiles, and ventures.

Key changes by theme:

Data Model Refactor:

  • User data previously stored under modules is now split into progression (level, exp), currency (RBN, SPH, etc.), profile (visual settings), and userInventory (cosmetics, inventory). All database reads/writes and in-memory usages are updated accordingly. (core/archetypes/Achievements.js, core/archetypes/Crafter.js, core/archetypes/Economy.js, core/archetypes/Premium.js, core/archetypes/Progression.js, core/archetypes/UserProfileModel.js, core/archetypes/Venture.js, core/commands/_botStaff/lvup.js) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23]

System-Specific Updates:

  • Achievements, Progression, and Leveling: All logic referencing user level or experience now uses progression.level and progression.exp. (core/archetypes/Achievements.js, core/archetypes/Progression.js, core/commands/_botStaff/lvup.js) [1] [2] [3] [4]
  • Economy and Currency: All currency operations (RBN, SPH, etc.) now use the currency object, and related DB updates are refactored. (core/archetypes/Economy.js, core/archetypes/Progression.js, core/archetypes/Venture.js) [1] [2] [3] [4] [5]
  • Crafting and Inventory: Inventory and cosmetics are now managed via the separate userInventory collection, with all related DB operations updated. (core/archetypes/Crafter.js, core/archetypes/Premium.js) [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Premium Rewards: Cosmetic rewards (flairs, medals, stickers) are now handled via userInventory, and premium logic is updated to reflect the new data structure. (core/archetypes/Premium.js) [1] [2] [3] [4] [5] [6] [7]
  • User Profile Model: Profile fields are mapped to the new structure, improving clarity and future extensibility. (core/archetypes/UserProfileModel.js) [1] [2]

This refactor is foundational and will make future development, maintenance, and feature expansion much easier and safer.

Flicksie and others added 25 commits March 6, 2026 08:03
Single-file fallback shim that bridges the old monolithic userdb to
the new split collections. This is the ONLY file in the bot that
references DB._legacyUserDB. Provides getUser, getUserFull,
getUserCosmetics, getUserCosmeticsFull, getUserOAuth, and
translateUpdate helpers. Marks old docs with sunset:true when synced.

Delete this entire file when sunsetting the legacy format.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- onEveryCommand: DB.userDB → DB.users, modules.exp → progression.exp
- globalLevelUp: modules.level → progression.level, modules.exp → progression.exp
- boxDrops: modules.exp → progression.exp

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Updates 9 files in core/archetypes, core/structures, core/utilities:
- Currency: modules.RBN/SPH/JDE/PSM/EVT → currency.*
- Progression: modules.level/exp → progression.*
- Profile: modules.bgID/favcolor/tagline/etc → profile.*
- Donator: .donator reads → .prime?.tier ?? null
- Inventory/cosmetic writes marked with TODO(sunset) for phase 2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Updates 38 command files across economy, social, cosmetics, games,
inventory, beta, infra, misc, pollux, and _botStaff categories:
- Currency: modules.RBN/SPH/JDE/PSM/EVT → currency.*
- Progression: modules.level/exp → progression.*
- Profile: modules.bgID/favcolor/tagline/persotext/etc → profile.*
- Donator: .donator → .prime?.tier
- DB.userDB → DB.users
- Cosmetic/inventory paths annotated with TODO(sunset) for future
  migration to DB.userCosmetics

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- userData.modules.level → userData.progression.level
- userData.modules.bgID → userData.profile.bgID
- userData.modules.favcolor → userData.profile.favcolor
- userData.modules.commend → userData.counters?.commend

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sweep of all remaining modules.inventory, modules.bgInventory,
modules.medalInventory, modules.stickerInventory, modules.skinInventory,
and modules.flairsInventory references across archetypes and commands.

Updated both JS property access and MongoDB query/update paths.
Crafter._modules now constructed from new schema shape (currency +
profile.inventory). Removed TODO(sunset) comments for completed items.

20 files: 3 archetypes + 17 command files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate remaining bot commands from profile.*Inventory to DB.userCosmetics:
- background.js: fix profile.bgID equip write (modules.bgID was wrong)
- openbooster.js: use getFull + cosmeticsDoc.removeItem for boosterpack consumption
- fragment.js: fetch cosmeticsDoc via getFull, use $pull on userCosmetics
- commend.js: add cosmeticsDoc fetch, fix inventory check and removeItem
- vdiff.js: add cosmeticsData fetch, fix all inventory count displays
- marketplace/post.js: parallel fetch + fix inventory ownership checks in AllChecks
- blackjack.js: fix agent-introduced modules.skins.blackjack back to profile.skins.blackjack
- use.js: add cosmeticsDoc fetch, hasItem check goes through cosmeticsDoc
- streakfix.js / streakfix+.js: removeItem now via DB.userCosmetics.getFull

Agent-contributed fixes (verified):
- lootbox_generator.js, any.js, synthBg.js, synthMedal.js
- inventory.js, decks.js, marry.js, blackjack.js (DECK fn)
- Premium.js: split sticker/flair/medal writes to DB.userCosmetics

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…y access

- Rename all DB.userCosmetics references to DB.userInventory
- Fix craft.js to read inventory from user_inventory collection
- Fix streakfix+.js removeItem arg order bug
- Route all addItem/removeItem/hasItem calls through userInventory docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant