feat(skydiver-profile): add SkydiverProfile MySQL model and service

Introduces the skydiver_profile table as an optional 1-to-1 extension
of the user table, holding skydive-specific fields (licence, poids,
bg_image). Wired up with Sequelize associations and a service with
upsert support. Migration, model, relationships, and service layer
all included.
This commit is contained in:
2026-04-25 22:32:30 +02:00
parent 07de469acb
commit ad7fc4384a
6 changed files with 122 additions and 0 deletions
@@ -0,0 +1,49 @@
const { DataTypes, Model } = require("sequelize");
const sequelize = require("../../config/sequelize");
class SkydiverProfile extends Model {}
const SkydiverProfileModel = () => {
SkydiverProfile.init(
{
userId: {
type: DataTypes.STRING(36),
allowNull: false,
primaryKey: true,
references: {
model: 'user',
key: 'id'
}
},
licence: {
type: DataTypes.INTEGER,
allowNull: true
},
poids: {
type: DataTypes.FLOAT,
allowNull: true
},
bg_image: {
type: DataTypes.STRING(255),
allowNull: true
}
},
{
sequelize,
tableName: 'skydiver_profile',
timestamps: true
}
);
SkydiverProfile.prototype.toJSONFor = function () {
return {
licence: this.licence,
poids: this.poids,
bg_image: this.bg_image || '/assets/images/users/bg_user.jpg'
};
};
return SkydiverProfile;
};
module.exports = SkydiverProfileModel;
+1
View File
@@ -10,6 +10,7 @@ exports.Product = require('./Product');
exports.ProductCategoryXref = require('./ProductCategoryXref');
exports.ProductTagXref = require('./ProductTagXref');
exports.Role = require('./Role');
exports.SkydiverProfile = require('./SkydiverProfile');
exports.Tag = require('./Tag');
exports.TagList = require('./TagList');
exports.User = require('./User');