Files
yourpart3/backend/models/falukant/data/character.js
Torsten Schulz (local) 2b83c45e97
All checks were successful
Deploy to production / deploy (push) Successful in 2m48s
feat(family): enhance family view and character pregnancy handling
- Updated the FalukantCharacter model to include a default scope that excludes pregnancy-related fields for compatibility with older databases.
- Implemented a new method in FalukantService to conditionally retrieve pregnancy information based on database schema.
- Enhanced the FamilyView component to display a summary navigation for family relationships, including partners, children, and lovers.
- Updated internationalization files to include new translations for family-related terms and summaries.
2026-03-30 14:36:02 +02:00

73 lines
1.8 KiB
JavaScript

import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class FalukantCharacter extends Model {}
FalukantCharacter.init(
{
userId: {
type: DataTypes.INTEGER,
allowNull: true},
regionId: {
type: DataTypes.INTEGER,
allowNull: false},
firstName: {
type: DataTypes.INTEGER,
allowNull: false},
lastName: {
type: DataTypes.INTEGER,
allowNull: false},
birthdate: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW},
gender: {
type: DataTypes.STRING},
health: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 100},
titleOfNobility: {
type: DataTypes.INTEGER,
allowNull: false},
moodId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 1}
,
reputation: {
type: DataTypes.INTEGER,
allowNull: false,
// Initialisierung: zufällig 20..80 (Prozent)
// DB-seitig per DEFAULT umgesetzt, damit es auch ohne App-Logic gilt.
defaultValue: sequelize.literal('(floor(random()*61)+20)'),
validate: {
min: 0,
max: 100
}
},
pregnancyDueAt: {
type: DataTypes.DATE,
allowNull: true,
},
pregnancyFatherCharacterId: {
type: DataTypes.INTEGER,
allowNull: true,
}
},
{
sequelize,
modelName: 'FalukantCharacter',
tableName: 'character',
schema: 'falukant_data',
timestamps: true,
underscored: true,
// Spalten erst nach Migration 20260330000000; ohne Exclude würde SELECT/INSERT auf alten DBs fehlschlagen
defaultScope: {
attributes: { exclude: ['pregnancyDueAt', 'pregnancyFatherCharacterId'] },
},
}
);
export default FalukantCharacter;