fix(skydive): migrate author field from ObjectId to UUID string

- Register SkydiverProfile model in mysql.js (fixes startup crash on association)
- Replace $toObjectId with direct string match in all 12 aggregation queries
- Guard toJSONFor on all Mongo models to fall back to MySQL user.toProfileJSONFor()
  when author is a UUID string (restores username/image in API responses)
- Pass user to toJSONFor() everywhere instead of null
- Remove dead .populate('author') calls (author: String has no ref)
- Fix ownership check in /last route: compare author string to req.payload.id
  instead of the now-absent author.username property
This commit is contained in:
2026-04-26 04:27:47 +02:00
parent da1f9437ab
commit 66821427be
17 changed files with 64 additions and 120 deletions
+2
View File
@@ -16,6 +16,7 @@ const TagModel = require('./models/mysql/Tag');
const TagListModel = require('./models/mysql/TagList');
const UserModel = require('./models/mysql/User');
const UserRoleXrefModel = require('./models/mysql/UserRoleXref');
const SkydiverProfileModel = require('./models/mysql/SkydiverProfile');
const DB = {
sequelize,
@@ -35,6 +36,7 @@ const DB = {
Tag: TagModel(sequelize, DataTypes),
TagList: TagListModel(sequelize, DataTypes),
UserRoleXref: UserRoleXrefModel(sequelize, DataTypes),
SkydiverProfile: SkydiverProfileModel(),
};
module.exports = DB;