Refactor multiple models to remove foreign key references while maintaining required fields, enhancing data integrity and simplifying model definitions.

This commit is contained in:
Torsten Schulz (local)
2025-12-18 16:08:30 +01:00
parent c66fbf1a62
commit c8072b8052
24 changed files with 38 additions and 222 deletions

View File

@@ -17,11 +17,6 @@ Production.init({
weatherTypeId: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: WeatherType,
key: 'id',
schema: 'falukant_type'
},
comment: 'Wetter zum Zeitpunkt der Produktionserstellung'
},
startTimestamp: {

View File

@@ -10,20 +10,11 @@ RegionData.init({
allowNull: false},
regionTypeId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: RegionType,
key: 'id',
schema: 'falukant_type'
}
allowNull: false
},
parentId: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: 'region',
key: 'id',
schema: 'falukant_data'}
allowNull: true
},
map: {
type: DataTypes.JSONB,

View File

@@ -8,21 +8,11 @@ RegionDistance.init(
{
sourceRegionId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: RegionData,
key: 'id',
schema: 'falukant_data',
},
allowNull: false
},
targetRegionId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: RegionData,
key: 'id',
schema: 'falukant_data',
},
allowNull: false
},
transportMode: {
// e.g. 'land', 'water', 'air' should match VehicleType.transportMode

View File

@@ -8,18 +8,10 @@ Relationship.init(
{
character1Id: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: FalukantCharacter,
key: 'id'},
onDelete: 'CASCADE'},
allowNull: false},
character2Id: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: FalukantCharacter,
key: 'id'},
onDelete: 'CASCADE'},
allowNull: false},
relationshipTypeId: {
type: DataTypes.INTEGER,
allowNull: false,

View File

@@ -8,13 +8,6 @@ FalukantUser.init({
userId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: {
tableName: 'user',
schema: 'community'
},
key: 'id'
},
unique: true},
money: {
type: DataTypes.DECIMAL(10, 2),
@@ -38,12 +31,7 @@ FalukantUser.init({
defaultValue: 1},
mainBranchRegionId: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: RegionData,
key: 'id',
schema: 'falukant_data'
}
allowNull: true
},
lastNobilityAdvanceAt: {
type: DataTypes.DATE,

View File

@@ -10,21 +10,11 @@ Weather.init(
regionId: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false,
references: {
model: RegionData,
key: 'id',
schema: 'falukant_data'
}
allowNull: false
},
weatherTypeId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: WeatherType,
key: 'id',
schema: 'falukant_type'
}
allowNull: false
}
},
{