feat(auth): migrate Application model from MongoDB to MySQL

- Add Sequelize migration creating the 'application' table
- Add Application Sequelize model with slugify, toJSONFor, toAuthJSON
- Rewrite passport-headerapikey strategy to use DB.Application
- Rewrite applications.routes.js to use Sequelize (findAll, count,
  build/save, destroy) instead of Mongoose
- Fix pre-existing bug: passport was querying { encryptedKey } but the
  stored field is named 'apikey'
- Add Application to MySQL models index and relationships
- Remove Application from Mongoose models index and delete the schema
This commit is contained in:
2026-04-26 18:26:58 +02:00
parent 097e11be1b
commit b3a31e4725
8 changed files with 228 additions and 148 deletions
+3
View File
@@ -1,6 +1,9 @@
const DB = require('../mysql');
const associate = () => {
DB.Application.belongsTo(DB.User, { as: 'author', foreignKey: 'authorId' });
DB.User.hasMany(DB.Application, { as: 'applications', foreignKey: 'authorId', onDelete: 'SET NULL' });
DB.User.hasOne(DB.SkydiverProfile, { as: 'skydiverProfile', foreignKey: 'userId', onDelete: 'CASCADE' });
DB.SkydiverProfile.belongsTo(DB.User, { as: 'user', foreignKey: 'userId' });