Some extensions and fixes

This commit is contained in:
Torsten Schulz
2025-01-28 09:55:36 +01:00
parent 2f60741116
commit 90b4f51dcb
27 changed files with 910 additions and 53 deletions

View File

@@ -1,49 +1,57 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class FalukantCharacter extends Model {};
class FalukantCharacter extends Model {}
FalukantCharacter.init({
userId: {
type: DataTypes.INTEGER,
allowNull: true,
FalukantCharacter.init(
{
user_id: {
type: DataTypes.INTEGER,
allowNull: true,
},
regionId: {
type: DataTypes.INTEGER,
allowNull: false,
region_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
firstName: {
type: DataTypes.INTEGER,
allowNull: false,
first_name: {
type: DataTypes.INTEGER,
allowNull: false,
},
lastName: {
type: DataTypes.INTEGER,
allowNull: false,
last_name: {
type: DataTypes.INTEGER,
allowNull: false,
},
birthdate: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
gender: {
type: DataTypes.STRING
type: DataTypes.STRING,
},
health: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 100
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 100,
},
titleOfNobility: {
type: DataTypes.INTEGER,
allowNull: false,
type: DataTypes.INTEGER,
allowNull: false,
},
moodId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 1,
}
}, {
},
{
sequelize,
modelName: 'FalukantCharacter',
tableName: 'character',
schema: 'falukant_data',
timestamps: true,
underscored: true,
});
}
);
export default FalukantCharacter;

View File

@@ -0,0 +1,27 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class FalukantCharacterTrait extends Model {}
FalukantCharacterTrait.init(
{
character_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
trait_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
},
{
sequelize,
modelName: 'FalukantCharacterTrait',
tableName: 'falukant_character_trait',
schema: 'falukant_data',
timestamps: false,
underscored: true,
}
);
export default FalukantCharacterTrait;

View File

@@ -0,0 +1,34 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class MarriageProposal extends Model {}
MarriageProposal.init(
{
requesterCharacterId: {
type: DataTypes.INTEGER,
allowNull: false,
onDelete: 'CASCADE',
},
proposedCharacterId: {
type: DataTypes.INTEGER,
allowNull: false,
onDelete: 'CASCADE',
},
cost: {
type: DataTypes.FLOAT,
allowNull: false,
defaultValue: 0,
},
},
{
sequelize,
modelName: 'MarriageProposal',
tableName: 'marriage_proposals',
schema: 'falukant_data',
timestamps: true,
underscored: true,
}
);
export default MarriageProposal;

View File

@@ -19,7 +19,7 @@ Production.init({
startTimestamp: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
}
}, {
sequelize,

View File

@@ -0,0 +1,34 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class TownProductWorth extends Model { }
TownProductWorth.init({
productId: {
type: DataTypes.INTEGER,
allowNull: false,
},
regionId: {
type: DataTypes.INTEGER,
allowNull: false,
},
worthPercent: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
}
}, {
sequelize,
modelName: 'TownProductWorth',
tableName: 'town_product_worth',
schema: 'falukant_data',
timestamps: false,
underscored: true,
hooks: {
beforeCreate: (worthPercent) => {
worthPercent.worthPercent = Math.floor(Math.random() * 20) + 40;
}
}
});
export default TownProductWorth;