diff --git a/src/api/models/messaging-history.ts b/src/api/models/messaging-history.ts index c06987e451..1e79032ed6 100644 --- a/src/api/models/messaging-history.ts +++ b/src/api/models/messaging-history.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('messaging_histories') as any; // fuck type definition +const MessagingHistory = db.get('messagingHistories'); +export default MessagingHistory; + +export type IMessagingHistory = { + _id: mongo.ObjectID; + updatedAt: Date; + userId: mongo.ObjectID; + partnerId: mongo.ObjectID; + messageId: mongo.ObjectID; +}; diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts index fcb356c5ca..026b23cf36 100644 --- a/src/api/models/messaging-message.ts +++ b/src/api/models/messaging-message.ts @@ -5,16 +5,17 @@ import { pack as packFile } from './drive-file'; import db from '../../db/mongodb'; import parse from '../common/text'; -const MessagingMessage = db.get('messaging_messages'); +const MessagingMessage = db.get('messagingMessages'); export default MessagingMessage; export interface IMessagingMessage { _id: mongo.ObjectID; - created_at: Date; + createdAt: Date; text: string; - user_id: mongo.ObjectID; - recipient_id: mongo.ObjectID; - is_read: boolean; + userId: mongo.ObjectID; + recipientId: mongo.ObjectID; + isRead: boolean; + fileId: mongo.ObjectID; } export function isValidText(text: string): boolean { diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 6d6b01a071..ac0476af0c 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -79,3 +79,25 @@ db.following.update({}, { follower_id: 'followerId', } }, false, true); + +db.messaging_histories.renameCollection('messagingHistories'); +db.messagingHistories.update({}, { + $rename: { + updated_at: 'updatedAt', + user_id: 'userId', + partner: 'partnerId', + message: 'messageId', + } +}, false, true); + +db.messaging_messages.renameCollection('messagingMessages'); +db.messagingMessages.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + recipient_id: 'recipientId', + file_id: 'fileId', + is_read: 'isRead' + } +}, false, true); +