diff --git a/backend/config/loadEnv.js b/backend/config/loadEnv.js new file mode 100644 index 0000000..8a51352 --- /dev/null +++ b/backend/config/loadEnv.js @@ -0,0 +1,20 @@ +// Centralized environment loader +import path from 'path'; +import { fileURLToPath } from 'url'; +import dotenv from 'dotenv'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +// Resolve backend/.env regardless of cwd +const envPath = path.resolve(__dirname, '../.env'); +const result = dotenv.config({ path: envPath }); +if (result.error) { + console.warn('[env] Konnte .env nicht laden:', result.error.message); +} else { + if (!process.env.SECRET_KEY) { + console.warn('[env] SECRET_KEY nicht gesetzt in .env'); + } +} + +export {}; diff --git a/backend/controllers/minigamesController.js b/backend/controllers/minigamesController.js index 3739e16..e69de29 100644 --- a/backend/controllers/minigamesController.js +++ b/backend/controllers/minigamesController.js @@ -1,32 +0,0 @@ -import MinigamesService from '../services/minigamesService.js'; - -function extractHashedUserId(req) { - return req.headers?.userid; -} - -class MinigamesController { - constructor() { - this.service = MinigamesService; - - this.listCampaigns = this._wrap((userId, req) => this.service.listCampaigns()); - this.getCampaign = this._wrap((userId, req) => this.service.getCampaign(req.params.code)); - this.getProgress = this._wrap((userId, req) => this.service.getProgress(userId, req.params.code)); - this.saveProgress = this._wrap((userId, req) => this.service.saveProgress(userId, req.params.code, req.body)); - } - - _wrap(fn, { successStatus = 200 } = {}) { - return async (req, res) => { - try { - const userId = extractHashedUserId(req); - if (!userId) return res.status(400).json({ error: 'Missing user identifier' }); - const result = await fn(userId, req, res); - res.status(successStatus).json(result); - } catch (error) { - console.error('Minigames controller error:', error); - res.status(500).json({ error: error.message || 'Internal error' }); - } - }; - } -} - -export default new MinigamesController(); diff --git a/backend/models/associations.js b/backend/models/associations.js index 544ce3d..3173f69 100644 --- a/backend/models/associations.js +++ b/backend/models/associations.js @@ -97,30 +97,15 @@ import Underground from './falukant/data/underground.js'; import UndergroundType from './falukant/type/underground.js'; import Blog from './community/blog.js'; import BlogPost from './community/blog_post.js'; -import MinigameCampaign from './service/minigame_campaign.js'; -import MinigameCampaignLevel from './service/minigame_campaign_level.js'; -import MinigameUserProgress from './service/minigame_user_progress.js'; - -// Match3 Models -import Match3Campaign from './match3/campaign.js'; +import Campaign from './match3/campaign.js'; import Match3Level from './match3/level.js'; -import Match3Objective from './match3/objective.js'; -import Match3UserProgress from './match3/userProgress.js'; -import Match3UserLevelProgress from './match3/userLevelProgress.js'; -import Match3TileType from './match3/tileType.js'; -import Match3LevelTileType from './match3/levelTileType.js'; +import Objective from './match3/objective.js'; +import UserProgress from './match3/userProgress.js'; +import UserLevelProgress from './match3/userLevelProgress.js'; export default function setupAssociations() { // RoomType 1:n Room RoomType.hasMany(Room, { foreignKey: 'roomTypeId', as: 'rooms' }); - // Minigames associations - MinigameCampaign.hasMany(MinigameCampaignLevel, { foreignKey: 'campaign_id', as: 'levels' }); - MinigameCampaignLevel.belongsTo(MinigameCampaign, { foreignKey: 'campaign_id', as: 'campaign' }); - - User.hasMany(MinigameUserProgress, { foreignKey: 'user_id', as: 'minigameProgress' }); - MinigameUserProgress.belongsTo(User, { foreignKey: 'user_id', as: 'user' }); - MinigameCampaign.hasMany(MinigameUserProgress, { foreignKey: 'campaign_id', as: 'userProgress' }); - MinigameUserProgress.belongsTo(MinigameCampaign, { foreignKey: 'campaign_id', as: 'campaign' }); Room.belongsTo(RoomType, { foreignKey: 'roomTypeId', as: 'roomType' }); // ChatUser <-> ChatRight n:m ChatUser.belongsToMany(ChatRight, { @@ -789,77 +774,16 @@ export default function setupAssociations() { BlogPost.belongsTo(User, { foreignKey: 'user_id', as: 'author' }); User.hasMany(BlogPost, { foreignKey: 'user_id', as: 'blogPosts' }); - // Match3 associations - Match3Campaign.hasMany(Match3Level, { - foreignKey: 'campaignId', - as: 'levels' - }); - Match3Level.belongsTo(Match3Campaign, { - foreignKey: 'campaignId', - as: 'campaign' - }); - - Match3Level.hasMany(Match3Objective, { - foreignKey: 'levelId', - as: 'objectives' - }); - Match3Objective.belongsTo(Match3Level, { - foreignKey: 'levelId', - as: 'level' - }); - - Match3Campaign.hasMany(Match3UserProgress, { - foreignKey: 'campaignId', - as: 'userProgress' - }); - Match3UserProgress.belongsTo(Match3Campaign, { - foreignKey: 'campaignId', - as: 'campaign' - }); - - User.hasMany(Match3UserProgress, { - foreignKey: 'userId', - as: 'match3Progress' - }); - Match3UserProgress.belongsTo(User, { - foreignKey: 'userId', - as: 'user' - }); - - Match3UserProgress.hasMany(Match3UserLevelProgress, { - foreignKey: 'userProgressId', - as: 'levelProgress' - }); - Match3UserLevelProgress.belongsTo(Match3UserProgress, { - foreignKey: 'userProgressId', - as: 'userProgress' - }); - - Match3Level.hasMany(Match3UserLevelProgress, { - foreignKey: 'levelId', - as: 'userProgress' - }); - Match3UserLevelProgress.belongsTo(Match3Level, { - foreignKey: 'levelId', - as: 'level' - }); - - // Match3 Tile Type associations - Match3Level.hasMany(Match3LevelTileType, { - foreignKey: 'levelId', - as: 'levelTileTypes' - }); - Match3LevelTileType.belongsTo(Match3Level, { - foreignKey: 'levelId', - as: 'level' - }); - - Match3TileType.hasMany(Match3LevelTileType, { - foreignKey: 'tileTypeId', - as: 'levelTileTypes' - }); - Match3LevelTileType.belongsTo(Match3TileType, { - foreignKey: 'tileTypeId', - as: 'tileType' - }); + // Match3 Campaign & Levels + Campaign.hasMany(Match3Level, { foreignKey: 'campaignId', as: 'levels' }); + Match3Level.belongsTo(Campaign, { foreignKey: 'campaignId', as: 'campaign' }); + Match3Level.hasMany(Objective, { foreignKey: 'levelId', as: 'objectives' }); + Objective.belongsTo(Match3Level, { foreignKey: 'levelId', as: 'level' }); + // User progress tracking + Campaign.hasMany(UserProgress, { foreignKey: 'campaignId', as: 'userProgressEntries' }); + UserProgress.belongsTo(Campaign, { foreignKey: 'campaignId', as: 'campaign' }); + UserProgress.hasMany(UserLevelProgress, { foreignKey: 'userProgressId', as: 'levelProgress' }); + UserLevelProgress.belongsTo(UserProgress, { foreignKey: 'userProgressId', as: 'userProgress' }); + Match3Level.hasMany(UserLevelProgress, { foreignKey: 'levelId', as: 'userLevelProgress' }); + UserLevelProgress.belongsTo(Match3Level, { foreignKey: 'levelId', as: 'level' }); } diff --git a/backend/models/chat/rights.js b/backend/models/chat/rights.js index cf2a42d..939a07d 100644 --- a/backend/models/chat/rights.js +++ b/backend/models/chat/rights.js @@ -5,19 +5,14 @@ const ChatRight = sequelize.define('ChatRight', { id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, + autoIncrement: true}, tr: { type: DataTypes.STRING(32), allowNull: false, - unique: true, - }, -}, { + unique: true}}, { schema: 'chat', tableName: 'rights', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ChatRight; diff --git a/backend/models/chat/room.js b/backend/models/chat/room.js index 9a68239..8409b9a 100644 --- a/backend/models/chat/room.js +++ b/backend/models/chat/room.js @@ -5,55 +5,43 @@ const Room = sequelize.define('Room', { id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, + autoIncrement: true}, title: { type: DataTypes.TEXT, - allowNull: false, - }, - owner_id: { + allowNull: false}, + ownerId: { type: DataTypes.INTEGER, allowNull: true, // kann null sein, wenn system-owned }, - room_type_id: { + roomTypeId: { type: DataTypes.INTEGER, - allowNull: true, - }, - is_public: { + allowNull: true}, + isPublic: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - }, - gender_restriction_id: { + defaultValue: true}, + genderRestrictionId: { type: DataTypes.INTEGER, - allowNull: true, - }, + allowNull: true}, password: { type: DataTypes.STRING, - allowNull: true, - }, - min_age: { + allowNull: true}, + minAge: { type: DataTypes.INTEGER, - allowNull: true, - }, - max_age: { + allowNull: true}, + maxAge: { type: DataTypes.INTEGER, - allowNull: true, - }, - password_hash: { + allowNull: true}, + passwordHash: { type: DataTypes.TEXT, - allowNull: true, - }, - friends_of_owner_only: { + allowNull: true}, + friendsOfOwnerOnly: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: false, - }, - required_user_right_id: { + defaultValue: false}, + requiredUserRightId: { type: DataTypes.INTEGER, - allowNull: true, - }, -}, { + allowNull: true}}, { schema: 'chat', tableName: 'room', timestamps: true, @@ -61,10 +49,7 @@ const Room = sequelize.define('Room', { indexes: [ { name: 'idx_chat_room_owner', - fields: ['owner_id'], - , - freezeTableName: true}, - ], -}); + fields: ['ownerId']}, + ]}); export default Room; diff --git a/backend/models/chat/room_type.js b/backend/models/chat/room_type.js index 56924d6..b40fcad 100644 --- a/backend/models/chat/room_type.js +++ b/backend/models/chat/room_type.js @@ -5,19 +5,14 @@ const RoomType = sequelize.define('RoomType', { id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, + autoIncrement: true}, tr: { type: DataTypes.STRING(32), allowNull: false, - unique: true, - }, -}, { + unique: true}}, { schema: 'chat', tableName: 'room_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default RoomType; diff --git a/backend/models/chat/user.js b/backend/models/chat/user.js index 2bd29ef..8e4a1d1 100644 --- a/backend/models/chat/user.js +++ b/backend/models/chat/user.js @@ -5,38 +5,29 @@ const ChatUser = sequelize.define('ChatUser', { id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - falukant_user_id: { + autoIncrement: true}, + falukantUserId: { type: DataTypes.INTEGER, allowNull: false, - comment: 'Verknüpfung zu community.falukant_user', - }, - display_name: { + comment: 'Verknüpfung zu community.falukant_user'}, + displayName: { type: DataTypes.STRING(64), - allowNull: false, - }, + allowNull: false}, color: { type: DataTypes.STRING(16), // z.B. Hex-Code allowNull: false, - defaultValue: '#000000', - }, - show_gender: { + defaultValue: '#000000'}, + showGender: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - }, - show_age: { + defaultValue: true}, + showAge: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - }, -}, { + defaultValue: true}}, { schema: 'chat', tableName: 'user', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ChatUser; diff --git a/backend/models/chat/user_rights.js b/backend/models/chat/user_rights.js index c9c22ee..e49f3cd 100644 --- a/backend/models/chat/user_rights.js +++ b/backend/models/chat/user_rights.js @@ -4,24 +4,21 @@ import ChatUser from './user.js'; import ChatRight from './rights.js'; const ChatUserRight = sequelize.define('ChatUserRight', { - chat_user_id: { + chatUserId: { type: DataTypes.INTEGER, allowNull: false, primaryKey: true, references: null, // Assoziation wird separat gesetzt }, - chat_right_id: { + chatRightId: { type: DataTypes.INTEGER, allowNull: false, primaryKey: true, references: null, // Assoziation wird separat gesetzt - }, -}, { + }}, { schema: 'chat', tableName: 'user_rights', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ChatUserRight; diff --git a/backend/models/community/blog.js b/backend/models/community/blog.js index 67c9547..3eb9b89 100644 --- a/backend/models/community/blog.js +++ b/backend/models/community/blog.js @@ -4,31 +4,28 @@ import { sequelize } from '../../utils/sequelize.js'; class Blog extends Model {} Blog.init({ - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false, field: 'user_id' }, title: { type: DataTypes.STRING(255), - allowNull: false, - }, + allowNull: false}, description: { type: DataTypes.TEXT, - allowNull: true, - }, + allowNull: true}, // 'public' or 'logged_in' visibility: { type: DataTypes.STRING(20), allowNull: false, - defaultValue: 'public', - }, - age_min: { + defaultValue: 'public'}, + ageMin: { type: DataTypes.INTEGER, allowNull: true, field: 'age_min' }, - age_max: { + ageMax: { type: DataTypes.INTEGER, allowNull: true, field: 'age_max' @@ -36,14 +33,13 @@ Blog.init({ // 'm' | 'f' | null; comma-separated for future-proofing (e.g., 'm,f') genders: { type: DataTypes.STRING(10), - allowNull: true, - }, - created_at: { + allowNull: true}, + createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW, field: 'created_at' }, - updated_at: { + updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW, field: 'updated_at' @@ -54,8 +50,6 @@ Blog.init({ tableName: 'blog', schema: 'community', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Blog; diff --git a/backend/models/community/blog_post.js b/backend/models/community/blog_post.js index 8240f43..2c11398 100644 --- a/backend/models/community/blog_post.js +++ b/backend/models/community/blog_post.js @@ -4,30 +4,28 @@ import { sequelize } from '../../utils/sequelize.js'; class BlogPost extends Model {} BlogPost.init({ - blog_id: { + blogId: { type: DataTypes.INTEGER, allowNull: false, field: 'blog_id' }, - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false, field: 'user_id' }, title: { type: DataTypes.STRING(255), - allowNull: false, - }, + allowNull: false}, content: { type: DataTypes.TEXT, - allowNull: false, - }, - created_at: { + allowNull: false}, + createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW, field: 'created_at' }, - updated_at: { + updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW, field: 'updated_at' @@ -38,8 +36,6 @@ BlogPost.init({ tableName: 'blog_post', schema: 'community', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default BlogPost; diff --git a/backend/models/community/diary.js b/backend/models/community/diary.js index 6fb150b..ee0442b 100644 --- a/backend/models/community/diary.js +++ b/backend/models/community/diary.js @@ -4,30 +4,24 @@ import { sequelize } from '../../utils/sequelize.js'; class Diary extends Model { } Diary.init({ - user_id: { + userId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, text: { type: DataTypes.TEXT, - allowNull: false, - }, - created_at: { + allowNull: false}, + createdAt: { type: DataTypes.DATE, - defaultValue: DataTypes.NOW, - }, - updated_at: { + defaultValue: DataTypes.NOW}, + updatedAt: { type: DataTypes.DATE, - defaultValue: DataTypes.NOW, - } + defaultValue: DataTypes.NOW} }, { sequelize, modelName: 'Diary', tableName: 'diary', schema: 'community', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Diary; diff --git a/backend/models/community/diary_history.js b/backend/models/community/diary_history.js index f6bec3a..7e2dc68 100644 --- a/backend/models/community/diary_history.js +++ b/backend/models/community/diary_history.js @@ -4,34 +4,26 @@ import { sequelize } from '../../utils/sequelize.js'; class DiaryHistory extends Model { } DiaryHistory.init({ - diary_id: { + diaryId: { type: DataTypes.INTEGER, - allowNull: false, - }, - user_id: { + allowNull: false}, + userId: { type: DataTypes.INTEGER, - allowNull: false, - }, - old_text: { + allowNull: false}, + oldText: { type: DataTypes.TEXT, - allowNull: false, - }, - old_created_at: { + allowNull: false}, + oldCreatedAt: { type: DataTypes.DATE, - allowNull: false, - }, - old_updated_at: { + allowNull: false}, + oldUpdatedAt: { type: DataTypes.DATE, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'DiaryHistory', tableName: 'diary_history', schema: 'community', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default DiaryHistory; diff --git a/backend/models/community/folder.js b/backend/models/community/folder.js index f990d97..2c7d1f1 100644 --- a/backend/models/community/folder.js +++ b/backend/models/community/folder.js @@ -5,30 +5,22 @@ import UserParamVisibilityType from '../type/user_param_visibility.js'; const Folder = sequelize.define('folder', { name: { type: DataTypes.STRING, - allowNull: false, - }, - parent_id: { + allowNull: false}, + parentId: { type: DataTypes.INTEGER, allowNull: true, references: { model: 'folder', - key: 'id', - }, - }, - user_id: { + key: 'id'}}, + userId: { type: DataTypes.INTEGER, allowNull: false, references: { model: 'user', - key: 'id', - }, - }, -}, { + key: 'id'}}}, { tableName: 'folder', schema: 'community', underscored: true, - timestamps: true, -, - freezeTableName: true}); + timestamps: true}); export default Folder; diff --git a/backend/models/community/folder_image_visibility.js b/backend/models/community/folder_image_visibility.js index 2505d12..600e1d9 100644 --- a/backend/models/community/folder_image_visibility.js +++ b/backend/models/community/folder_image_visibility.js @@ -8,7 +8,7 @@ const FolderImageVisibility = sequelize.define('folder_image_visibility', { primaryKey: true, allowNull: false }, - folder_id: { + folderId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -16,7 +16,7 @@ const FolderImageVisibility = sequelize.define('folder_image_visibility', { key: 'id' } }, - visibility_type_id: { + visibilityTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -31,8 +31,6 @@ const FolderImageVisibility = sequelize.define('folder_image_visibility', { tableName: 'folder_image_visibility', schema: 'community', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default FolderImageVisibility; diff --git a/backend/models/community/folder_visibility_user.js b/backend/models/community/folder_visibility_user.js index a2593df..eda688d 100644 --- a/backend/models/community/folder_visibility_user.js +++ b/backend/models/community/folder_visibility_user.js @@ -8,7 +8,7 @@ const FolderVisibilityUser = sequelize.define('folder_visibility_user', { primaryKey: true, allowNull: false }, - folder_id: { + folderId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -16,7 +16,7 @@ const FolderVisibilityUser = sequelize.define('folder_visibility_user', { key: 'id' } }, - visibility_user_id: { + visibilityUserId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -28,8 +28,6 @@ const FolderVisibilityUser = sequelize.define('folder_visibility_user', { tableName: 'folder_visibility_user', schema: 'community', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default FolderVisibilityUser; diff --git a/backend/models/community/friendship.js b/backend/models/community/friendship.js index cbce643..5867196 100644 --- a/backend/models/community/friendship.js +++ b/backend/models/community/friendship.js @@ -31,8 +31,6 @@ const Friendship = sequelize.define('friendship', { tableName: 'friendship', schema: 'community', underscored: true, - timestamps: true, -, - freezeTableName: true}); + timestamps: true}); export default Friendship; diff --git a/backend/models/community/guestbook.js b/backend/models/community/guestbook.js index 4612d19..d306f26 100644 --- a/backend/models/community/guestbook.js +++ b/backend/models/community/guestbook.js @@ -7,9 +7,8 @@ const GuestbookEntry = sequelize.define('guestbook_entry', { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true, - allowNull: false, - }, - recipient_id: { + allowNull: false}, + recipientId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -17,7 +16,7 @@ const GuestbookEntry = sequelize.define('guestbook_entry', { key: 'id' } }, - sender_id: { + senderId: { type: DataTypes.INTEGER, allowNull: true, references: { @@ -25,24 +24,18 @@ const GuestbookEntry = sequelize.define('guestbook_entry', { key: 'id' } }, - sender_username: { + senderUsername: { type: DataTypes.STRING, - allowNull: true, - }, - content_html: { + allowNull: true}, + contentHtml: { type: DataTypes.TEXT, - allowNull: false, - }, - image_url: { + allowNull: false}, + imageUrl: { type: DataTypes.STRING, - allowNull: true, - }, -}, { + allowNull: true}}, { tableName: 'guestbook_entry', schema: 'community', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default GuestbookEntry; diff --git a/backend/models/community/image.js b/backend/models/community/image.js index f41a662..b654c3e 100644 --- a/backend/models/community/image.js +++ b/backend/models/community/image.js @@ -5,43 +5,32 @@ import UserParamVisibilityType from '../type/user_param_visibility.js'; const Image = sequelize.define('image', { title: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, description: { type: DataTypes.TEXT, - allowNull: true, - }, - original_file_name: { + allowNull: true}, + originalFileName: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, hash: { type: DataTypes.STRING, allowNull: false, - unique: true, - }, - folder_id: { + unique: true}, + folderId: { type: DataTypes.INTEGER, allowNull: false, references: { model: 'folder', - key: 'id', - }, - }, - user_id: { + key: 'id'}}, + userId: { type: DataTypes.INTEGER, allowNull: false, references: { model: 'user', - key: 'id', - }, - }, -}, { + key: 'id'}}}, { tableName: 'image', schema: 'community', underscored: true, - timestamps: true, -, - freezeTableName: true}); + timestamps: true}); export default Image; diff --git a/backend/models/community/image_image_visibility.js b/backend/models/community/image_image_visibility.js index 2144bf4..27ad316 100644 --- a/backend/models/community/image_image_visibility.js +++ b/backend/models/community/image_image_visibility.js @@ -8,7 +8,7 @@ const ImageImageVisibility = sequelize.define('image_image_visibility', { primaryKey: true, allowNull: false }, - image_id: { + imageId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -16,7 +16,7 @@ const ImageImageVisibility = sequelize.define('image_image_visibility', { key: 'id' } }, - visibility_type_id: { + visibilityTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -31,8 +31,6 @@ const ImageImageVisibility = sequelize.define('image_image_visibility', { tableName: 'image_image_visibility', schema: 'community', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ImageImageVisibility; diff --git a/backend/models/community/image_visibility_user.js b/backend/models/community/image_visibility_user.js index f2a2a08..898f7e4 100644 --- a/backend/models/community/image_visibility_user.js +++ b/backend/models/community/image_visibility_user.js @@ -8,11 +8,11 @@ const ImageVisibilityUser = sequelize.define('image_visibility_user', { primaryKey: true, allowNull: false }, - image_id: { + imageId: { type: DataTypes.INTEGER, allowNull: false }, - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false } @@ -21,7 +21,6 @@ const ImageVisibilityUser = sequelize.define('image_visibility_user', { timestamps: false, underscored: true, schema: 'community' -, - freezeTableName: true}); +}); export default ImageVisibilityUser; diff --git a/backend/models/community/interest.js b/backend/models/community/interest.js index 9a52c75..5173b26 100644 --- a/backend/models/community/interest.js +++ b/backend/models/community/interest.js @@ -6,7 +6,6 @@ const interest = sequelize.define('interest_type', { tableName: 'interest', schema: 'community', underscored: true -, - freezeTableName: true}); +}); export default interest; \ No newline at end of file diff --git a/backend/models/community/user.js b/backend/models/community/user.js index 2583860..3124f9c 100644 --- a/backend/models/community/user.js +++ b/backend/models/community/user.js @@ -36,7 +36,7 @@ const User = sequelize.define('user', { type: DataTypes.STRING, allowNull: false, }, - registration_date: { + registrationDate: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW @@ -45,11 +45,11 @@ const User = sequelize.define('user', { type: DataTypes.BOOLEAN, defaultValue: false }, - reset_token: { + resetToken: { type: DataTypes.UUID, allowNull: true }, - hashed_id: { + hashedId: { type: DataTypes.STRING, allowNull: true }, @@ -57,7 +57,7 @@ const User = sequelize.define('user', { type: DataTypes.BOOLEAN, defaultValue: true }, - auth_code: { + authCode: { type: DataTypes.STRING, allowNull: true } @@ -70,8 +70,7 @@ const User = sequelize.define('user', { const hashedId = crypto.createHash('sha256').update(user.id.toString()).digest('hex'); user.hashedId = hashedId; await user.save(); - , - freezeTableName: true} + }, } }); diff --git a/backend/models/community/user_param.js b/backend/models/community/user_param.js index 54989b1..63b6ef4 100644 --- a/backend/models/community/user_param.js +++ b/backend/models/community/user_param.js @@ -5,7 +5,7 @@ import UserParamType from '../type/user_param.js'; import { encrypt, decrypt } from '../../utils/encryption.js'; const UserParam = sequelize.define('user_param', { - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -13,7 +13,7 @@ const UserParam = sequelize.define('user_param', { key: 'id', }, }, - param_type_id: { + paramTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -54,9 +54,8 @@ const UserParam = sequelize.define('user_param', { indexes: [ { unique: true, - fields: ['user_id', 'param_type_id'], - , - freezeTableName: true}, + fields: ['userId', 'paramTypeId'], + } ], }); diff --git a/backend/models/community/user_param_visibility.js b/backend/models/community/user_param_visibility.js index da8a655..6ee378e 100644 --- a/backend/models/community/user_param_visibility.js +++ b/backend/models/community/user_param_visibility.js @@ -8,7 +8,7 @@ const UserParamVisibility = sequelize.define('user_param_visibility', { primaryKey: true, allowNull: false }, - param_id: { + paramId: { type: DataTypes.INTEGER, allowNull: false }, @@ -21,7 +21,6 @@ const UserParamVisibility = sequelize.define('user_param_visibility', { timestamps: false, underscored: true, schema: 'community' -, - freezeTableName: true}); +}); export default UserParamVisibility; diff --git a/backend/models/community/user_right.js b/backend/models/community/user_right.js index d7a9fe6..d2f8e58 100644 --- a/backend/models/community/user_right.js +++ b/backend/models/community/user_right.js @@ -4,7 +4,7 @@ import User from './user.js'; import UserRightType from '../type/user_right.js'; const UserRight = sequelize.define('user_right', { - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -12,19 +12,16 @@ const UserRight = sequelize.define('user_right', { key: 'id' } }, - right_type_id: { + rightTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { model: UserRightType, key: 'id' } - }, -}, { + }}, { tableName: 'user_right', schema: 'community', - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default UserRight; diff --git a/backend/models/falukant/data/branch.js b/backend/models/falukant/data/branch.js index 2a731e7..d589e58 100644 --- a/backend/models/falukant/data/branch.js +++ b/backend/models/falukant/data/branch.js @@ -4,19 +4,15 @@ import { sequelize } from '../../../utils/sequelize.js'; class Branch extends Model { } Branch.init({ - branch_type_id: { + branchTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, - region_id: { + allowNull: false}, + regionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - falukant_user_id: { + allowNull: false}, + falukantUserId: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'Branch', tableName: 'branch', @@ -26,10 +22,8 @@ Branch.init({ indexes: [ { unique: true, - fields: ['region_id', 'falukant_user_id'] - , - freezeTableName: true} - ], -}); + fields: ['regionId', 'falukantUserId'] + } + ]}); export default Branch; diff --git a/backend/models/falukant/data/buyable_house.js b/backend/models/falukant/data/buyable_house.js index ed71f58..6c49209 100644 --- a/backend/models/falukant/data/buyable_house.js +++ b/backend/models/falukant/data/buyable_house.js @@ -4,38 +4,35 @@ import { sequelize } from '../../../utils/sequelize.js'; class BuyableHouse extends Model { } BuyableHouse.init({ - roof_condition: { + roofCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - floor_condition: { + floorCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - wall_condition: { + wallCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - window_condition: { + windowCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - house_type_id: { + houseTypeId: { type: DataTypes.INTEGER, - allowNull: false, - } + allowNull: false} }, { sequelize, modelName: 'BuyableHouse', tableName: 'buyable_house', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default BuyableHouse; diff --git a/backend/models/falukant/data/buyable_stock.js b/backend/models/falukant/data/buyable_stock.js index 64bfde7..9e4cb88 100644 --- a/backend/models/falukant/data/buyable_stock.js +++ b/backend/models/falukant/data/buyable_stock.js @@ -4,26 +4,20 @@ import { sequelize } from '../../../utils/sequelize.js'; class BuyableStock extends Model { } BuyableStock.init({ - region_id: { + regionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - stock_type_id: { + allowNull: false}, + stockTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quantity: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'BuyableStock', tableName: 'buyable_stock', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default BuyableStock; diff --git a/backend/models/falukant/data/candidate.js b/backend/models/falukant/data/candidate.js index 7ade6db..14da278 100644 --- a/backend/models/falukant/data/candidate.js +++ b/backend/models/falukant/data/candidate.js @@ -8,24 +8,18 @@ Candidate.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - election_id: { + autoIncrement: true}, + electionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - character_id: { + allowNull: false}, + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'Candidate', tableName: 'candidate', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Candidate; diff --git a/backend/models/falukant/data/character.js b/backend/models/falukant/data/character.js index ed513c9..6cc449f 100644 --- a/backend/models/falukant/data/character.js +++ b/backend/models/falukant/data/character.js @@ -5,44 +5,35 @@ class FalukantCharacter extends Model {} FalukantCharacter.init( { - user_id: { + userId: { type: DataTypes.INTEGER, - allowNull: true, - }, - region_id: { + allowNull: true}, + regionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - first_name: { + allowNull: false}, + firstName: { type: DataTypes.INTEGER, - allowNull: false, - }, - last_name: { + allowNull: false}, + lastName: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, birthdate: { type: DataTypes.DATE, allowNull: false, - defaultValue: DataTypes.NOW, - }, + defaultValue: DataTypes.NOW}, gender: { - type: DataTypes.STRING, - }, + type: DataTypes.STRING}, health: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 100, - }, - title_of_nobility: { + defaultValue: 100}, + titleOfNobility: { + type: DataTypes.INTEGER, + allowNull: false}, + moodId: { type: DataTypes.INTEGER, allowNull: false, - }, - mood_id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 1, - } + defaultValue: 1} }, { sequelize, @@ -50,9 +41,7 @@ FalukantCharacter.init( tableName: 'character', schema: 'falukant_data', timestamps: true, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default FalukantCharacter; diff --git a/backend/models/falukant/data/child_relation.js b/backend/models/falukant/data/child_relation.js index 8e21417..1984246 100644 --- a/backend/models/falukant/data/child_relation.js +++ b/backend/models/falukant/data/child_relation.js @@ -5,46 +5,38 @@ class ChildRelation extends Model {} ChildRelation.init( { - father_character_id: { + fatherCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - mother_character_id: { + allowNull: false}, + motherCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - child_character_id: { + allowNull: false}, + childCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - father_name: { + allowNull: false}, + fatherName: { type: DataTypes.STRING, - allowNull: false, - }, - mother_name: { + allowNull: false}, + motherName: { type: DataTypes.STRING, - allowNull: false, - }, - name_set: { + allowNull: false}, + nameSet: { type: DataTypes.BOOLEAN, allowNull: false, - default: false, - }, - is_heir: { + default: false}, + isHeir: { type: DataTypes.BOOLEAN, allowNull: true, - default: false, - } + default: false} }, { sequelize, modelName: 'ChildRelation', tableName: 'child_relation', // exakter Tabellenname schema: 'falukant_data', // exaktes Schema - freezeTableName: true, // keine Pluralisierung + // keine Pluralisierung timestamps: true, - underscored: true, - } + underscored: true} ); export default ChildRelation; diff --git a/backend/models/falukant/data/credit.js b/backend/models/falukant/data/credit.js index 442570a..a1db3c6 100644 --- a/backend/models/falukant/data/credit.js +++ b/backend/models/falukant/data/credit.js @@ -8,31 +8,24 @@ Credit.init({ // aufgenommener Kredit-Betrag amount: { type: DataTypes.DECIMAL(14,2), - allowNull: false, - }, + allowNull: false}, // noch offener Kreditbetrag - remaining_amount: { + remainingAmount: { type: DataTypes.DECIMAL(14,2), - allowNull: false, - }, + allowNull: false}, // Zinssatz als Prozentsatz (z.B. 3.5 für 3.5%) - interest_rate: { + interestRate: { type: DataTypes.DECIMAL(5,2), - allowNull: false, - }, + allowNull: false}, // Verknüpfung auf FalukantUser - falukant_user_id: { + falukantUserId: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'Credit', tableName: 'credit', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Credit; diff --git a/backend/models/falukant/data/debtors_prism.js b/backend/models/falukant/data/debtors_prism.js index 2c41693..99a01f4 100644 --- a/backend/models/falukant/data/debtors_prism.js +++ b/backend/models/falukant/data/debtors_prism.js @@ -5,18 +5,14 @@ class DebtorsPrism extends Model {} DebtorsPrism.init({ // Verknüpfung auf FalukantCharacter - character_id: { + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'DebtorsPrism', tableName: 'debtors_prism', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default DebtorsPrism; diff --git a/backend/models/falukant/data/director.js b/backend/models/falukant/data/director.js index 51cb91e..dcd3d6e 100644 --- a/backend/models/falukant/data/director.js +++ b/backend/models/falukant/data/director.js @@ -4,39 +4,32 @@ import { sequelize } from '../../../utils/sequelize.js'; class Director extends Model { } Director.init({ - director_character_id: { + directorCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - employer_user_id: { + allowNull: false}, + employerUserId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, income: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, satisfaction: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 100, - }, - may_produce: { + defaultValue: 100}, + mayProduce: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - }, - may_sell: { + defaultValue: true}, + maySell: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - }, - may_start_transport: { + defaultValue: true}, + mayStartTransport: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - }, - last_salary_payout: { + defaultValue: true}, + lastSalaryPayout: { type: DataTypes.DATE, allowNull: false, defaultValue: new Date(0) @@ -47,8 +40,6 @@ Director.init({ tableName: 'director', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Director; diff --git a/backend/models/falukant/data/director_proposal.js b/backend/models/falukant/data/director_proposal.js index e70e769..4d4594d 100644 --- a/backend/models/falukant/data/director_proposal.js +++ b/backend/models/falukant/data/director_proposal.js @@ -4,26 +4,20 @@ import { sequelize } from '../../../utils/sequelize.js'; class DirectorProposal extends Model { } DirectorProposal.init({ - director_character_id: { + directorCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - employer_user_id: { + allowNull: false}, + employerUserId: { type: DataTypes.INTEGER, - allowNull: false, - }, - proposed_income: { + allowNull: false}, + proposedIncome: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'DirectorProposal', tableName: 'director_proposal', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default DirectorProposal; diff --git a/backend/models/falukant/data/election.js b/backend/models/falukant/data/election.js index 7def4c3..0b58a05 100644 --- a/backend/models/falukant/data/election.js +++ b/backend/models/falukant/data/election.js @@ -8,32 +8,25 @@ Election.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - office_type_id: { + autoIncrement: true}, + officeTypeId: { type: DataTypes.INTEGER, - allowNull: true, - }, - region_id: { + allowNull: true}, + regionId: { type: DataTypes.INTEGER, allowNull: false }, date: { type: DataTypes.DATE, - allowNull: false, - }, - posts_to_fill: { + allowNull: false}, + postsToFill: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'Election', tableName: 'election', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Election; diff --git a/backend/models/falukant/data/election_result.js b/backend/models/falukant/data/election_result.js index e624c8c..3bad292 100644 --- a/backend/models/falukant/data/election_result.js +++ b/backend/models/falukant/data/election_result.js @@ -8,28 +8,21 @@ ElectionResult.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - election_id: { + autoIncrement: true}, + electionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - candidate_id: { + allowNull: false}, + candidateId: { type: DataTypes.INTEGER, - allowNull: false, - }, - votes_received: { + allowNull: false}, + votesReceived: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'ElectionResult', tableName: 'election_result', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ElectionResult; diff --git a/backend/models/falukant/data/falukant_character_trait.js b/backend/models/falukant/data/falukant_character_trait.js index f6444f2..0991e06 100644 --- a/backend/models/falukant/data/falukant_character_trait.js +++ b/backend/models/falukant/data/falukant_character_trait.js @@ -5,24 +5,19 @@ class FalukantCharacterTrait extends Model {} FalukantCharacterTrait.init( { - character_id: { + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - trait_id: { + allowNull: false}, + traitId: { type: DataTypes.INTEGER, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'FalukantCharacterTrait', tableName: 'falukant_character_trait', schema: 'falukant_data', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default FalukantCharacterTrait; diff --git a/backend/models/falukant/data/inventory.js b/backend/models/falukant/data/inventory.js index 89d251f..6fd0355 100644 --- a/backend/models/falukant/data/inventory.js +++ b/backend/models/falukant/data/inventory.js @@ -4,35 +4,28 @@ import { sequelize } from '../../../utils/sequelize.js'; class Inventory extends Model { } Inventory.init({ - stock_id: { + stockId: { type: DataTypes.INTEGER, - allowNull: false, - }, - product_id: { + allowNull: false}, + productId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quantity: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quality: { type: DataTypes.INTEGER, - allowNull: false, - }, - produced_at: { + allowNull: false}, + producedAt: { type: DataTypes.DATE, allowNull: false, - defaultValue: DataTypes.NOW, - } + defaultValue: DataTypes.NOW} }, { sequelize, modelName: 'Inventory', tableName: 'inventory', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Inventory; diff --git a/backend/models/falukant/data/learning.js b/backend/models/falukant/data/learning.js index 4abff9c..b7a71d5 100644 --- a/backend/models/falukant/data/learning.js +++ b/backend/models/falukant/data/learning.js @@ -5,35 +5,29 @@ class Learning extends Model {} Learning.init( { - learning_recipient_id: { + learningRecipientId: { type: DataTypes.INTEGER, - allowNull: false, - }, - product_id: { + allowNull: false}, + productId: { type: DataTypes.INTEGER, allowNull: true, - defaultValue: null, - }, - learn_all_products: { + defaultValue: null}, + learnAllProducts: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: false, - }, - associated_falukant_user_id: { + defaultValue: false}, + associatedFalukantUserId: { type: DataTypes.INTEGER, allowNull: true, - defaultValue: null, - }, - associated_learning_character_id: { + defaultValue: null}, + associatedLearningCharacterId: { type: DataTypes.INTEGER, allowNull: true, - defaultValue: null, - }, - learning_is_executed: { + defaultValue: null}, + learningIsExecuted: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: false, - } + defaultValue: false} }, { sequelize, @@ -41,9 +35,7 @@ Learning.init( tableName: 'learning', schema: 'falukant_data', timestamps: true, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default Learning; diff --git a/backend/models/falukant/data/marriage_proposal.js b/backend/models/falukant/data/marriage_proposal.js index fd217e7..522cd64 100644 --- a/backend/models/falukant/data/marriage_proposal.js +++ b/backend/models/falukant/data/marriage_proposal.js @@ -5,31 +5,25 @@ class MarriageProposal extends Model {} MarriageProposal.init( { - requester_character_id: { + requesterCharacterId: { type: DataTypes.INTEGER, allowNull: false, - onDelete: 'CASCADE', - }, - proposed_character_id: { + onDelete: 'CASCADE'}, + proposedCharacterId: { type: DataTypes.INTEGER, allowNull: false, - onDelete: 'CASCADE', - }, + onDelete: 'CASCADE'}, cost: { type: DataTypes.FLOAT, allowNull: false, - defaultValue: 0, - }, - }, + defaultValue: 0}}, { sequelize, modelName: 'MarriageProposal', tableName: 'marriage_proposals', schema: 'falukant_data', timestamps: true, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default MarriageProposal; diff --git a/backend/models/falukant/data/occupied_political_office.js b/backend/models/falukant/data/occupied_political_office.js index 7d5f541..650f91b 100644 --- a/backend/models/falukant/data/occupied_political_office.js +++ b/backend/models/falukant/data/occupied_political_office.js @@ -8,24 +8,18 @@ OccupiedPoliticalOffice.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - political_office_id: { + autoIncrement: true}, + politicalOfficeId: { type: DataTypes.INTEGER, - allowNull: false, - }, - character_id: { + allowNull: false}, + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'OccupiedPoliticalOffice', tableName: 'occupied_political_office', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default OccupiedPoliticalOffice; diff --git a/backend/models/falukant/data/party.js b/backend/models/falukant/data/party.js index 38197b4..3f4718f 100644 --- a/backend/models/falukant/data/party.js +++ b/backend/models/falukant/data/party.js @@ -4,27 +4,27 @@ import { sequelize } from '../../../utils/sequelize.js'; class Party extends Model {} Party.init({ - party_type_id: { + partyTypeId: { type: DataTypes.INTEGER, allowNull: false, field: 'party_type_id' }, - falukant_user_id: { + falukantUserId: { type: DataTypes.INTEGER, allowNull: false, field: 'falukant_user_id' }, - music_type_id: { + musicTypeId: { type: DataTypes.INTEGER, allowNull: false, field: 'music_type' }, - banquette_type_id: { + banquetteTypeId: { type: DataTypes.INTEGER, allowNull: false, field: 'banquette_type' }, - servant_ratio: { + servantRatio: { type: DataTypes.INTEGER, allowNull: false, field: 'servant_ratio' @@ -33,15 +33,12 @@ Party.init({ type: DataTypes.FLOAT, allowNull: false, defaultValue: 0 - }, - }, { + }}, { sequelize, modelName: 'Party', tableName: 'party', schema: 'falukant_data', timestamps: true, - underscored: true, - , - freezeTableName: true}); + underscored: true}); export default Party; \ No newline at end of file diff --git a/backend/models/falukant/data/partyInvitedNobility.js b/backend/models/falukant/data/partyInvitedNobility.js index a6e9714..ebc4124 100644 --- a/backend/models/falukant/data/partyInvitedNobility.js +++ b/backend/models/falukant/data/partyInvitedNobility.js @@ -4,12 +4,12 @@ import { sequelize } from '../../../utils/sequelize.js' class PartyInvitedNobility extends Model {} PartyInvitedNobility.init({ - party_id: { + partyId: { type: DataTypes.INTEGER, allowNull: false, field: 'party_id' }, - title_of_nobility_id: { + titleOfNobilityId: { type: DataTypes.INTEGER, allowNull: false, field: 'title_of_nobility_id' @@ -21,7 +21,6 @@ PartyInvitedNobility.init({ schema: 'falukant_data', timestamps: false, underscored: true -, - freezeTableName: true}) +}) export default PartyInvitedNobility diff --git a/backend/models/falukant/data/political_office.js b/backend/models/falukant/data/political_office.js index b1e9bc8..c7d7007 100644 --- a/backend/models/falukant/data/political_office.js +++ b/backend/models/falukant/data/political_office.js @@ -8,28 +8,21 @@ PoliticalOffice.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - office_type_id: { + autoIncrement: true}, + officeTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, - character_id: { + allowNull: false}, + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - region_id: { + allowNull: false}, + regionId: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'PoliticalOffice', tableName: 'political_office', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default PoliticalOffice; diff --git a/backend/models/falukant/data/product_knowledge.js b/backend/models/falukant/data/product_knowledge.js index 46febaa..47c2624 100644 --- a/backend/models/falukant/data/product_knowledge.js +++ b/backend/models/falukant/data/product_knowledge.js @@ -4,19 +4,16 @@ import { sequelize } from '../../../utils/sequelize.js'; class Knowledge extends Model { } Knowledge.init({ - product_id: { + productId: { type: DataTypes.INTEGER, - allowNull: false, - }, - character_id: { + allowNull: false}, + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, knowledge: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 0, - } + defaultValue: 0} }, { sequelize, modelName: 'Knowledge', @@ -27,8 +24,7 @@ Knowledge.init({ hooks: { beforeCreate: (knowledge) => { knowledge.knowledge = Math.floor(Math.random() * 61) + 20; - , - freezeTableName: true} + } } }); diff --git a/backend/models/falukant/data/production.js b/backend/models/falukant/data/production.js index 263390a..ce3f3f3 100644 --- a/backend/models/falukant/data/production.js +++ b/backend/models/falukant/data/production.js @@ -4,31 +4,25 @@ import { sequelize } from '../../../utils/sequelize.js'; class Production extends Model { } Production.init({ - branch_id: { + branchId: { type: DataTypes.INTEGER, - allowNull: false, - }, - product_id: { + allowNull: false}, + productId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quantity: { type: DataTypes.INTEGER, - allowNull: false, - }, - start_timestamp: { + allowNull: false}, + startTimestamp: { type: DataTypes.DATE, allowNull: false, - defaultValue: sequelize.literal('CURRENT_TIMESTAMP'), - } + defaultValue: sequelize.literal('CURRENT_TIMESTAMP')} }, { sequelize, modelName: 'Production', tableName: 'production', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Production; diff --git a/backend/models/falukant/data/region.js b/backend/models/falukant/data/region.js index 781036b..133fbe3 100644 --- a/backend/models/falukant/data/region.js +++ b/backend/models/falukant/data/region.js @@ -7,9 +7,8 @@ class RegionData extends Model { } RegionData.init({ name: { type: DataTypes.STRING, - allowNull: false, - }, - region_type_id: { + allowNull: false}, + regionTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -18,14 +17,13 @@ RegionData.init({ schema: 'falukant_type' } }, - parent_id: { + parentId: { type: DataTypes.INTEGER, allowNull: true, references: { model: 'region', key: 'id', - schema: 'falukant_data', - } + schema: 'falukant_data'} }, map: { type: DataTypes.JSONB, @@ -38,8 +36,6 @@ RegionData.init({ tableName: 'region', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default RegionData; diff --git a/backend/models/falukant/data/relationship.js b/backend/models/falukant/data/relationship.js index 786a7d4..fec1a1e 100644 --- a/backend/models/falukant/data/relationship.js +++ b/backend/models/falukant/data/relationship.js @@ -11,47 +11,36 @@ Relationship.init( allowNull: false, references: { model: FalukantCharacter, - key: 'id', - }, - onDelete: 'CASCADE', - }, + key: 'id'}, + onDelete: 'CASCADE'}, character2Id: { type: DataTypes.INTEGER, allowNull: false, references: { model: FalukantCharacter, - key: 'id', - }, - onDelete: 'CASCADE', - }, - relationship_type_id: { + key: 'id'}, + onDelete: 'CASCADE'}, + relationshipTypeId: { type: DataTypes.INTEGER, allowNull: false, - onDelete: 'CASCADE', - }, + onDelete: 'CASCADE'}, widowFirstName1: { type: DataTypes.STRING, - allowNull: true, - }, + allowNull: true}, widowFirstName2: { type: DataTypes.STRING, - allowNull: true, - }, - next_step_progress: { + allowNull: true}, + nextStepProgress: { type: DataTypes.INTEGER, allowNull: true, - defaultValue: 0, - }, - }, + defaultValue: 0}}, { sequelize, modelName: 'Relationship', tableName: 'relationship', schema: 'falukant_data', timestamps: true, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default Relationship; diff --git a/backend/models/falukant/data/stock.js b/backend/models/falukant/data/stock.js index ac3c122..e95ef8f 100644 --- a/backend/models/falukant/data/stock.js +++ b/backend/models/falukant/data/stock.js @@ -4,27 +4,22 @@ import { sequelize } from '../../../utils/sequelize.js'; class FalukantStock extends Model { } FalukantStock.init({ - branch_id: { + branchId: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 }, - stock_type_id: { + stockTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quantity: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'StockData', tableName: 'stock', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default FalukantStock; diff --git a/backend/models/falukant/data/town_product_worth.js b/backend/models/falukant/data/town_product_worth.js index b062027..e314890 100644 --- a/backend/models/falukant/data/town_product_worth.js +++ b/backend/models/falukant/data/town_product_worth.js @@ -4,19 +4,16 @@ import { sequelize } from '../../../utils/sequelize.js'; class TownProductWorth extends Model { } TownProductWorth.init({ - product_id: { + productId: { + type: DataTypes.INTEGER, + allowNull: false}, + regionId: { + type: DataTypes.INTEGER, + allowNull: false}, + worthPercent: { type: DataTypes.INTEGER, allowNull: false, - }, - region_id: { - type: DataTypes.INTEGER, - allowNull: false, - }, - worth_percent: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 0, - } + defaultValue: 0} }, { sequelize, modelName: 'TownProductWorth', @@ -27,8 +24,7 @@ TownProductWorth.init({ hooks: { beforeCreate: (worthPercent) => { worthPercent.worthPercent = Math.floor(Math.random() * 20) + 40; - , - freezeTableName: true} + } } }); diff --git a/backend/models/falukant/data/underground.js b/backend/models/falukant/data/underground.js index 38cc25b..eb757e3 100644 --- a/backend/models/falukant/data/underground.js +++ b/backend/models/falukant/data/underground.js @@ -4,34 +4,27 @@ import { sequelize } from '../../../utils/sequelize.js'; class Underground extends Model { } Underground.init({ - underground_type_id: { + undergroundTypeId: { type: DataTypes.STRING, - allowNull: false, - }, - performer_id: { + allowNull: false}, + performerId: { type: DataTypes.INTEGER, - allowNull: false, - }, - victim_id: { + allowNull: false}, + victimId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, parameters: { type: DataTypes.JSON, - allowNull: true, - }, + allowNull: true}, result: { type: DataTypes.JSON, - allowNull: true, - } + allowNull: true} }, { sequelize, modelName: 'Underground', tableName: 'underground', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Underground; diff --git a/backend/models/falukant/data/user.js b/backend/models/falukant/data/user.js index 0afde73..5c16dc3 100644 --- a/backend/models/falukant/data/user.js +++ b/backend/models/falukant/data/user.js @@ -5,7 +5,7 @@ import RegionData from './region.js'; class FalukantUser extends Model { } FalukantUser.init({ - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -15,34 +15,28 @@ FalukantUser.init({ }, key: 'id' }, - unique: true, - }, + unique: true}, money: { type: DataTypes.DECIMAL(10, 2), allowNull: false, - defaultValue: 0.00, - }, - credit_amount: { + defaultValue: 0.00}, + creditAmount: { type: DataTypes.DECIMAL(10, 2), allowNull: false, - defaultValue: 0.00, - }, - today_credit_taken: { + defaultValue: 0.00}, + todayCreditTaken: { type: DataTypes.DECIMAL(10, 2), allowNull: false, - defaultValue: 0.00, - }, - credit_interest_rate: { + defaultValue: 0.00}, + creditInterestRate: { type: DataTypes.DECIMAL(5, 2), allowNull: false, - defaultValue: 0.00, - }, + defaultValue: 0.00}, certificate: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 1, - }, - main_branch_region_id: { + defaultValue: 1}, + mainBranchRegionId: { type: DataTypes.INTEGER, allowNull: true, references: { @@ -57,8 +51,6 @@ FalukantUser.init({ tableName: 'falukant_user', schema: 'falukant_data', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default FalukantUser; diff --git a/backend/models/falukant/data/user_house.js b/backend/models/falukant/data/user_house.js index 6053560..f9b9ff5 100644 --- a/backend/models/falukant/data/user_house.js +++ b/backend/models/falukant/data/user_house.js @@ -4,32 +4,32 @@ import { sequelize } from '../../../utils/sequelize.js'; class UserHouse extends Model { } UserHouse.init({ - roof_condition: { + roofCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - floor_condition: { + floorCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - wall_condition: { + wallCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - window_condition: { + windowCondition: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 100 }, - house_type_id: { + houseTypeId: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 1 }, - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 1 @@ -40,8 +40,6 @@ UserHouse.init({ tableName: 'user_house', schema: 'falukant_data', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default UserHouse; diff --git a/backend/models/falukant/data/vote.js b/backend/models/falukant/data/vote.js index 2da1868..13ce6af 100644 --- a/backend/models/falukant/data/vote.js +++ b/backend/models/falukant/data/vote.js @@ -9,26 +9,20 @@ Vote.init( id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - election_id: { + autoIncrement: true}, + electionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - candidate_id: { + allowNull: false}, + candidateId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, timestamp: { type: DataTypes.DATE, allowNull: false, - defaultValue: DataTypes.NOW, - }, - falukant_user_id: { + defaultValue: DataTypes.NOW}, + falukantUserId: { type: DataTypes.INTEGER, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'Vote', @@ -39,11 +33,8 @@ Vote.init( indexes: [ { unique: true, - fields: ['election_id', 'candidate_id'], - , - freezeTableName: true}, - ], - } + fields: ['electionId', 'candidateId']}, + ]} ); export default Vote; diff --git a/backend/models/falukant/log/dayproduction.js b/backend/models/falukant/log/dayproduction.js index ef8f777..1e42c1b 100644 --- a/backend/models/falukant/log/dayproduction.js +++ b/backend/models/falukant/log/dayproduction.js @@ -4,32 +4,26 @@ import { sequelize } from '../../../utils/sequelize.js'; class DayProduction extends Model { } DayProduction.init({ - region_id: { + regionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - product_id: { + allowNull: false}, + productId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quantity: { type: DataTypes.INTEGER, - allowNull: false, - }, - producer_id: { + allowNull: false}, + producerId: { type: DataTypes.INTEGER, - allowNull: false, - }, - production_timestamp: { + allowNull: false}, + productionTimestamp: { type: DataTypes.DATE, allowNull: false, - defaultValue: sequelize.literal('CURRENT_TIMESTAMP'), - }, - production_date: { + defaultValue: sequelize.literal('CURRENT_TIMESTAMP')}, + productionDate: { type: DataTypes.DATEONLY, allowNull: false, - defaultValue: sequelize.literal('CURRENT_DATE'), - } + defaultValue: sequelize.literal('CURRENT_DATE')} }, { sequelize, modelName: 'DayProduction', @@ -40,9 +34,8 @@ DayProduction.init({ indexes: [ { unique: true, - fields: ['producer_id', 'product_id', 'region_id', 'production_date'] - , - freezeTableName: true} + fields: ['producerId', 'productId', 'regionId', 'productionDate'] + } ] }); diff --git a/backend/models/falukant/log/daysell.js b/backend/models/falukant/log/daysell.js index 89e4a9d..f150554 100644 --- a/backend/models/falukant/log/daysell.js +++ b/backend/models/falukant/log/daysell.js @@ -4,27 +4,22 @@ import { sequelize } from '../../../utils/sequelize.js'; class DaySell extends Model { } DaySell.init({ - region_id: { + regionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - product_id: { + allowNull: false}, + productId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, quantity: { type: DataTypes.INTEGER, - allowNull: false, - }, - seller_id: { + allowNull: false}, + sellerId: { type: DataTypes.INTEGER, - allowNull: false, - }, - sell_timestamp: { + allowNull: false}, + sellTimestamp: { type: DataTypes.DATE, allowNull: false, - defaultValue: sequelize.literal('CURRENT_TIMESTAMP'), - } + defaultValue: sequelize.literal('CURRENT_TIMESTAMP')} }, { sequelize, modelName: 'DaySell', @@ -35,9 +30,8 @@ DaySell.init({ indexes: [ { unique: true, - fields: ['seller_id', 'product_id', 'region_id'] - , - freezeTableName: true} + fields: ['sellerId', 'productId', 'regionId'] + } ] }); diff --git a/backend/models/falukant/log/election_history.js b/backend/models/falukant/log/election_history.js index 97fa84a..e42fd47 100644 --- a/backend/models/falukant/log/election_history.js +++ b/backend/models/falukant/log/election_history.js @@ -4,30 +4,24 @@ import { sequelize } from '../../../utils/sequelize.js'; class ElectionHistory extends Model { } ElectionHistory.init({ - election_id: { + electionId: { type: DataTypes.INTEGER, - allowNull: false, - }, - political_office_type_id: { + allowNull: false}, + politicalOfficeTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, - election_date: { + allowNull: false}, + electionDate: { type: DataTypes.DATE, - allowNull: false, - }, - election_result: { + allowNull: false}, + electionResult: { type: DataTypes.JSON, - allowNull: false, - } + allowNull: false} }, { sequelize, modelName: 'ElectionHistory', tableName: 'election_history', schema: 'falukant_log', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ElectionHistory; diff --git a/backend/models/falukant/log/health_activity.js b/backend/models/falukant/log/health_activity.js index 859d833..89a332a 100644 --- a/backend/models/falukant/log/health_activity.js +++ b/backend/models/falukant/log/health_activity.js @@ -7,21 +7,17 @@ HealthActivity.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - character_id: { + autoIncrement: true}, + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - activity_tr: { + allowNull: false}, + activityTr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, cost: { type: DataTypes.FLOAT, - allowNull: false, - }, - success_percentage: { + allowNull: false}, + successPercentage: { type: DataTypes.INTEGER, allowNull: false } @@ -31,8 +27,6 @@ HealthActivity.init({ tableName: 'health_activity', schema: 'falukant_log', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default HealthActivity; diff --git a/backend/models/falukant/log/moneyflow.js b/backend/models/falukant/log/moneyflow.js index e13074d..a6cc4cb 100644 --- a/backend/models/falukant/log/moneyflow.js +++ b/backend/models/falukant/log/moneyflow.js @@ -4,43 +4,34 @@ import { sequelize } from '../../../utils/sequelize.js'; class MoneyFlow extends Model { } MoneyFlow.init({ - falukant_user_id: { + falukantUserId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, activity: { type: DataTypes.STRING, - allowNull: false, - }, - money_before: { + allowNull: false}, + moneyBefore: { type: DataTypes.DOUBLE, - allowNull: false, - }, - money_after: { + allowNull: false}, + moneyAfter: { type: DataTypes.DOUBLE, - allowNull: true, - }, + allowNull: true}, time: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, - change_value: { + changeValue: { type: DataTypes.DOUBLE, - allowNull: false, - }, - changed_by: { + allowNull: false}, + changedBy: { type: DataTypes.INTEGER, - allowNull: true, - }, -}, { + allowNull: true}}, { sequelize, modelName: 'MoneyFlow', tableName: 'moneyflow', schema: 'falukant_log', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default MoneyFlow; diff --git a/backend/models/falukant/log/notification.js b/backend/models/falukant/log/notification.js index 70dd6bf..f4bcf6e 100644 --- a/backend/models/falukant/log/notification.js +++ b/backend/models/falukant/log/notification.js @@ -4,27 +4,21 @@ import { sequelize } from '../../../utils/sequelize.js'; class Notification extends Model { } Notification.init({ - user_id: { + userId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, tr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, shown: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: false, - }, -}, { + defaultValue: false}}, { sequelize, modelName: 'Notification', tableName: 'notification', schema: 'falukant_log', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default Notification; diff --git a/backend/models/falukant/log/political_office_history.js b/backend/models/falukant/log/political_office_history.js index d11385c..06eb6d7 100644 --- a/backend/models/falukant/log/political_office_history.js +++ b/backend/models/falukant/log/political_office_history.js @@ -5,22 +5,18 @@ class PoliticalOfficeHistory extends Model { } PoliticalOfficeHistory.init( { - character_id: { + characterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - office_type_id: { + allowNull: false}, + officeTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, - start_date: { + allowNull: false}, + startDate: { type: DataTypes.DATE, - allowNull: false, - }, - end_date: { + allowNull: false}, + endDate: { type: DataTypes.DATE, - allowNull: false, - } + allowNull: false} }, { sequelize, @@ -28,9 +24,7 @@ PoliticalOfficeHistory.init( tableName: 'political_office_history', schema: 'falukant_log', timestamps: true, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default PoliticalOfficeHistory; diff --git a/backend/models/falukant/log/promotional_gift.js b/backend/models/falukant/log/promotional_gift.js index a93f141..fa10248 100644 --- a/backend/models/falukant/log/promotional_gift.js +++ b/backend/models/falukant/log/promotional_gift.js @@ -4,30 +4,23 @@ import { sequelize } from '../../../utils/sequelize.js'; class PromotionalGiftLog extends Model { }; PromotionalGiftLog.init({ - sender_character_id: { + senderCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - recipient_character_id: { + allowNull: false}, + recipientCharacterId: { type: DataTypes.INTEGER, - allowNull: false, - }, - gift_id: { + allowNull: false}, + giftId: { type: DataTypes.INTEGER, - allowNull: false, - }, - change_value: { + allowNull: false}, + changeValue: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'PromotionalGiftLog', tableName: 'promotional_gift', schema: 'falukant_log', timestamps: true, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default PromotionalGiftLog; \ No newline at end of file diff --git a/backend/models/falukant/predefine/firstname.js b/backend/models/falukant/predefine/firstname.js index 9e87a17..086d05e 100644 --- a/backend/models/falukant/predefine/firstname.js +++ b/backend/models/falukant/predefine/firstname.js @@ -19,9 +19,7 @@ const FalukantPredefineFirstname = sequelize.define('firstname', { { unique: true, fields: ['name', 'gender'] - , - freezeTableName: true} - ], -}); + } + ]}); export default FalukantPredefineFirstname; \ No newline at end of file diff --git a/backend/models/falukant/predefine/lastname.js b/backend/models/falukant/predefine/lastname.js index cc19eba..2c39943 100644 --- a/backend/models/falukant/predefine/lastname.js +++ b/backend/models/falukant/predefine/lastname.js @@ -6,8 +6,7 @@ const FalukantPredefineLastname = sequelize.define('lastname', { type: DataTypes.STRING, length: 1, allowNull: false - }, -}, { + }}, { tableName: 'lastname', schema: 'falukant_predefine', underscored: true, @@ -16,9 +15,7 @@ const FalukantPredefineLastname = sequelize.define('lastname', { { unique: true, fields: ['name'] - , - freezeTableName: true} - ], -}); + } + ]}); export default FalukantPredefineLastname; \ No newline at end of file diff --git a/backend/models/falukant/predefine/political_office_benefit.js b/backend/models/falukant/predefine/political_office_benefit.js index 5f475b5..cde1dff 100644 --- a/backend/models/falukant/predefine/political_office_benefit.js +++ b/backend/models/falukant/predefine/political_office_benefit.js @@ -9,29 +9,22 @@ PoliticalOfficeBenefit.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, - political_office_id: { + autoIncrement: true}, + politicalOfficeId: { type: DataTypes.INTEGER, - allowNull: false, - }, - benefit_type_id: { + allowNull: false}, + benefitTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, value: { type: DataTypes.JSONB, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'PoliticalOfficeBenefit', tableName: 'political_office_benefit', schema: 'falukant_predefine', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); // Association PoliticalOfficeBenefit.belongsTo(PoliticalOfficeBenefitType, { diff --git a/backend/models/falukant/predefine/political_office_prerequisite.js b/backend/models/falukant/predefine/political_office_prerequisite.js index dd812f7..bc85918 100644 --- a/backend/models/falukant/predefine/political_office_prerequisite.js +++ b/backend/models/falukant/predefine/political_office_prerequisite.js @@ -9,27 +9,22 @@ PoliticalOfficePrerequisite.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, + autoIncrement: true}, // Neu: Feld heißt jetzt eindeutig "office_type_id" - office_type_id: { + officeTypeId: { type: DataTypes.INTEGER, - allowNull: false, - }, + field: 'office_type_id', + allowNull: false}, prerequisite: { type: DataTypes.JSONB, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'PoliticalOfficePrerequisite', tableName: 'political_office_prerequisite', schema: 'falukant_predefine', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default PoliticalOfficePrerequisite; diff --git a/backend/models/falukant/predefine/promotional_gift_character_trait.js b/backend/models/falukant/predefine/promotional_gift_character_trait.js index 796b97f..d15eb8d 100644 --- a/backend/models/falukant/predefine/promotional_gift_character_trait.js +++ b/backend/models/falukant/predefine/promotional_gift_character_trait.js @@ -5,33 +5,26 @@ import CharacterTrait from '../type/character_trait.js'; class PromotionalGiftCharacterTrait extends Model {} -PromotionalGiftCharacterTrait.init( +PromotionalGiftCharacterTrait.init( { - gift_id: { + giftId: { type: DataTypes.INTEGER, - references: { - model: PromotionalGift, - key: 'id', - }, - allowNull: false, + field: 'gift_id', + references: { model: PromotionalGift, key: 'id' }, + allowNull: false }, - trait_id: { + traitId: { type: DataTypes.INTEGER, - references: { - model: CharacterTrait, - key: 'id', - }, - allowNull: false, + field: 'trait_id', + references: { model: CharacterTrait, key: 'id' }, + allowNull: false }, suitability: { type: DataTypes.INTEGER, allowNull: false, validate: { min: 1, - max: 5, - }, - }, - }, + max: 5}}}, { sequelize, modelName: 'PromotionalGiftCharacterTrait', @@ -39,8 +32,9 @@ PromotionalGiftCharacterTrait.init( schema: 'falukant_predefine', timestamps: false, underscored: true, - , - freezeTableName: true} + indexes: [ + { unique: true, fields: ['gift_id','trait_id'] } + ]} ); - + export default PromotionalGiftCharacterTrait; diff --git a/backend/models/falukant/predefine/promotional_gift_mood.js b/backend/models/falukant/predefine/promotional_gift_mood.js index 42f82f8..3e479e9 100644 --- a/backend/models/falukant/predefine/promotional_gift_mood.js +++ b/backend/models/falukant/predefine/promotional_gift_mood.js @@ -7,40 +7,44 @@ class PromotionalGiftMood extends Model {} PromotionalGiftMood.init( { - gift_id: { + giftId: { type: DataTypes.INTEGER, + field: 'gift_id', references: { model: PromotionalGift, - key: 'id', + key: 'id' }, - allowNull: false, + allowNull: false }, - mood_id: { + moodId: { type: DataTypes.INTEGER, + field: 'mood_id', references: { model: Mood, - key: 'id', + key: 'id' }, - allowNull: false, + allowNull: false }, suitability: { type: DataTypes.INTEGER, allowNull: false, validate: { min: 1, - max: 5, - }, - }, - }, + max: 5}}}, { sequelize, - modelName: 'PromotionalGiftMood', + modelName: 'PromotionalGiftMood', tableName: 'promotional_gift_mood', schema: 'falukant_predefine', timestamps: false, underscored: true, - , - freezeTableName: true} + indexes: [ + { + unique: true, + fields: ['gift_id', 'mood_id'] + } + ] + } ); export default PromotionalGiftMood; diff --git a/backend/models/falukant/type/banquette.js b/backend/models/falukant/type/banquette.js index e1e97d5..133c13d 100644 --- a/backend/models/falukant/type/banquette.js +++ b/backend/models/falukant/type/banquette.js @@ -7,26 +7,20 @@ BanquetteType.init( { tr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, cost: { type: DataTypes.INTEGER, - allowNull: false, - }, - reputation_growth: { + allowNull: false}, + reputationGrowth: { type: DataTypes.INTEGER, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'BanquetteType', tableName: 'banquette', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default BanquetteType; diff --git a/backend/models/falukant/type/branch.js b/backend/models/falukant/type/branch.js index 5776f1b..74709a3 100644 --- a/backend/models/falukant/type/branch.js +++ b/backend/models/falukant/type/branch.js @@ -4,14 +4,12 @@ import { sequelize } from '../../../utils/sequelize.js'; class BranchType extends Model { } BranchType.init({ - label_tr: { + labelTr: { type: DataTypes.STRING, - allowNull: false, - }, - base_cost: { + allowNull: false}, + baseCost: { type: DataTypes.INTEGER, - allowNull: false, - } + allowNull: false} }, { sequelize, modelName: 'BranchType', @@ -22,10 +20,8 @@ BranchType.init({ indexes: [ { unique: true, - fields: ['label_tr'] - , - freezeTableName: true} - ], -}); + fields: ['labelTr'] + } + ]}); export default BranchType; diff --git a/backend/models/falukant/type/character_trait.js b/backend/models/falukant/type/character_trait.js index dfd7b7e..147d0bb 100644 --- a/backend/models/falukant/type/character_trait.js +++ b/backend/models/falukant/type/character_trait.js @@ -7,18 +7,14 @@ CharacterTrait.init( { tr: { type: DataTypes.STRING, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'CharacterTrait', tableName: 'character_trait', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default CharacterTrait; diff --git a/backend/models/falukant/type/house.js b/backend/models/falukant/type/house.js index 4740a3e..febdc9b 100644 --- a/backend/models/falukant/type/house.js +++ b/backend/models/falukant/type/house.js @@ -4,23 +4,18 @@ import { sequelize } from '../../../utils/sequelize.js'; class HouseType extends Model { } HouseType.init({ - label_tr: { + labelTr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, cost: { type: DataTypes.INTEGER, - allowNull: false, - }, + allowNull: false}, position: { type: DataTypes.INTEGER, - allowNull: false, - }, - minimum_noble_title: { + allowNull: false}, + minimumNobleTitle: { type: DataTypes.INTEGER, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'HouseType', tableName: 'house', @@ -30,10 +25,8 @@ HouseType.init({ indexes: [ { unique: true, - fields: ['label_tr'] - , - freezeTableName: true} - ], -}); + fields: ['labelTr'] + } + ]}); export default HouseType; diff --git a/backend/models/falukant/type/learn_recipient.js b/backend/models/falukant/type/learn_recipient.js index 8b72f7d..0553b21 100644 --- a/backend/models/falukant/type/learn_recipient.js +++ b/backend/models/falukant/type/learn_recipient.js @@ -7,18 +7,14 @@ LearnRecipient.init( { tr: { type: DataTypes.STRING, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'LearnRecipient', tableName: 'learn_recipient', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default LearnRecipient; diff --git a/backend/models/falukant/type/mood.js b/backend/models/falukant/type/mood.js index feeb45f..a8ffd0e 100644 --- a/backend/models/falukant/type/mood.js +++ b/backend/models/falukant/type/mood.js @@ -5,20 +5,20 @@ class Mood extends Model {} Mood.init( { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true}, tr: { type: DataTypes.STRING, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'Mood', tableName: 'mood', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default Mood; diff --git a/backend/models/falukant/type/music.js b/backend/models/falukant/type/music.js index 8309668..e52b77b 100644 --- a/backend/models/falukant/type/music.js +++ b/backend/models/falukant/type/music.js @@ -7,26 +7,20 @@ MusicType.init( { tr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, cost: { type: DataTypes.INTEGER, - allowNull: false, - }, - reputation_growth: { + allowNull: false}, + reputationGrowth: { type: DataTypes.INTEGER, - allowNull: false, - }, - }, + allowNull: false}}, { sequelize, modelName: 'MusicType', tableName: 'music', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default MusicType; diff --git a/backend/models/falukant/type/party.js b/backend/models/falukant/type/party.js index ccec089..897fb33 100644 --- a/backend/models/falukant/type/party.js +++ b/backend/models/falukant/type/party.js @@ -7,21 +7,17 @@ PartyType.init( { tr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, cost: { type: DataTypes.INTEGER, - allowNull: false, - }, - for_marriage: { + allowNull: false}, + forMarriage: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: false, - }, - reputation_growth: { + defaultValue: false}, + reputationGrowth: { type: DataTypes.INTEGER, - allowNull: false, - } + allowNull: false} }, { sequelize, @@ -29,9 +25,7 @@ PartyType.init( tableName: 'party', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default PartyType; diff --git a/backend/models/falukant/type/political_office_benefit_type.js b/backend/models/falukant/type/political_office_benefit_type.js index 8e466a2..922b35b 100644 --- a/backend/models/falukant/type/political_office_benefit_type.js +++ b/backend/models/falukant/type/political_office_benefit_type.js @@ -8,20 +8,15 @@ PoliticalOfficeBenefitType.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, + autoIncrement: true}, tr: { type: DataTypes.STRING, - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'PoliticalOfficeBenefitType', tableName: 'political_office_benefit_type', schema: 'falukant_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default PoliticalOfficeBenefitType; diff --git a/backend/models/falukant/type/political_office_type.js b/backend/models/falukant/type/political_office_type.js index 3dcf837..7adecdd 100644 --- a/backend/models/falukant/type/political_office_type.js +++ b/backend/models/falukant/type/political_office_type.js @@ -7,33 +7,25 @@ PoliticalOfficeType.init({ id: { type: DataTypes.INTEGER, primaryKey: true, - autoIncrement: true, - }, + autoIncrement: true}, name: { type: DataTypes.STRING, - allowNull: false, - }, - seats_per_region: { + allowNull: false}, + seatsPerRegion: { type: DataTypes.INTEGER, - allowNull: false, - }, - region_type: { + allowNull: false}, + regionType: { type: DataTypes.STRING, - allowNull: false, - }, - term_length: { + allowNull: false}, + termLength: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 0, - }, -}, { + defaultValue: 0}}, { sequelize, modelName: 'PoliticalOfficeType', tableName: 'political_office_type', schema: 'falukant_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default PoliticalOfficeType; diff --git a/backend/models/falukant/type/product.js b/backend/models/falukant/type/product.js index 9fbae35..33f4eeb 100644 --- a/backend/models/falukant/type/product.js +++ b/backend/models/falukant/type/product.js @@ -4,22 +4,18 @@ import { sequelize } from '../../../utils/sequelize.js'; class ProductType extends Model { } ProductType.init({ - label_tr: { + labelTr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, category: { type: DataTypes.INTEGER, - allowNull: false, - }, - production_time: { + allowNull: false}, + productionTime: { type: DataTypes.INTEGER, - allowNull: false, - }, - sell_cost: { + allowNull: false}, + sellCost: { type: DataTypes.INTEGER, - allowNull: false, - } + allowNull: false} }, { sequelize, modelName: 'ProductType', @@ -30,10 +26,8 @@ ProductType.init({ indexes: [ { unique: true, - fields: ['label_tr'] - , - freezeTableName: true} - ], -}); + fields: ['labelTr'] + } + ]}); export default ProductType; diff --git a/backend/models/falukant/type/promotional_gift.js b/backend/models/falukant/type/promotional_gift.js index c2319b0..aef3208 100644 --- a/backend/models/falukant/type/promotional_gift.js +++ b/backend/models/falukant/type/promotional_gift.js @@ -5,29 +5,27 @@ class PromotionalGift extends Model {} PromotionalGift.init( { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true}, name: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, description: { type: DataTypes.TEXT, - allowNull: true, - }, + allowNull: true}, value: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 0, - }, - }, + defaultValue: 0}}, { sequelize, modelName: 'PromotionalGift', tableName: 'promotional_gift', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default PromotionalGift; diff --git a/backend/models/falukant/type/region.js b/backend/models/falukant/type/region.js index 1c47ba8..7757a81 100644 --- a/backend/models/falukant/type/region.js +++ b/backend/models/falukant/type/region.js @@ -4,18 +4,16 @@ import { sequelize } from '../../../utils/sequelize.js'; class RegionType extends Model { } RegionType.init({ - label_tr: { + labelTr: { type: DataTypes.STRING, - allowNull: false, - }, - parent_id: { + allowNull: false}, + parentId: { type: DataTypes.INTEGER, allowNull: true, references: { model: 'region', key: 'id', - schema: 'falukant_type', - } + schema: 'falukant_type'} } }, { sequelize, @@ -23,8 +21,6 @@ RegionType.init({ tableName: 'region', schema: 'falukant_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default RegionType; diff --git a/backend/models/falukant/type/relationship.js b/backend/models/falukant/type/relationship.js index 071fb4b..5f97bf0 100644 --- a/backend/models/falukant/type/relationship.js +++ b/backend/models/falukant/type/relationship.js @@ -7,8 +7,7 @@ RelationshipType.init( { tr: { type: DataTypes.STRING, - allowNull: false, - } + allowNull: false} }, { sequelize, @@ -16,9 +15,7 @@ RelationshipType.init( tableName: 'relationship', schema: 'falukant_type', timestamps: false, - underscored: true, - , - freezeTableName: true} + underscored: true} ); export default RelationshipType; diff --git a/backend/models/falukant/type/stock.js b/backend/models/falukant/type/stock.js index a6f3763..ba515a2 100644 --- a/backend/models/falukant/type/stock.js +++ b/backend/models/falukant/type/stock.js @@ -4,23 +4,19 @@ import { sequelize } from '../../../utils/sequelize.js'; class FalukantStockType extends Model { } FalukantStockType.init({ - label_tr: { + labelTr: { type: DataTypes.STRING, allowNull: false, - unique: true, - }, + unique: true}, cost: { type: DataTypes.INTEGER, - allowNull: false, - } + allowNull: false} }, { sequelize, modelName: 'StockType', tableName: 'stock', schema: 'falukant_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default FalukantStockType; diff --git a/backend/models/falukant/type/title_of_nobility.js b/backend/models/falukant/type/title_of_nobility.js index 56d6043..073114f 100644 --- a/backend/models/falukant/type/title_of_nobility.js +++ b/backend/models/falukant/type/title_of_nobility.js @@ -4,23 +4,18 @@ import { sequelize } from '../../../utils/sequelize.js'; class TitleOfNobility extends Model { } TitleOfNobility.init({ - label_tr: { + labelTr: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, level: { type: DataTypes.INTEGER, allowNull: false, - defaultValue: 0, - }, -}, { + defaultValue: 0}}, { sequelize, modelName: 'Title', tableName: 'title', schema: 'falukant_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default TitleOfNobility; diff --git a/backend/models/falukant/type/title_requirement.js b/backend/models/falukant/type/title_requirement.js index ee2a4d8..eb382ca 100644 --- a/backend/models/falukant/type/title_requirement.js +++ b/backend/models/falukant/type/title_requirement.js @@ -8,21 +8,16 @@ TitleRequirement.init({ type: DataTypes.INTEGER, allowNull: false, primaryKey: true, - autoIncrement: true, - }, - title_id: { + autoIncrement: true}, + titleId: { type: DataTypes.INTEGER, - allowNull: false, - }, - requirement_type: { + allowNull: false}, + requirementType: { type: DataTypes.STRING, - allowNull: false, - }, - requirement_value: { + allowNull: false}, + requirementValue: { type: DataTypes.DECIMAL(14, 2), - allowNull: false, - }, -}, { + allowNull: false}}, { sequelize, modelName: 'TitleRequirement', tableName: 'title_requirement', @@ -32,10 +27,9 @@ TitleRequirement.init({ indexes: [ { unique: true, - fields: ['title_id', 'requirement_type'], + fields: ['titleId', 'requirementType'], name: 'title_requirement_titleid_reqtype_unique' - , - freezeTableName: true} + } ] }); diff --git a/backend/models/falukant/type/underground.js b/backend/models/falukant/type/underground.js index 6409883..ce572d5 100644 --- a/backend/models/falukant/type/underground.js +++ b/backend/models/falukant/type/underground.js @@ -7,20 +7,16 @@ UndergroundType.init({ tr: { type: DataTypes.STRING, allowNull: false, - unique: true, - }, + unique: true}, cost: { type: DataTypes.INTEGER, - allowNull: false, - } + allowNull: false} }, { sequelize, modelName: 'UndergroundType', tableName: 'underground', schema: 'falukant_type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default UndergroundType; diff --git a/backend/models/forum/forum.js b/backend/models/forum/forum.js index 298a9f4..134884b 100644 --- a/backend/models/forum/forum.js +++ b/backend/models/forum/forum.js @@ -10,7 +10,6 @@ const Forum = sequelize.define('forum', { tableName: 'forum', schema: 'forum', underscored: true -, - freezeTableName: true}); +}); export default Forum; diff --git a/backend/models/forum/forum_forum_permission.js b/backend/models/forum/forum_forum_permission.js index ecf4648..cf35b1e 100644 --- a/backend/models/forum/forum_forum_permission.js +++ b/backend/models/forum/forum_forum_permission.js @@ -2,7 +2,7 @@ import { sequelize } from '../../utils/sequelize.js'; import { DataTypes } from 'sequelize'; const ForumForumPermission = sequelize.define('forum_forum_permission', { - forum_id: { + forumId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -10,7 +10,7 @@ const ForumForumPermission = sequelize.define('forum_forum_permission', { key: 'id' } }, - permission_id: { + permissionId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -22,7 +22,6 @@ const ForumForumPermission = sequelize.define('forum_forum_permission', { tableName: 'forum_forum_permission', schema: 'forum', underscored: true -, - freezeTableName: true}); +}); export default ForumForumPermission; diff --git a/backend/models/forum/forum_permission.js b/backend/models/forum/forum_permission.js index ad8c71f..c547d15 100644 --- a/backend/models/forum/forum_permission.js +++ b/backend/models/forum/forum_permission.js @@ -4,20 +4,16 @@ import { DataTypes } from 'sequelize'; const ForumPermission = sequelize.define('forum_permission', { name: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false}, value: { type: DataTypes.STRING, - allowNull: true, - }, -}, { + allowNull: true}}, { sequelize, modelName: 'ForumPermission', tableName: 'forum_permission', schema: 'forum', timestamps: false, underscored: true -, - freezeTableName: true}); +}); export default ForumPermission; diff --git a/backend/models/forum/forum_user_permission.js b/backend/models/forum/forum_user_permission.js index 295f518..a75c631 100644 --- a/backend/models/forum/forum_user_permission.js +++ b/backend/models/forum/forum_user_permission.js @@ -2,23 +2,21 @@ import { sequelize } from '../../utils/sequelize.js'; import { DataTypes } from 'sequelize'; const ForumUserPermission = sequelize.define('forum_user_permission', { - user_id: { + userId: { type: DataTypes.INTEGER, allowNull: true }, - permission_id: { + permissionId: { type: DataTypes.INTEGER, allowNull: false }, - forum_id: { + forumId: { type: DataTypes.INTEGER, allowNull: false - }, -}, { + }}, { tableName: 'forum_user_permission', schema: 'forum', underscored: true -, - freezeTableName: true}); +}); export default ForumUserPermission; diff --git a/backend/models/forum/message.js b/backend/models/forum/message.js index 0d4ccd2..ffa470f 100644 --- a/backend/models/forum/message.js +++ b/backend/models/forum/message.js @@ -6,11 +6,11 @@ const Message = sequelize.define('message', { type: DataTypes.TEXT, allowNull: false }, - created_by: { + createdBy: { type: DataTypes.INTEGER, allowNull: false }, - title_id: { + titleId: { type: DataTypes.INTEGER, allowNull: false } @@ -19,7 +19,6 @@ const Message = sequelize.define('message', { schema: 'forum', underscored: true, timestamps: true -, - freezeTableName: true}); +}); export default Message; diff --git a/backend/models/forum/message_history.js b/backend/models/forum/message_history.js index 3c9d25b..61eb3bb 100644 --- a/backend/models/forum/message_history.js +++ b/backend/models/forum/message_history.js @@ -2,19 +2,19 @@ import { sequelize } from '../../utils/sequelize.js'; import { DataTypes } from 'sequelize'; const MessageHistory = sequelize.define('message_history', { - message_id: { + messageId: { type: DataTypes.INTEGER, allowNull: false }, - old_text: { + oldText: { type: DataTypes.TEXT, allowNull: false }, - changed_by: { + changedBy: { type: DataTypes.INTEGER, allowNull: false }, - old_updated_at: { + oldUpdatedAt: { type: DataTypes.DATE, allowNull: false } @@ -23,7 +23,6 @@ const MessageHistory = sequelize.define('message_history', { schema: 'forum', underscored: true, timestamps: false -, - freezeTableName: true}); +}); export default MessageHistory; diff --git a/backend/models/forum/message_image.js b/backend/models/forum/message_image.js index ce5b58c..fc584f5 100644 --- a/backend/models/forum/message_image.js +++ b/backend/models/forum/message_image.js @@ -2,11 +2,11 @@ import { sequelize } from '../../utils/sequelize.js'; import { DataTypes } from 'sequelize'; const MessageImage = sequelize.define('message_image', { - message_id: { + messageId: { type: DataTypes.INTEGER, allowNull: false }, - file_name: { + fileName: { type: DataTypes.STRING, allowNull: false } @@ -15,7 +15,6 @@ const MessageImage = sequelize.define('message_image', { schema: 'forum', underscored: true, timestamps: false -, - freezeTableName: true}); +}); export default MessageImage; diff --git a/backend/models/forum/title.js b/backend/models/forum/title.js index bdd4781..52ea11e 100644 --- a/backend/models/forum/title.js +++ b/backend/models/forum/title.js @@ -11,11 +11,11 @@ const Title = sequelize.define('title', { type: DataTypes.STRING, allowNull: false }, - created_by: { + createdBy: { type: DataTypes.INTEGER, allowNull: false }, - forum_id: { + forumId: { type: DataTypes.INTEGER, allowNull: false } @@ -23,8 +23,6 @@ const Title = sequelize.define('title', { tableName: 'title', schema: 'forum', underscored: true, - timestamps: true, -, - freezeTableName: true}); + timestamps: true}); export default Title; diff --git a/backend/models/forum/title_history.js b/backend/models/forum/title_history.js index 16b4e63..535ef2b 100644 --- a/backend/models/forum/title_history.js +++ b/backend/models/forum/title_history.js @@ -2,19 +2,19 @@ import { sequelize } from '../../utils/sequelize.js'; import { DataTypes } from 'sequelize'; const TitleHistory = sequelize.define('title_history', { - title_id: { + titleId: { type: DataTypes.INTEGER, allowNull: false }, - old_title: { + oldTitle: { type: DataTypes.STRING, allowNull: false }, - changed_by: { + changedBy: { type: DataTypes.INTEGER, allowNull: false }, - old_updated_at: { + oldUpdatedAt: { type: DataTypes.DATE, allowNull: false } @@ -23,7 +23,6 @@ const TitleHistory = sequelize.define('title_history', { schema: 'forum', underscored: true, timestamps: false -, - freezeTableName: true}); +}); export default TitleHistory; diff --git a/backend/models/index.js b/backend/models/index.js index ae983d8..0cf35c1 100644 --- a/backend/models/index.js +++ b/backend/models/index.js @@ -86,20 +86,6 @@ import Credit from './falukant/data/credit.js'; import DebtorsPrism from './falukant/data/debtors_prism.js'; import HealthActivity from './falukant/log/health_activity.js'; -// Minigames (service) -import MinigameCampaign from './service/minigame_campaign.js'; -import MinigameCampaignLevel from './service/minigame_campaign_level.js'; -import MinigameUserProgress from './service/minigame_user_progress.js'; - -// Match3 Models -import Match3Campaign from './match3/campaign.js'; -import Match3Level from './match3/level.js'; -import Match3Objective from './match3/objective.js'; -import Match3UserProgress from './match3/userProgress.js'; -import Match3UserLevelProgress from './match3/userLevelProgress.js'; -import Match3TileType from './match3/tileType.js'; -import Match3LevelTileType from './match3/levelTileType.js'; - // — Politische Ämter (Politics) — import PoliticalOfficeType from './falukant/type/political_office_type.js'; import PoliticalOfficeRequirement from './falukant/predefine/political_office_prerequisite.js'; @@ -208,16 +194,6 @@ const models = { Credit, DebtorsPrism, HealthActivity, - MinigameCampaign, - MinigameCampaignLevel, - MinigameUserProgress, - Match3Campaign, - Match3Level, - Match3Objective, - Match3UserProgress, - Match3UserLevelProgress, - Match3TileType, - Match3LevelTileType, PoliticalOfficeType, PoliticalOfficeRequirement, PoliticalOfficeBenefitType, diff --git a/backend/models/match3/campaign.js b/backend/models/match3/campaign.js index b4590b8..8c2fafb 100644 --- a/backend/models/match3/campaign.js +++ b/backend/models/match3/campaign.js @@ -15,7 +15,7 @@ const Campaign = sequelize.define('Campaign', { type: DataTypes.TEXT, allowNull: true }, - is_active: { + isActive: { type: DataTypes.BOOLEAN, defaultValue: true }, @@ -23,11 +23,11 @@ const Campaign = sequelize.define('Campaign', { type: DataTypes.INTEGER, defaultValue: 1 }, - created_at: { + createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }, - updated_at: { + updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW } @@ -36,7 +36,6 @@ const Campaign = sequelize.define('Campaign', { schema: 'match3', timestamps: true, underscored: true // WICHTIG: Alle Datenbankfelder im snake_case Format -, - freezeTableName: true}); +}); export default Campaign; diff --git a/backend/models/match3/level.js b/backend/models/match3/level.js index ae34a7b..2f478c7 100644 --- a/backend/models/match3/level.js +++ b/backend/models/match3/level.js @@ -7,7 +7,7 @@ const Match3Level = sequelize.define('Match3Level', { primaryKey: true, autoIncrement: true }, - campaign_id: { + campaignId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -27,40 +27,40 @@ const Match3Level = sequelize.define('Match3Level', { type: DataTypes.INTEGER, allowNull: false }, - board_layout: { + boardLayout: { type: DataTypes.TEXT, allowNull: true, // Ändern zu true, da bereits existierende Datensätze vorhanden sind defaultValue: 'xxxxxx\nxxxxxx\nxxxxxx\nxxxxxx\nxxxxxx\nxxxxxx', // Standard-Layout für neue Level comment: 'Level-Form als String (o = kein Feld, x = Feld, Zeilen durch \n getrennt)' }, - board_width: { + boardWidth: { type: DataTypes.INTEGER, allowNull: true, // Ändern zu true, da bereits existierende Datensätze vorhanden sind defaultValue: 6, // Standardwert für neue Level comment: 'Breite des Level-Boards' }, - board_height: { + boardHeight: { type: DataTypes.INTEGER, allowNull: true, // Ändern zu true, da bereits existierende Datensätze vorhanden sind defaultValue: 6, // Standardwert für neue Level comment: 'Höhe des Level-Boards' }, - tile_types: { + tileTypes: { type: DataTypes.JSON, allowNull: true, // Ändern zu true, da wir jetzt eine Verknüpfungstabelle haben comment: 'Legacy: Array der verfügbaren Tile-Typen (wird durch levelTileTypes ersetzt)' }, - move_limit: { + moveLimit: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 20 }, - time_limit: { + timeLimit: { type: DataTypes.INTEGER, allowNull: true, comment: 'Zeitlimit in Sekunden (null = kein Limit)' }, - is_active: { + isActive: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true @@ -70,7 +70,6 @@ const Match3Level = sequelize.define('Match3Level', { schema: 'match3', timestamps: true, underscored: true // WICHTIG: Alle Datenbankfelder im snake_case Format -, - freezeTableName: true}); +}); export default Match3Level; diff --git a/backend/models/match3/levelTileType.js b/backend/models/match3/levelTileType.js index 3931745..014d3c2 100644 --- a/backend/models/match3/levelTileType.js +++ b/backend/models/match3/levelTileType.js @@ -7,7 +7,7 @@ const Match3LevelTileType = sequelize.define('Match3LevelTileType', { primaryKey: true, autoIncrement: true }, - level_id: { + levelId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -16,7 +16,7 @@ const Match3LevelTileType = sequelize.define('Match3LevelTileType', { }, comment: 'Referenz auf den Level' }, - tile_type_id: { + tileTypeId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -31,7 +31,7 @@ const Match3LevelTileType = sequelize.define('Match3LevelTileType', { defaultValue: 1, comment: 'Gewichtung für die Wahrscheinlichkeit, dass dieser Tile-Typ erscheint' }, - is_active: { + isActive: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, @@ -45,9 +45,8 @@ const Match3LevelTileType = sequelize.define('Match3LevelTileType', { indexes: [ { unique: true, - fields: ['level_id', 'tile_type_id'] // WICHTIG: Bei underscored: true müssen snake_case Namen verwendet werden - , - freezeTableName: true} + fields: ['levelId', 'tileTypeId'] // WICHTIG: Bei underscored: true müssen snake_case Namen verwendet werden + } ] }); diff --git a/backend/models/match3/objective.js b/backend/models/match3/objective.js index bfb1f00..651a381 100644 --- a/backend/models/match3/objective.js +++ b/backend/models/match3/objective.js @@ -7,7 +7,7 @@ const Objective = sequelize.define('Objective', { primaryKey: true, autoIncrement: true }, - level_id: { + levelId: { type: DataTypes.INTEGER, allowNull: false }, @@ -31,15 +31,15 @@ const Objective = sequelize.define('Objective', { type: DataTypes.INTEGER, defaultValue: 1 }, - is_required: { + isRequired: { type: DataTypes.BOOLEAN, defaultValue: true }, - created_at: { + createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }, - updated_at: { + updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW } @@ -48,7 +48,6 @@ const Objective = sequelize.define('Objective', { schema: 'match3', timestamps: true, underscored: true // WICHTIG: Alle Datenbankfelder im snake_case Format -, - freezeTableName: true}); +}); export default Objective; diff --git a/backend/models/match3/tileType.js b/backend/models/match3/tileType.js index 4733ea6..b30649f 100644 --- a/backend/models/match3/tileType.js +++ b/backend/models/match3/tileType.js @@ -12,7 +12,7 @@ const Match3TileType = sequelize.define('Match3TileType', { allowNull: false, comment: 'Eindeutiger Name des Tile-Typs (z.B. "gem", "star", "heart")' }, - display_name: { + displayName: { type: DataTypes.STRING(100), allowNull: false, comment: 'Anzeigename des Tile-Typs (z.B. "Juwel", "Stern", "Herz")' @@ -39,7 +39,7 @@ const Match3TileType = sequelize.define('Match3TileType', { defaultValue: 10, comment: 'Punkte, die dieser Tile-Typ beim Matchen gibt' }, - is_active: { + isActive: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, @@ -54,8 +54,7 @@ const Match3TileType = sequelize.define('Match3TileType', { { unique: true, fields: ['name'] - , - freezeTableName: true} + } ] }); diff --git a/backend/models/match3/userLevelProgress.js b/backend/models/match3/userLevelProgress.js index 1783650..17eb240 100644 --- a/backend/models/match3/userLevelProgress.js +++ b/backend/models/match3/userLevelProgress.js @@ -7,11 +7,11 @@ const UserLevelProgress = sequelize.define('UserLevelProgress', { primaryKey: true, autoIncrement: true }, - user_progress_id: { + userProgressId: { type: DataTypes.INTEGER, allowNull: false }, - level_id: { + levelId: { type: DataTypes.INTEGER, allowNull: false }, @@ -31,7 +31,7 @@ const UserLevelProgress = sequelize.define('UserLevelProgress', { type: DataTypes.INTEGER, defaultValue: 0 }, - is_completed: { + isCompleted: { type: DataTypes.BOOLEAN, defaultValue: false }, @@ -39,27 +39,27 @@ const UserLevelProgress = sequelize.define('UserLevelProgress', { type: DataTypes.INTEGER, defaultValue: 1 }, - best_score: { + bestScore: { type: DataTypes.INTEGER, defaultValue: 0 }, - best_moves: { + bestMoves: { type: DataTypes.INTEGER, defaultValue: 0 }, - best_time: { + bestTime: { type: DataTypes.INTEGER, defaultValue: 0 }, - completed_at: { + completedAt: { type: DataTypes.DATE, allowNull: true }, - created_at: { + createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }, - updated_at: { + updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW } @@ -71,9 +71,8 @@ const UserLevelProgress = sequelize.define('UserLevelProgress', { indexes: [ { unique: true, - fields: ['user_progress_id', 'level_id'] // WICHTIG: Bei underscored: true müssen snake_case Namen verwendet werden - , - freezeTableName: true} + fields: ['userProgressId', 'levelId'] // WICHTIG: Bei underscored: true müssen snake_case Namen verwendet werden + } ] }); diff --git a/backend/models/match3/userProgress.js b/backend/models/match3/userProgress.js index bec19a7..1f05ea2 100644 --- a/backend/models/match3/userProgress.js +++ b/backend/models/match3/userProgress.js @@ -7,43 +7,43 @@ const UserProgress = sequelize.define('UserProgress', { primaryKey: true, autoIncrement: true }, - user_id: { + userId: { type: DataTypes.STRING(255), allowNull: false }, - campaign_id: { + campaignId: { type: DataTypes.INTEGER, allowNull: false }, - total_score: { + totalScore: { type: DataTypes.INTEGER, defaultValue: 0 }, - total_stars: { + totalStars: { type: DataTypes.INTEGER, defaultValue: 0 }, - levels_completed: { + levelsCompleted: { type: DataTypes.INTEGER, defaultValue: 0 }, - current_level: { + currentLevel: { type: DataTypes.INTEGER, defaultValue: 1 }, - is_completed: { + isCompleted: { type: DataTypes.BOOLEAN, defaultValue: false }, - last_played: { + lastPlayed: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }, - created_at: { + createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }, - updated_at: { + updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW } @@ -55,9 +55,8 @@ const UserProgress = sequelize.define('UserProgress', { indexes: [ { unique: true, - fields: ['user_id', 'campaign_id'] // WICHTIG: Bei underscored: true müssen snake_case Namen verwendet werden - , - freezeTableName: true} + fields: ['userId', 'campaignId'] // WICHTIG: Bei underscored: true müssen snake_case Namen verwendet werden + } ] }); diff --git a/backend/models/service/contactmessage.js b/backend/models/service/contactmessage.js index e49890c..d3cbe27 100644 --- a/backend/models/service/contactmessage.js +++ b/backend/models/service/contactmessage.js @@ -51,11 +51,11 @@ const ContactMessage = sequelize.define('contact_message', { } } }, - allow_data_save: { + allowDataSave: { type: DataTypes.BOOLEAN, allowNull: false }, - is_finished: { + isFinished: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false @@ -77,11 +77,11 @@ const ContactMessage = sequelize.define('contact_message', { } } }, - answered_at: { + answeredAt: { type: DataTypes.DATE, allowNull: true }, - is_answered: { + isAnswered: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false @@ -91,7 +91,6 @@ const ContactMessage = sequelize.define('contact_message', { timestamps: true, schema: 'service', underscored: true -, - freezeTableName: true}); +}); export default ContactMessage; diff --git a/backend/models/service/minigame_campaign.js b/backend/models/service/minigame_campaign.js index feb5cb6..e69de29 100644 --- a/backend/models/service/minigame_campaign.js +++ b/backend/models/service/minigame_campaign.js @@ -1,25 +0,0 @@ -import { sequelize } from '../../utils/sequelize.js'; -import { DataTypes } from 'sequelize'; - -const MinigameCampaign = sequelize.define('minigame_campaign', { - code: { - type: DataTypes.STRING, - allowNull: false, - unique: true, - }, - title: { - type: DataTypes.STRING, - allowNull: false, - }, - description: { - type: DataTypes.TEXT, - allowNull: true, - }, -}, { - tableName: 'minigame_campaign', - schema: 'service', - underscored: true, -, - freezeTableName: true}); - -export default MinigameCampaign; diff --git a/backend/models/service/minigame_campaign_level.js b/backend/models/service/minigame_campaign_level.js index 271d8b9..e69de29 100644 --- a/backend/models/service/minigame_campaign_level.js +++ b/backend/models/service/minigame_campaign_level.js @@ -1,26 +0,0 @@ -import { sequelize } from '../../utils/sequelize.js'; -import { DataTypes } from 'sequelize'; - -const MinigameCampaignLevel = sequelize.define('minigame_campaign_level', { - campaign_id: { - type: DataTypes.INTEGER, - allowNull: false, - field: 'campaign_id' - }, - index: { // 1-based level number - type: DataTypes.INTEGER, - allowNull: false, - }, - config: { - type: DataTypes.JSONB, - allowNull: false, - defaultValue: {} - }, -}, { - tableName: 'minigame_campaign_level', - schema: 'service', - underscored: true, -, - freezeTableName: true}); - -export default MinigameCampaignLevel; diff --git a/backend/models/service/minigame_user_progress.js b/backend/models/service/minigame_user_progress.js index 1efba27..e69de29 100644 --- a/backend/models/service/minigame_user_progress.js +++ b/backend/models/service/minigame_user_progress.js @@ -1,42 +0,0 @@ -import { sequelize } from '../../utils/sequelize.js'; -import { DataTypes } from 'sequelize'; - -const MinigameUserProgress = sequelize.define('minigame_user_progress', { - user_id: { - type: DataTypes.INTEGER, - allowNull: false, - field: 'user_id' - }, - campaign_id: { - type: DataTypes.INTEGER, - allowNull: false, - field: 'campaign_id' - }, - level_index: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 1, - field: 'level_index' - }, - stars: { // 0..3 - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 0 - }, - best_score: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 0, - field: 'best_score' - } -}, { - tableName: 'minigame_user_progress', - schema: 'service', - underscored: true, - indexes: [ - { unique: true, fields: ['user_id', 'campaign_id'] , - freezeTableName: true} - ] -}); - -export default MinigameUserProgress; diff --git a/backend/models/type/image_visibility.js b/backend/models/type/image_visibility.js index 1b80268..ed83eaf 100644 --- a/backend/models/type/image_visibility.js +++ b/backend/models/type/image_visibility.js @@ -16,8 +16,6 @@ const ImageVisibilityType = sequelize.define('image_visibility_type', { tableName: 'image_visibility_type', schema: 'type', timestamps: false, - underscored: true, -, - freezeTableName: true}); + underscored: true}); export default ImageVisibilityType; diff --git a/backend/models/type/interest.js b/backend/models/type/interest.js index 77f1a89..e38a8fd 100644 --- a/backend/models/type/interest.js +++ b/backend/models/type/interest.js @@ -11,16 +11,14 @@ const Interest = sequelize.define('interest_type', { allowNull: false, defaultValue: false }, - adult_only: { + adultOnly: { type: DataTypes.BOOLEAN, allowNull: false, - defaultValue: true, - } + defaultValue: true} }, { tableName: 'interest', schema: 'type', underscored: true -, - freezeTableName: true}); +}); export default Interest; \ No newline at end of file diff --git a/backend/models/type/interest_translation.js b/backend/models/type/interest_translation.js index 424e66a..0677209 100644 --- a/backend/models/type/interest_translation.js +++ b/backend/models/type/interest_translation.js @@ -11,7 +11,7 @@ const interestTranslation = sequelize.define('interest_translation_type', { type: DataTypes.INTEGER, allowNull: false }, - interests_id: { + interestsId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -20,12 +20,10 @@ const interestTranslation = sequelize.define('interest_translation_type', { }, onUpdate: 'CASCADE', onDelete: 'CASCADE' - }, -}, { + }}, { tableName: 'interest_translation', schema: 'type', underscored: true -, - freezeTableName: true}); +}); export default interestTranslation; \ No newline at end of file diff --git a/backend/models/type/settings.js b/backend/models/type/settings.js index 5341fcb..9e288cb 100644 --- a/backend/models/type/settings.js +++ b/backend/models/type/settings.js @@ -5,12 +5,10 @@ const Settings = sequelize.define('settings_type', { name: { type: DataTypes.STRING, allowNull: false - }, -}, { + }}, { tableName: 'settings', schema: 'type', underscored: true -, - freezeTableName: true}); +}); export default Settings; \ No newline at end of file diff --git a/backend/models/type/user_param.js b/backend/models/type/user_param.js index 423f709..2fae1d9 100644 --- a/backend/models/type/user_param.js +++ b/backend/models/type/user_param.js @@ -6,7 +6,7 @@ const UserParamType = sequelize.define('user_param_type', { type: DataTypes.STRING, allowNull: false }, - min_age: { + minAge: { type: DataTypes.INTEGER, allowNull: true }, @@ -19,7 +19,7 @@ const UserParamType = sequelize.define('user_param_type', { allowNull: false, defaultValue: 'string' }, - settings_id: { + settingsId: { type: DataTypes.INTEGER, allowNull: false, references: { @@ -27,7 +27,7 @@ const UserParamType = sequelize.define('user_param_type', { key: 'id' } }, - order_id: { + orderId: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 @@ -40,7 +40,6 @@ const UserParamType = sequelize.define('user_param_type', { tableName: 'user_param', schema: 'type', underscored: true -, - freezeTableName: true}); +}); export default UserParamType; diff --git a/backend/models/type/user_param_value.js b/backend/models/type/user_param_value.js index 7492a9e..462b28a 100644 --- a/backend/models/type/user_param_value.js +++ b/backend/models/type/user_param_value.js @@ -8,7 +8,7 @@ const UserParamValue = sequelize.define('user_param_value', { primaryKey: true, autoIncrement: true }, - user_param_type_id: { + userParamTypeId: { type: DataTypes.INTEGER, allowNull: false }, @@ -16,7 +16,7 @@ const UserParamValue = sequelize.define('user_param_value', { type: DataTypes.STRING, allowNull: false }, - order_id: { + orderId: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 @@ -26,8 +26,7 @@ const UserParamValue = sequelize.define('user_param_value', { tableName: 'user_param_value', schema: 'type', underscored: true -, - freezeTableName: true} +} ); export default UserParamValue; diff --git a/backend/models/type/user_param_visibility.js b/backend/models/type/user_param_visibility.js index e2a1157..4bcdc73 100644 --- a/backend/models/type/user_param_visibility.js +++ b/backend/models/type/user_param_visibility.js @@ -17,7 +17,6 @@ const UserParamVisibilityType = sequelize.define('user_param_visibility_type', { timestamps: false, underscored: true, schema: 'type' -, - freezeTableName: true}); +}); export default UserParamVisibilityType; diff --git a/backend/models/type/user_right.js b/backend/models/type/user_right.js index 6eb792c..3cf4741 100644 --- a/backend/models/type/user_right.js +++ b/backend/models/type/user_right.js @@ -9,8 +9,7 @@ const UserRightType = sequelize.define('user_right_type', { }, { tableName: 'user_right', schema: 'type', - underscored: true -, - freezeTableName: true}); + underscored: true +}); export default UserRightType; diff --git a/backend/package.json b/backend/package.json index cc5793e..b18be6a 100644 --- a/backend/package.json +++ b/backend/package.json @@ -5,6 +5,8 @@ "type": "module", "main": "index.js", "scripts": { + "start": "node server.js", + "dev": "NODE_ENV=development node server.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], diff --git a/backend/server.js b/backend/server.js index 79ab3a2..ad13f37 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1,3 +1,4 @@ +import './config/loadEnv.js'; // .env deterministisch laden import http from 'http'; import app from './app.js'; import { setupWebSocket } from './utils/socket.js'; diff --git a/backend/services/match3Service.js b/backend/services/match3Service.js index c2e48c6..82ac300 100644 --- a/backend/services/match3Service.js +++ b/backend/services/match3Service.js @@ -139,7 +139,24 @@ class Match3Service { throw { status: 404, message: 'Level not found' }; } - return level; + // Ergänze levelTileTypes wie in getCampaign (optional) + try { + const levelTileTypes = await Match3LevelTileType.findAll({ + where: { levelId: level.id, isActive: true }, + include: [ + { + model: Match3TileType, + as: 'tileType', + where: { isActive: true }, + required: true + } + ], + order: [['weight', 'DESC']] + }); + return { ...level.toJSON(), levelTileTypes }; + } catch (e) { + return { ...level.toJSON(), levelTileTypes: [] }; + } } // Lade Benutzer-Fortschritt für eine Kampagne diff --git a/backend/services/minigamesService.js b/backend/services/minigamesService.js index b69c08b..e69de29 100644 --- a/backend/services/minigamesService.js +++ b/backend/services/minigamesService.js @@ -1,53 +0,0 @@ -import BaseService from './BaseService.js'; -import models from '../models/index.js'; -import { Op } from 'sequelize'; - -const { MinigameCampaign, MinigameCampaignLevel, MinigameUserProgress, User } = models; - -class MinigamesService extends BaseService { - async listCampaigns() { - const campaigns = await MinigameCampaign.findAll({ order: [['id', 'ASC']] }); - return campaigns; - } - - async getCampaign(code) { - const campaign = await MinigameCampaign.findOne({ where: { code }, include: [{ model: MinigameCampaignLevel, as: 'levels', order: [['index', 'ASC']] }] }); - if (!campaign) throw new Error('campaign_not_found'); - return campaign; - } - - async getProgress(hashedUserId, code) { - const user = await this.getUserByHashedId(hashedUserId); - if (!user) throw new Error('user_not_found'); - const campaign = await MinigameCampaign.findOne({ where: { code } }); - if (!campaign) throw new Error('campaign_not_found'); - const progress = await MinigameUserProgress.findOne({ where: { userId: user.id, campaignId: campaign.id } }); - if (!progress) { - return { levelIndex: 1, stars: 0, bestScore: 0 }; - } - return progress; - } - - async saveProgress(hashedUserId, code, payload) { - const user = await this.getUserByHashedId(hashedUserId); - if (!user) throw new Error('user_not_found'); - const campaign = await MinigameCampaign.findOne({ where: { code } }); - if (!campaign) throw new Error('campaign_not_found'); - - const { levelIndex, stars, bestScore } = payload; - const [progress, created] = await MinigameUserProgress.findOrCreate({ - where: { userId: user.id, campaignId: campaign.id }, - defaults: { levelIndex, stars, bestScore } - }); - if (!created) { - await progress.update({ - levelIndex: Math.max(progress.levelIndex, levelIndex), - stars: Math.max(progress.stars, stars), - bestScore: Math.max(progress.bestScore, bestScore), - }); - } - return { success: true }; - } -} - -export default new MinigamesService(); diff --git a/backend/utils/checkLoginTable.js b/backend/utils/checkLoginTable.js deleted file mode 100644 index 93762bd..0000000 --- a/backend/utils/checkLoginTable.js +++ /dev/null @@ -1,57 +0,0 @@ -import { sequelize } from './sequelize.js'; - -async function checkLoginTable() { - console.log('🔍 Überprüfe logs.login Tabelle...'); - - try { - // Prüfe die Spaltenstruktur der logs.login Tabelle - const columns = await sequelize.query( - `SELECT column_name, data_type, is_nullable, column_default - FROM information_schema.columns - WHERE table_schema = 'logs' AND table_name = 'login' - ORDER BY ordinal_position`, - { type: sequelize.QueryTypes.SELECT } - ); - - if (columns.length === 0) { - console.log('❌ Tabelle logs.login existiert nicht!'); - } else { - console.log('📊 logs.login Tabellen-Struktur:'); - columns.forEach(col => { - const defaultValue = col.column_default ? ` (default: ${col.column_default})` : ''; - console.log(` ✅ ${col.column_name} (${col.data_type}, nullable: ${col.is_nullable})${defaultValue}`); - }); - } - - // Prüfe auch ein paar Beispieldaten - const sampleData = await sequelize.query( - `SELECT * FROM logs.login LIMIT 3`, - { type: sequelize.QueryTypes.SELECT } - ); - - if (sampleData.length > 0) { - console.log('\n📋 Beispieldaten:'); - sampleData.forEach((row, index) => { - console.log(` ${index + 1}: ${JSON.stringify(row)}`); - }); - } else { - console.log('\n📋 Keine Daten in der Tabelle gefunden.'); - } - - } catch (error) { - console.error('❌ Fehler beim Überprüfen der logs.login Tabelle:', error.message); - } finally { - await sequelize.close(); - } -} - -// Führe die Überprüfung aus -checkLoginTable() - .then(() => { - console.log('\n✅ Login-Tabellenüberprüfung abgeschlossen!'); - process.exit(0); - }) - .catch((error) => { - console.error('💥 Login-Tabellenüberprüfung fehlgeschlagen:', error); - process.exit(1); - }); diff --git a/backend/utils/cleanupDatabaseConstraints.js b/backend/utils/cleanupDatabaseConstraints.js index e1033b8..0a7908f 100644 --- a/backend/utils/cleanupDatabaseConstraints.js +++ b/backend/utils/cleanupDatabaseConstraints.js @@ -8,7 +8,11 @@ async function cleanupDatabaseConstraints() { try { console.log('🧹 Starte Bereinigung der Datenbank-Constraints...'); - // 1. Doppelte UNIQUE Constraints entfernen + // 1. Spezielle Bereinigung für community.user Tabelle + console.log('🔍 Spezielle Bereinigung für community.user Tabelle...'); + await cleanupUserTableConstraints(); + + // 2. Doppelte UNIQUE Constraints entfernen console.log('🔍 Suche nach doppelten UNIQUE Constraints...'); const duplicateUniqueConstraints = await sequelize.query(` @@ -50,7 +54,11 @@ async function cleanupDatabaseConstraints() { } } - // 2. Doppelte CHECK Constraints entfernen (korrigierte Abfrage) + // 3. Entferne alle Constraints mit numerischen Suffixen + console.log('🔍 Entferne alle Constraints mit numerischen Suffixen...'); + await removeNumericalSuffixConstraints(); + + // 4. Doppelte CHECK Constraints entfernen (korrigierte Abfrage) console.log('🔍 Suche nach doppelten CHECK Constraints...'); try { @@ -72,7 +80,7 @@ async function cleanupDatabaseConstraints() { console.log(`⚠️ Konnte CHECK Constraints nicht abfragen: ${error.message}`); } - // 3. Doppelte Foreign Key Constraints entfernen + // 5. Doppelte Foreign Key Constraints entfernen console.log('🔍 Suche nach doppelten Foreign Key Constraints...'); const duplicateFKs = await sequelize.query(` @@ -95,7 +103,7 @@ async function cleanupDatabaseConstraints() { console.log(`📊 Gefunden: ${duplicateFKs.length} Foreign Key Constraints`); - // 4. Doppelte Indexe entfernen + // 6. Doppelte Indexe entfernen console.log('🔍 Suche nach doppelten Indexen...'); const duplicateIndexes = await sequelize.query(` @@ -112,7 +120,7 @@ async function cleanupDatabaseConstraints() { console.log(`📊 Gefunden: ${duplicateIndexes.length} potenziell doppelte Indexe`); - // 5. Spezifische Match3-Constraints prüfen + // 7. Spezifische Match3-Constraints prüfen console.log('🔍 Prüfe Match3-spezifische Constraints...'); const match3Constraints = await sequelize.query(` @@ -130,7 +138,7 @@ async function cleanupDatabaseConstraints() { console.log(` - ${constraint.table_name}: ${constraint.constraint_type} (${constraint.constraint_name})`); }); - // 6. Spezifische Chat-Constraints prüfen (da das Problem dort auftritt) + // 8. Spezifische Chat-Constraints prüfen (da das Problem dort auftritt) console.log('🔍 Prüfe Chat-spezifische Constraints...'); try { @@ -155,7 +163,7 @@ async function cleanupDatabaseConstraints() { console.log(`⚠️ Konnte Chat Constraints nicht abfragen: ${error.message}`); } - // 7. Spezifische Überprüfung der chat.rights Tabelle + // 9. Spezifische Überprüfung der chat.rights Tabelle console.log('🔍 Spezielle Überprüfung der chat.rights Tabelle...'); try { @@ -203,7 +211,7 @@ async function cleanupDatabaseConstraints() { console.log(`⚠️ Konnte chat.rights Constraints nicht abfragen: ${error.message}`); } - // 8. Empfehlungen ausgeben + // 10. Empfehlungen ausgeben console.log('\n💡 Empfehlungen:'); console.log('1. Überprüfe die oben gelisteten Constraints auf Duplikate'); console.log('2. Verwende updateSchema() nur bei expliziten Schema-Änderungen'); @@ -218,6 +226,133 @@ async function cleanupDatabaseConstraints() { } } +/** + * Spezielle Bereinigung für die community.user Tabelle + * Entfernt alle Constraints mit numerischen Suffixen + */ +async function cleanupUserTableConstraints() { + try { + console.log('🔍 Bereinige community.user Tabelle...'); + + // Finde alle Constraints der user Tabelle + const userConstraints = await sequelize.query(` + SELECT + tc.constraint_name, + tc.constraint_type, + kcu.column_name + FROM information_schema.table_constraints tc + LEFT JOIN information_schema.key_column_usage kcu + ON tc.constraint_name = kcu.constraint_name + WHERE tc.table_schema = 'community' + AND tc.table_name = 'user' + ORDER BY tc.constraint_type, kcu.column_name; + `, { type: sequelize.QueryTypes.SELECT }); + + console.log(`📊 Community.user Constraints gefunden: ${userConstraints.length}`); + + // Gruppiere Constraints nach Spalte und Typ + const constraintsByColumn = {}; + userConstraints.forEach(constraint => { + const key = `${constraint.constraint_type}_${constraint.column_name || 'general'}`; + if (!constraintsByColumn[key]) { + constraintsByColumn[key] = []; + } + constraintsByColumn[key].push(constraint.constraint_name); + }); + + // Entferne doppelte Constraints, behalte nur einen pro Spalte/Typ + for (const [key, constraintNames] of Object.entries(constraintsByColumn)) { + if (constraintNames.length > 1) { + console.log(`🗑️ Entferne ${constraintNames.length - 1} doppelte Constraints für ${key}`); + + // Sortiere nach Namen, um konsistente Ergebnisse zu erhalten + constraintNames.sort(); + + // Behalte den ersten, entferne die anderen + for (let i = 1; i < constraintNames.length; i++) { + const constraintName = constraintNames[i]; + try { + await sequelize.query(` + ALTER TABLE community."user" + DROP CONSTRAINT IF EXISTS "${constraintName}" + `); + console.log(` ✅ Entfernt: ${constraintName}`); + } catch (error) { + console.log(` ⚠️ Konnte nicht entfernen: ${constraintName} - ${error.message}`); + } + } + } + } + + // Entferne alle Constraints mit numerischen Suffixen + const numericalConstraints = userConstraints.filter(c => + /\d+$/.test(c.constraint_name) && + (c.constraint_name.includes('_key') || c.constraint_name.includes('_index')) + ); + + if (numericalConstraints.length > 0) { + console.log(`🗑️ Entferne ${numericalConstraints.length} Constraints mit numerischen Suffixen`); + + for (const constraint of numericalConstraints) { + try { + await sequelize.query(` + ALTER TABLE community."user" + DROP CONSTRAINT IF EXISTS "${constraint.constraint_name}" + `); + console.log(` ✅ Entfernt: ${constraint.constraint_name}`); + } catch (error) { + console.log(` ⚠️ Konnte nicht entfernen: ${constraint.constraint_name} - ${error.message}`); + } + } + } + + } catch (error) { + console.log(`⚠️ Konnte community.user Constraints nicht bereinigen: ${error.message}`); + } +} + +/** + * Entfernt alle Constraints mit numerischen Suffixen aus allen Tabellen + */ +async function removeNumericalSuffixConstraints() { + try { + console.log('🔍 Entferne alle Constraints mit numerischen Suffixen...'); + + // Finde alle Constraints mit numerischen Suffixen + const numericalConstraints = await sequelize.query(` + SELECT + tc.table_schema, + tc.table_name, + tc.constraint_name, + tc.constraint_type + FROM information_schema.table_constraints tc + WHERE tc.table_schema IN ('match3', 'community', 'falukant_data', 'falukant_type', 'falukant_predefine', 'falukant_log', 'chat', 'forum', 'logs', 'type', 'service') + AND tc.constraint_name ~ '.*\\d+$' + AND (tc.constraint_name LIKE '%_key%' OR tc.constraint_name LIKE '%_index%') + ORDER BY tc.table_schema, tc.table_name, tc.constraint_name; + `, { type: sequelize.QueryTypes.SELECT }); + + console.log(`📊 Gefunden: ${numericalConstraints.length} Constraints mit numerischen Suffixen`); + + if (numericalConstraints.length > 0) { + for (const constraint of numericalConstraints) { + try { + await sequelize.query(` + ALTER TABLE ${constraint.table_schema}.${constraint.table_name} + DROP CONSTRAINT IF EXISTS "${constraint.constraint_name}" + `); + console.log(` ✅ Entfernt: ${constraint.table_schema}.${constraint.table_name}.${constraint.constraint_name}`); + } catch (error) { + console.log(` ⚠️ Konnte nicht entfernen: ${constraint.constraint_name} - ${error.message}`); + } + } + } + + } catch (error) { + console.log(`⚠️ Konnte numerische Suffix-Constraints nicht entfernen: ${error.message}`); + } +} + // Führe das Skript aus, wenn es direkt aufgerufen wird if (import.meta.url === `file://${process.argv[1]}`) { cleanupDatabaseConstraints() diff --git a/backend/utils/crypto.js b/backend/utils/crypto.js index 1876d92..6444fe0 100644 --- a/backend/utils/crypto.js +++ b/backend/utils/crypto.js @@ -1,7 +1,11 @@ import crypto from 'crypto'; const algorithm = 'aes-256-ecb'; // Verwende ECB-Modus, der keinen IV benötigt -const key = crypto.scryptSync(process.env.SECRET_KEY, 'salt', 32); // Der Schlüssel sollte eine Länge von 32 Bytes haben +const secret = process.env.SECRET_KEY; +if (!secret) { + console.warn('[crypto] SECRET_KEY fehlt – verwende unsicheren Fallback (nur Entwicklung).'); +} +const key = crypto.scryptSync(secret || 'DEV_FALLBACK_SECRET', 'salt', 32); // Der Schlüssel sollte eine Länge von 32 Bytes haben export const encrypt = (text) => { const cipher = crypto.createCipheriv(algorithm, key, null); // Kein IV verwendet diff --git a/backend/utils/encryption.js b/backend/utils/encryption.js index 8947ba3..5258338 100644 --- a/backend/utils/encryption.js +++ b/backend/utils/encryption.js @@ -2,7 +2,11 @@ import crypto from 'crypto'; const algorithm = 'aes-256-ecb'; -const key = crypto.scryptSync(process.env.SECRET_KEY, 'salt', 32); +const secret = process.env.SECRET_KEY; +if (!secret) { + console.warn('[encryption] SECRET_KEY fehlt – verwende unsicheren Fallback (nur für Entwicklung).'); +} +const key = crypto.scryptSync(secret || 'DEV_FALLBACK_SECRET', 'salt', 32); export const generateIv = () => { return crypto.randomBytes(16).toString('base64'); diff --git a/backend/utils/falukant/initializeFalukantTypes.js b/backend/utils/falukant/initializeFalukantTypes.js index d37af91..22507e7 100644 --- a/backend/utils/falukant/initializeFalukantTypes.js +++ b/backend/utils/falukant/initializeFalukantTypes.js @@ -6,6 +6,7 @@ import CharacterTrait from "../../models/falukant/type/character_trait.js"; import PromotionalGift from "../../models/falukant/type/promotional_gift.js"; import PromotionalGiftCharacterTrait from "../../models/falukant/predefine/promotional_gift_character_trait.js"; import PromotionalGiftMood from "../../models/falukant/predefine/promotional_gift_mood.js"; +import { sequelize } from '../sequelize.js'; import HouseType from '../../models/falukant/type/house.js'; import TitleOfNobility from "../../models/falukant/type/title_of_nobility.js"; import PartyType from "../../models/falukant/type/party.js"; @@ -16,6 +17,9 @@ import PoliticalOfficeType from "../../models/falukant/type/political_office_typ import PoliticalOfficePrerequisite from "../../models/falukant/predefine/political_office_prerequisite.js"; import UndergroundType from "../../models/falukant/type/underground.js"; +// Debug-Flag: Nur wenn DEBUG_FALUKANT=1 gesetzt ist, werden ausführliche Logs ausgegeben. +const falukantDebug = process.env.DEBUG_FALUKANT === '1'; + export const initializeFalukantTypes = async () => { await initializeFalukantTypeRegions(); await initializeFalukantRelationships(); @@ -631,7 +635,7 @@ export const initializeFalukantRegions = async () => { console.error(`Parent region not found for: ${region.parentTr}`); continue; } - console.log('Creating/Fetching Region:', region.labelTr, 'Type:', regionType.labelTr, 'Parent:', parentRegion?.name); + if (falukantDebug) console.log('[Falukant] Region', region.labelTr, 'type', regionType.labelTr, 'parent', parentRegion?.name); await RegionData.findOrCreate({ where: { name: region.labelTr }, defaults: { @@ -682,44 +686,102 @@ export const initializeFalukantPromotionalGifts = async () => { }; export const initializePromotionalGiftTraitLinks = async () => { + const giftRows = await PromotionalGift.findAll({ attributes: ['id','name'], raw: true }); + const traitRows = await CharacterTrait.findAll({ attributes: ['id','tr'], raw: true }); + const giftMap = new Map(giftRows.map(g=>[g.name,g.id])); + const traitMap = new Map(traitRows.map(t=>[t.tr,t.id])); + let created = 0, updated = 0, skipped = 0; for (const link of promotionalGiftTraitLinks) { - const gift = await PromotionalGift.findOne({ where: { name: link.gift } }); - const trait = await CharacterTrait.findOne({ where: { tr: link.trait } }); - if (!gift || !trait) { - console.error(`Gift or Trait not found for: ${link.gift}, ${link.trait}`); - continue; + const giftId = giftMap.get(link.gift); + const traitId = traitMap.get(link.trait); + if (giftId == null || traitId == null) { skipped++; continue; } + try { + const [record, wasCreated] = await PromotionalGiftCharacterTrait.findOrCreate({ + where: { giftId, traitId }, + defaults: { giftId, traitId, suitability: link.suitability } + }); + if (wasCreated) { created++; } + else if (record.suitability !== link.suitability) { record.suitability = link.suitability; await record.save(); updated++; } + } catch (e) { + if (falukantDebug) console.error('[Falukant] TraitLink Fehler (Model)', { giftId, traitId, error: e.message }); + // Fallback RAW Insert/Upsert + try { + await sequelize.query('INSERT INTO falukant_predefine.promotional_gift_character_trait (gift_id, trait_id, suitability) VALUES (:g,:t,:s) ON CONFLICT (gift_id, trait_id) DO UPDATE SET suitability = EXCLUDED.suitability', { + replacements: { g: giftId, t: traitId, s: link.suitability } + }); + created++; + } catch (rawErr) { + console.error('[Falukant] TraitLink RAW fail', { giftId, traitId, error: rawErr.message }); + throw rawErr; + } } - await PromotionalGiftCharacterTrait.findOrCreate({ - where: { - gift_id: gift.id, - trait_id: trait.id, - }, - defaults: { - suitability: link.suitability, - gift_id: gift.id, - trait_id: trait.id, - }, - }); } + console.log(`[Falukant] TraitLinks neu=${created} upd=${updated}${skipped?` skip=${skipped}`:''}`); }; export const initializePromotionalGiftMoodLinks = async () => { + // Diagnose: Zähle vorhandene Gifts & Moods bevor Links erstellt werden + try { + const totalGifts = await PromotionalGift.count(); + const totalMoods = await Mood.count(); + if (falukantDebug) console.log(`[Falukant] MoodLinks start gifts=${totalGifts} moods=${totalMoods} defs=${promotionalGiftMoodLinks.length}`); + } catch (e) { + if (falukantDebug) console.warn('[Falukant] MoodLinks count fail:', e.message); + } + // Prefetch Maps um Lookup stabil zu machen und potentielle Race-Conditions auszuschließen + const giftRows = await PromotionalGift.findAll({ attributes: ['id', 'name'], raw: true }); + const moodRows = await Mood.findAll({ attributes: ['id', 'tr'], raw: true }); + const giftMap = new Map(giftRows.map(g => [g.name, g.id])); + const moodMap = new Map(moodRows.map(m => [m.tr, m.id])); + // (logging minimiert) + + let nullIdIssues = 0; + let createdCount = 0; + let updatedCount = 0; + const anomalies = []; for (const link of promotionalGiftMoodLinks) { - const gift = await PromotionalGift.findOne({ where: { name: link.gift } }); - const mood = await Mood.findOne({ where: { tr: link.mood } }); - if (!gift || !mood) { - console.error(`Gift or Mood not found for: ${link.gift}, ${link.mood}`); + const giftId = giftMap.get(link.gift); + const moodId = moodMap.get(link.mood); + if (giftId == null || moodId == null) { + nullIdIssues++; + anomalies.push({ link, giftId, moodId }); + if (falukantDebug && nullIdIssues <= 10) console.error('[Falukant] MoodLink Lookup miss', { link, giftId, moodId }); continue; } - - await PromotionalGiftMood.create({ - gift_id: gift.id, - mood_id: mood.id, - suitability: link.suitability, - }).catch(err => { - if (err.name !== 'SequelizeUniqueConstraintError') throw err; - }); + try { + // Verwende Model API mit field-Mapping (giftId -> gift_id) jetzt vorhanden im Model + const [record, created] = await PromotionalGiftMood.findOrCreate({ + where: { giftId, moodId }, + defaults: { suitability: link.suitability } + }); + if (!created && record.suitability !== link.suitability) { + record.suitability = link.suitability; + await record.save(); + updatedCount++; + } else if (created) { + createdCount++; + } + // kein per-Link Logging mehr + } catch (err) { + if (falukantDebug) console.error('[Falukant] MoodLink Fehler (Model)', { link, giftId, moodId, error: err.message }); + // Fallback: versuche noch einmal per RAW (sollte nicht nötig sein) + try { + await sequelize.query('INSERT INTO falukant_predefine.promotional_gift_mood (gift_id, mood_id, suitability) VALUES (:g,:m,:s) ON CONFLICT (gift_id, mood_id) DO UPDATE SET suitability = EXCLUDED.suitability', { + replacements: { g: giftId, m: moodId, s: link.suitability } + }); + createdCount++; + // Fallback erfolgreich (unterdrücktes Detail-Logging) + } catch (rawErr) { + console.error('[Falukant] MoodLink RAW fail', { giftId, moodId, error: rawErr.message }); + throw rawErr; + } + } } + if (falukantDebug && nullIdIssues > 0) { + console.warn(`[Falukant] MoodLinks miss=${nullIdIssues} (bis 10 geloggt)`); + if (anomalies.length) console.warn('[Falukant] MoodLinks Beispiele:', anomalies.slice(0, 3)); + } + console.log(`[Falukant] MoodLinks neu=${createdCount} upd=${updatedCount}${nullIdIssues?` miss=${nullIdIssues}`:''}`); }; export const initializeFalukantHouseTypes = async () => { @@ -801,20 +863,25 @@ export const initializePoliticalOfficeTypes = async () => { }; export const initializePoliticalOfficePrerequisites = async () => { + let created = 0; + let existing = 0; + let skipped = 0; for (const prereq of politicalOfficePrerequisites) { - const office = await PoliticalOfficeType.findOne({ - where: { name: prereq.officeTr } - }); - if (!office) continue; - - await PoliticalOfficePrerequisite.findOrCreate({ - where: { office_type_id: office.id }, - defaults: { - office_type_id: office.id, - prerequisite: prereq.prerequisite - } - }); + const office = await PoliticalOfficeType.findOne({ where: { name: prereq.officeTr } }); + if (!office) { skipped++; continue; } + try { + const [record, wasCreated] = await PoliticalOfficePrerequisite.findOrCreate({ + where: { officeTypeId: office.id }, + defaults: { officeTypeId: office.id, prerequisite: prereq.prerequisite } + }); + if (wasCreated) created++; else existing++; + } catch (e) { + if (falukantDebug) console.error('[Falukant] OfficePrereq Fehler', { officeId: office?.id, error: e.message }); + // Fehler weiterwerfen um Initialisierung nicht still zu verschlucken + throw e; + } } + console.log(`[Falukant] OfficePrereq neu=${created} exist=${existing}${skipped?` skip=${skipped}`:''}`); }; export const initializeUndergroundTypes = async () => { diff --git a/backend/utils/redis.js b/backend/utils/redis.js index 28ea97d..1ce7de1 100644 --- a/backend/utils/redis.js +++ b/backend/utils/redis.js @@ -1,13 +1,16 @@ -import dotenv from 'dotenv'; import { createClient } from 'redis'; import User from '../models/community/user.js'; - -dotenv.config(); +// dotenv wird global in server.js/app.js geladen const EXPIRATION_TIME = 30 * 60 * 1000; +const redisHost = process.env.REDIS_HOST || '127.0.0.1'; +const redisPort = process.env.REDIS_PORT || '6379'; +if (!process.env.REDIS_HOST || !process.env.REDIS_PORT) { + console.warn(`[redis] Verwende Fallback ${redisHost}:${redisPort}`); +} const redisClient = createClient({ - url: `redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`, + url: `redis://${redisHost}:${redisPort}`, password: process.env.REDIS_PASSWORD, legacyMode: false, }); diff --git a/backend/utils/sequelize.js b/backend/utils/sequelize.js index d9ae69a..730a38c 100644 --- a/backend/utils/sequelize.js +++ b/backend/utils/sequelize.js @@ -1,4 +1,4 @@ -import { Sequelize } from 'sequelize'; +import { Sequelize, DataTypes } from 'sequelize'; import dotenv from 'dotenv'; dotenv.config(); @@ -8,8 +8,7 @@ const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, proces dialect: 'postgres', define: { timestamps: false, - underscored: true, // WICHTIG: Alle Datenbankfelder im snake_case Format - freezeTableName: true // Verhindert Pluralisierung der Tabellennamen + underscored: true // WICHTIG: Alle Datenbankfelder im snake_case Format }, }); @@ -285,18 +284,23 @@ const findModelForTable = (schemaName, tableName, models) => { // Hilfsfunktion: Konvertiert Sequelize-Datentyp zu PostgreSQL-Datentyp const getExpectedDataType = (attribute) => { + if (!attribute || !attribute.type) return 'text'; const type = attribute.type; - - if (type instanceof sequelize.DataTypes.INTEGER) return 'integer'; - if (type instanceof sequelize.DataTypes.STRING) return 'character varying'; - if (type instanceof sequelize.DataTypes.TEXT) return 'text'; - if (type instanceof sequelize.DataTypes.BOOLEAN) return 'boolean'; - if (type instanceof sequelize.DataTypes.DATE) return 'timestamp without time zone'; - if (type instanceof sequelize.DataTypes.JSON) return 'json'; - if (type instanceof sequelize.DataTypes.DECIMAL) return 'numeric'; - - // Fallback - return 'text'; + + // Direktklassentypen in Sequelize sind Funktionen/Klassen; "instanceof" funktioniert bei Wrappern wie DataTypes.INTEGER() nicht immer. + // Deshalb vergleichen wir über den .key wenn verfügbar. + const key = type.key || type.constructor?.key; + switch (key) { + case 'INTEGER': return 'integer'; + case 'STRING': return 'character varying'; + case 'TEXT': return 'text'; + case 'BOOLEAN': return 'boolean'; + case 'DATE': return 'timestamp without time zone'; + case 'JSON': return 'json'; + case 'DECIMAL': return 'numeric'; + default: + return 'text'; + } }; // Hilfsfunktion: Konvertiert Sequelize-Default zu PostgreSQL-Default diff --git a/frontend/src/i18n/locales/en/navigation.json b/frontend/src/i18n/locales/en/navigation.json index 958d268..f1a8986 100644 --- a/frontend/src/i18n/locales/en/navigation.json +++ b/frontend/src/i18n/locales/en/navigation.json @@ -29,9 +29,6 @@ "videos": "Videos" } }, - "m-minigames": { - "match3": "Match 3 - Jewels" - }, "m-settings": { "homepage": "Homepage", "account": "Account",