Project 1: Ensuring Rocket.Chat database consistency by Chuan De Sheng
This series of blog posts will share the Google Summer of Code projects that our 2018 cohort of students are working on. Community memebers are encouraged to join them in creating and testing these exciting new areas of features.
Each project will have their open source repository listed. Please feel free to drop in and say hello, or join in the action with your own issue or code contribution.
Mentors: Diego Sampaio, Rodrigo Nascimento, Sing Li
The first installment of this blog series features Chuan de Sheng’s database schema builder that will ensure database integrity across all versions of Rocket.Chat.
Consistency of database structure over time can be an ongoing problem
With NoSQL databases, the structure (or schema) of a database is not enforced by the database engine. Rocket.Chat uses the leading NoSQL database, MongoDB, for its data storage requirements. Different versions of Rocket.Chat have slightly different database schemas. When users try to upgrade their version of Rocket.Chat to a newer one, data migration is performed automatically. However, there are currently no checks to ensure that the old database schema is completely consistent with the new database, and its integrity can therefore become compromised over time. This is especially true if the user has attempted any kind of custom modifications or development during the lifetime of a Rocket.Chat server.
On the road to enforcing NoSQL database consistency
You can find Chuan de Sheng’s work here. This project first defines a base schema for Rocket.Chat’s current database and creating a mechanism to validate any new entry prior to its inclusion in the database. The mechanism must also be dynamic, so that users are able to add or modify fields, while ensuring that all data in the current base schema of Rocket.Chat is consistent, and avoids application breakage or data corruption due to an inconsistent / unexpected schema elements.
The second aim of this project is to use data relations between the field types to double-check data, especially after migration of data in an existing Rocket.Chat instance.
A Rocket.Chat database schema builder – WIP
Chuan’s has created a database schema builder. This database schema builder will help community users access and keep track of the schema, despite having architectural database changes. Subsequently, code and output from the schema builder may be incorporated into Rocket.Chat itself for ongoing enforcement of database consistency.
An immediate benefit for community users
One immediate benefit of this project is the feature for an administrator of a Rocket.Chat instance to view the current structure/schema (not the data itself) of his/her Rocket.Chat database. The schema is displayed in an easy-to-understand format for the administrator.
About the creator: Chuan De Sheng
Chuan is a fourth year Material Sciences undergraduate from Singapore who balances his studies with his passion for coding. He was interested in Rocket.Chat as he had worked with Meteor.JS for a long time and wanted to give something back to the community. Chuan recently worked on a forum/chat platform as a side project with friends and is looking forward to applying what he learnt from it to a meaningful project during GSOC, with the added bonus of getting experience using MongoDB and of gaining insight into how the open source contribution process works.