Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Standardize collection names

Open engelgabriel opened this issue 11 years ago • 13 comments

All to lowercase, and remove data. prefix

engelgabriel avatar May 28 '15 15:05 engelgabriel

Questions:

  1. Does data.ChatRoom becomes chat_room or chatroom?
  2. Any other collections besides: data.ChatMessage, data.ChatRoom, data.ChatSubscription, and data.ChatTyping?
  3. Does the solution need to migrate existing data? Meteor doesn't support renaming or deleting a collection as far as I know. Any suggestions?

rwakida avatar Jul 09 '15 21:07 rwakida

I was thinking in to use a prefic like "rocket" for collection names. should be one of these:

  • rocket.chatRoom, rocket.chatMessage, rocket.chatSubscription, ...
  • rocketRoom, rocketMessage, rocketSubscription, ...

I think using a prefix is the best for an existing database with other collections.

What do you others think?

sampaiodiego avatar Jul 09 '15 22:07 sampaiodiego

I think we should either lose the prefix all together.. and use

  • rooms
  • messages
  • subscriptions

or

  • rocketchat_rooms
  • rocketchat_messages
  • rocketchat_subscriptions

engelgabriel avatar Jul 10 '15 13:07 engelgabriel

As an outsider learning the system, the prefix helps to differentiate Rocket.Chat's collections from non-Rocket.Chat collections. I like rocketchat_rooms format.

What about existing data migration?

rwakida avatar Jul 11 '15 00:07 rwakida

I agree with @rwakida.

About the data migration we already use one lib to do migrations, you can see here (https://github.com/RocketChat/Rocket.Chat/tree/master/server/startup/migrations)

rodrigok avatar Jul 11 '15 00:07 rodrigok

Thanks @rodrigok. I saw the migrations, but I think this is a special case. Meteor (from what I know) doesn't support Mongo's renameCollection or drop collection. So we either have to:

  1. Instruct the user to manually run renameCollection from the shell before starting meteor. or
  2. Rename the collections in collections.coffee. Create a migration that accesses the old collections and migrates the data to the new collections.

The first option is clean, but requires user intervention. The second option is user-friendly, but leaves the old collections and the user has to manually drop the old collections.

A Google search suggested using a Node package that provides shell access, but only works when NOT using the embedded MongoDB.

I'm relatively new to Meteor so please excuse me if I missed something.

rwakida avatar Jul 11 '15 00:07 rwakida

@rodrigok but using meteor could be painful since you can't rename collections

sampaiodiego avatar Jul 11 '15 00:07 sampaiodiego

IMHO, there is no problem in create the new collections, migrate de data from old collections, remove old data and keep this collections empty.

We don't have a stable version yet, this seems to be a very small problem.

rodrigok avatar Jul 11 '15 19:07 rodrigok

I have merged this PR, but I think we should also change the names of "settings" and "migrations" collections. Also, rename "userSessions" to "user_sessions".

marceloschmidt avatar Jul 17 '15 18:07 marceloschmidt

Hi @marceloschmidt. Sorry, I missed those collections. I noticed you added the "in Progress" label. Does that mean you're taking over and renaming the settings, migrations, and userSessions collections?

rwakida avatar Jul 17 '15 23:07 rwakida

Thanks for the work @rwakida, you did a great job. @marceloschmidt just labeled as in progress so we know that is half done. Having said, I am not sure you'd have access to control the name of all those collection from our repository. Some are 3rd party packages, other are made by us, but in other repositories... you can give it a try and let us know.

engelgabriel avatar Jul 18 '15 00:07 engelgabriel

Thanks and great job on Rocket.Chat!

@engelgabriel @marceloschmidt I did a quick search and found that settings and oembed_cache are under Rocket.Chat control. I added both to the v9 migration and created a new pull request.

rwakida avatar Jul 18 '15 08:07 rwakida

Thank you very much @rwakida

marceloschmidt avatar Jul 19 '15 22:07 marceloschmidt