Updated models and migrations to new spec

This commit is contained in:
2022-08-17 19:36:47 +02:00
parent bc075805e2
commit 05804cb78a
22 changed files with 336 additions and 86 deletions

View File

@@ -10,22 +10,18 @@ module.exports = (sequelize, DataTypes) => {
* The `models/index` file will call this method automatically.
*/
static associate(models) {
Card.belongsTo(models.Character, {
foreignKey: 'characterID',
as: 'character'
});
Card.belongsTo(models.User, {
foreignKey: 'ownerID',
key: 'userId',
as: 'owner'
});
Card.belongsTo(models.User);
Card.belongsTo(models.Character);
}
}
Card.init({
ownerID: DataTypes.STRING,
identifier: DataTypes.STRING,
characterID: DataTypes.INTEGER,
enabled: { type: DataTypes.BOOLEAN, defaultValue: true }
characterId: DataTypes.INTEGER,
quality: DataTypes.INTEGER,
userId: DataTypes.STRING,
imageHash: DataTypes.STRING,
enabled: { type: DataTypes.BOOLEAN, defaultValue: true },
printNr: DataTypes.INTEGER,
}, {
sequelize,
modelName: 'Card',