feat: Anpassung der Datenbankmodelle zur Unterstützung von snake_case und Einführung von freezeTableName
- Aktualisierung der Modelle in verschiedenen Bereichen, um die Feldnamen im snake_case-Format zu verwenden. - Hinzufügen der Option freezeTableName zu den Modellen, um die Tabellennamen in der Datenbank unverändert zu lassen. - Verbesserung der Konsistenz und Lesbarkeit des Codes durch einheitliche Namenskonventionen.
This commit is contained in:
@@ -4,11 +4,11 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class DayProduction extends Model { }
|
||||
|
||||
DayProduction.init({
|
||||
regionId: {
|
||||
region_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
productId: {
|
||||
product_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
@@ -16,16 +16,16 @@ DayProduction.init({
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
producerId: {
|
||||
producer_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
productionTimestamp: {
|
||||
production_timestamp: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
|
||||
},
|
||||
productionDate: {
|
||||
production_date: {
|
||||
type: DataTypes.DATEONLY,
|
||||
allowNull: false,
|
||||
defaultValue: sequelize.literal('CURRENT_DATE'),
|
||||
@@ -41,7 +41,8 @@ DayProduction.init({
|
||||
{
|
||||
unique: true,
|
||||
fields: ['producer_id', 'product_id', 'region_id', 'production_date']
|
||||
}
|
||||
,
|
||||
freezeTableName: true}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class DaySell extends Model { }
|
||||
|
||||
DaySell.init({
|
||||
regionId: {
|
||||
region_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
productId: {
|
||||
product_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
@@ -16,11 +16,11 @@ DaySell.init({
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
sellerId: {
|
||||
seller_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
sellTimestamp: {
|
||||
sell_timestamp: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
|
||||
@@ -36,7 +36,8 @@ DaySell.init({
|
||||
{
|
||||
unique: true,
|
||||
fields: ['seller_id', 'product_id', 'region_id']
|
||||
}
|
||||
,
|
||||
freezeTableName: true}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
@@ -4,19 +4,19 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class ElectionHistory extends Model { }
|
||||
|
||||
ElectionHistory.init({
|
||||
electionId: {
|
||||
election_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
politicalOfficeTypeId: {
|
||||
political_office_type_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
electionDate: {
|
||||
election_date: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
electionResult: {
|
||||
election_result: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false,
|
||||
}
|
||||
@@ -27,6 +27,7 @@ ElectionHistory.init({
|
||||
schema: 'falukant_log',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
,
|
||||
freezeTableName: true});
|
||||
|
||||
export default ElectionHistory;
|
||||
|
||||
@@ -9,11 +9,11 @@ HealthActivity.init({
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
characterId: {
|
||||
character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
activityTr: {
|
||||
activity_tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
@@ -21,7 +21,7 @@ HealthActivity.init({
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
successPercentage: {
|
||||
success_percentage: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
}
|
||||
@@ -32,6 +32,7 @@ HealthActivity.init({
|
||||
schema: 'falukant_log',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
,
|
||||
freezeTableName: true});
|
||||
|
||||
export default HealthActivity;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class MoneyFlow extends Model { }
|
||||
|
||||
MoneyFlow.init({
|
||||
falukantUserId: {
|
||||
falukant_user_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
@@ -12,11 +12,11 @@ MoneyFlow.init({
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
moneyBefore: {
|
||||
money_before: {
|
||||
type: DataTypes.DOUBLE,
|
||||
allowNull: false,
|
||||
},
|
||||
moneyAfter: {
|
||||
money_after: {
|
||||
type: DataTypes.DOUBLE,
|
||||
allowNull: true,
|
||||
},
|
||||
@@ -25,11 +25,11 @@ MoneyFlow.init({
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW
|
||||
},
|
||||
changeValue: {
|
||||
change_value: {
|
||||
type: DataTypes.DOUBLE,
|
||||
allowNull: false,
|
||||
},
|
||||
changedBy: {
|
||||
changed_by: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
@@ -40,6 +40,7 @@ MoneyFlow.init({
|
||||
schema: 'falukant_log',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
,
|
||||
freezeTableName: true});
|
||||
|
||||
export default MoneyFlow;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class Notification extends Model { }
|
||||
|
||||
Notification.init({
|
||||
userId: {
|
||||
user_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
@@ -24,6 +24,7 @@ Notification.init({
|
||||
schema: 'falukant_log',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
,
|
||||
freezeTableName: true});
|
||||
|
||||
export default Notification;
|
||||
|
||||
@@ -5,19 +5,19 @@ class PoliticalOfficeHistory extends Model { }
|
||||
|
||||
PoliticalOfficeHistory.init(
|
||||
{
|
||||
characterId: {
|
||||
character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
officeTypeId: {
|
||||
office_type_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
startDate: {
|
||||
start_date: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
endDate: {
|
||||
end_date: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
}
|
||||
@@ -29,7 +29,8 @@ PoliticalOfficeHistory.init(
|
||||
schema: 'falukant_log',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
}
|
||||
,
|
||||
freezeTableName: true}
|
||||
);
|
||||
|
||||
export default PoliticalOfficeHistory;
|
||||
|
||||
@@ -4,19 +4,19 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class PromotionalGiftLog extends Model { };
|
||||
|
||||
PromotionalGiftLog.init({
|
||||
senderCharacterId: {
|
||||
sender_character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
recipientCharacterId: {
|
||||
recipient_character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
giftId: {
|
||||
gift_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
changeValue: {
|
||||
change_value: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
@@ -27,6 +27,7 @@ PromotionalGiftLog.init({
|
||||
schema: 'falukant_log',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
,
|
||||
freezeTableName: true});
|
||||
|
||||
export default PromotionalGiftLog;
|
||||
Reference in New Issue
Block a user